Skip to content

fix(test): seed TestGuardOwedAbsoluteMeasuredCommand with CheckContext (#3008) - #3017

Open
Gaoshou101 wants to merge 2 commits into
Agent-Field:devfrom
Gaoshou101:fix/guard-owed-absolute-context-3008
Open

Gaoshou101 wants to merge 2 commits into
Agent-Field:devfrom
Gaoshou101:fix/guard-owed-absolute-context-3008

Conversation

@Gaoshou101

@Gaoshou101 Gaoshou101 commented Dec 2, 2026 •

Copy link
Copy Markdown

Fixes #3008

What changed

  • TestGuardOwedAbsoluteMeasuredCommand previously seeded the inherited synthetic check (old) with Context: make([]string, 8) (all empty strings), while running the subsequent go test ./... through the live bash observer (_codeaf_check), which populates next.Context from checkContextNames (GOOS, GOARCH, GOFLAGS, CGO_ENABLED, GOWORK, GORACE, NODE_ENV, PYTEST_ADDOPTS). Whenever any of those variables was exported in the runner environment, next.identity != old.identity kept the saved absolute failure owed even after a matching portable rerun.
  • Exported verification.CheckContext() in internal/factory/verification/receipts.go (and reused it in CoversUnrun in internal/factory/verification/go_requirements.go to avoid duplicating the checkContextNames loop), and seeded old.Context in TestGuardOwedAbsoluteMeasuredCommand with verification.CheckContext().
  • Added TestGuardOwedAbsoluteMeasuredCommandContext in cmd/codeaf/factory_guard_stale_test.go to pin both sides of the contract with t.Setenv: a rerun under a different GOOS keeps the saved failure owed, while a portable rerun under the matching non-empty GOOS + GOWORK context clears it.

How it was checked

  • Reproduced failure before fix on dev (a5499811) with GOOS=linux and GOWORK=off:
    • GOOS=linux go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand$' ./cmd/codeaf -> FAIL at factory_guard_stale_test.go:270: portable rerun did not clear saved absolute failure: repair is incomplete; owed: 'go' 'test' './...' ...
    • GOWORK=off go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand$' ./cmd/codeaf -> FAIL at factory_guard_stale_test.go:270
  • Verified after fix:
    • go test -v -count=1 -run '^TestGuard' ./cmd/codeaf -> PASS (1.144s, all 10 TestGuard* tests)
    • GOOS=linux go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand' ./cmd/codeaf -> PASS (0.252s)
    • GOWORK=off go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand' ./cmd/codeaf -> PASS (0.191s)
    • CGO_ENABLED=0 GOFLAGS=-v go test -v -count=1 -run '^TestGuardOwedAbsoluteMeasuredCommand' ./cmd/codeaf -> PASS (0.195s)
    • go test -race -count=1 ./internal/factory/verification -> PASS (4.930s)
    • go test -count=1 ./internal/namelaw ./cmd/codeaf-changes ./internal/factory/verification -> PASS
    • go vet ./internal/factory/verification ./cmd/codeaf -> clean (exit 0)
    • gofmt -l and git diff --check -> clean
    • Scope limit: did not run the full-repo suite or -race on cmd/codeaf due to container link time; added docs/changes/unreleased/3017-guard-owed-absolute-context.md and validated via make changelog-check.

Checklist

  • Only my own paths are staged — no git add -A.
  • A change entry — docs/changes/unreleased/3017-guard-owed-absolute-context.md added and validated with make changelog-check.
  • No slash command, key, tool, default, limit, or refusal moved (internal/manual/chat/ unaffected).

Fixes Agent-Field#3008

TestGuardOwedAbsoluteMeasuredCommand hardcoded Context: make([]string, 8)
on the inherited synthetic check while executing the portable rerun through
the live bash check observer, which records the runner's checkContextNames
(GOOS, GOARCH, GOFLAGS, CGO_ENABLED, GOWORK, GORACE, NODE_ENV, PYTEST_ADDOPTS).
When any of those variables was set in the environment, the context mismatch
kept the saved absolute failure owed even after a matching portable rerun.

Export verification.CheckContext() (also reused by CoversUnrun), use it to
seed the inherited check, and add TestGuardOwedAbsoluteMeasuredCommandContext
to verify both matching non-empty context clearing and cross-context holding.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@santoshkumarradha

Copy link
Copy Markdown
Member

Hey, thanks for the PR. Could you sign the CLA when you get a chance so we can review it?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestGuardOwedAbsoluteMeasuredCommand fails on a clean dev tree

3 participants