Repository navigation
Description
Current state
| Item | Value |
|---|---|
| File | pkg/lifecycle/lifecycle_test.go |
| Source pair | pkg/lifecycle/lifecycle.go (+ rules.go) |
| Test functions | 6 (plus helper testDelivery) |
| Lines | 153 |
| Assertions | require only; no assert |
| Parallelism | no t.Parallel() |
Strengths
TestDeliveryAdoptionRulesis table-driven and covers the rule matrix.TestLifecycleIdentitySeparatesEffectsAndAttemptschecks that identity changes split records.TestLifecycleDecisionAndReversaland the replay-conflict test cover the main lifecycle transitions.
Prioritized improvements
1. Missing high-value tests
Each example below was verified against a stdlib-only copy of lifecycle.go and rules.go.
IsHumanhas no test. It is public API (seepkg/lifecycle/README.md:31) and is called frompkg/cli/logs_lifecycle_adoption.go:145. Suggested table:
func TestIsHuman(t *testing.T) {
publishers := []string{"gh-aw-bot"}
tests := []struct {
name, actorType, login string
want bool
}{
{"user", "User", "alice", true},
{"dependabot bot", "User", "dependabot[bot]", false},
{"renovate bot upper case", "User", "Renovate[BOT]", false},
{"bot actor type", "Bot", "alice", false},
{"empty login", "User", "", false},
{"publisher, case-insensitive", "User", "GH-AW-BOT", false},
{"organization", "Organization", "acme", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, IsHuman(tt.actorType, tt.login, publishers))
})
}
}Deliveredtarget-URL validation is untested. These are rejected:(redacted) scheme, a foreign host, userinfo, and a query string. Also untested:RunID == 0` rejection.Observeerror paths are untested. These are: invalid state, zeroObservedAt, and a decision earlier than delivery.MergeDelivery.Atconflict is untested. With identity held fixed, a differentDelivery.Atreturnsconflicting lifecycle identity or delivery evidence.Mergewith empty previous and an invalid incoming record returns an error, but nothing asserts it.Adoption.EqualUTC normalization is not asserted. The same instant in a different zone comparesEqual == truewhile==is false, andMergeaccepts it.
2. Fix the weak fallback loop
In TestLifecycleValidatesRetainedDecisionsAndAcceptanceKinds (lines 139–146), both loop iterations set At = Delivery.At + 1s. The time clause therefore fails on every iteration, and the human flag is never isolated. The loop name suggests it tests the human-flag predicate, but it does not.
Verified behavior: At == Delivery.At with HumanVerified=false succeeds. Both At+1s and HumanVerified=true return the same message, delivery fallback is not permitted, because Observe combines both checks in one condition. Assert the success control first, then check each violated clause:
// Before
for _, human := range []bool{false, true} {
_, err = Observe(fallback, Observation{
State: "accepted", Signal: "delivered", At: fallback.Delivery.At.Add(time.Second),
ObservedAt: at, HumanVerified: human, AcceptanceKind: "fallback_delivery",
})
require.ErrorContains(t, err, "fallback is not permitted")
}
// After
_, err = Observe(fallback, Observation{
State: "accepted", Signal: "delivered", At: fallback.Delivery.At,
ObservedAt: at, AcceptanceKind: "fallback_delivery",
})
require.NoError(t, err)
_, err = Observe(fallback, Observation{
State: "accepted", Signal: "delivered", At: fallback.Delivery.At.Add(time.Second),
ObservedAt: at, AcceptanceKind: "fallback_delivery",
})
require.ErrorContains(t, err, "fallback is not permitted")
_, err = Observe(fallback, Observation{
State: "accepted", Signal: "delivered", At: fallback.Delivery.At,
ObservedAt: at, HumanVerified: true, AcceptanceKind: "fallback_delivery",
})
require.ErrorContains(t, err, "fallback is not permitted")3. Assertion upgrades
- Use
assertfor behavior checks and keeprequirefor setup, followingscratchpad/testing.md. Setup calls such asDeliveredand the firstObserveshould stay onrequire. - Prefer
assert.Equaloverrequire.Equalfor field comparisons inTestLifecycleIdentitySeparatesEffectsAndAttempts, so one failing field does not hide the rest.
4. Table-driven refactor
TestLifecycleIdentitySeparatesEffectsAndAttempts checks identity changes one by one. Move the Host, Workflow, Type, and TargetURL changes into a table so each field gets its own subtest.
5. Optional: t.Parallel()
The repo uses t.Parallel() in about 754 of 2,695 test files. These tests are pure functions with no shared state, so adding it is low risk.
Acceptance checklist
-
IsHumantable test added, covering user, bot, case-insensitive publisher, and organization cases -
Deliveredrejects `(redacted) foreign host, userinfo, and query string -
Observeerror paths covered: invalid state, zeroObservedAt, decision before delivery -
MergeDelivery.Atconflict covered - Fallback loop split into separate assertions that isolate
HumanVerifiedand time -
make test-unitpasses (orgo test ./pkg/lifecycle/)
Environment limitation
go test ./pkg/lifecycle/ could not run in the analysis sandbox. github.com/stretchr/[email protected] could not be downloaded from proxy.golang.org because of a TLS certificate error. The probe results above come from a stdlib-only copy of lifecycle.go and rules.go. Confirm them by running the suite in CI before merging test changes.
Generated by 🧪 Daily Testify Uber Super Expert · copilot · routed: haiku55 xhigh · ~9 AIC · ⌖ ~2 AIC · ⊞ 3.9K · ◷
- expires on Nov 19, 2026, 10:13 AM UTC-08:00
Activity
github-actions commentedon Nov 18, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪