Repository navigation
audit: report model resolution startup failures from the unified session - #70653
Conversation
Co-authored-by: SivaKesava1 <11771739+SivaKesava1@users.noreply.github.com>
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Commit pushed:
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Two small opportunities to keep the new session parser aligned with the existing unified-session conventions.
net: -14 lines possible.
Generated by ✂️ Ponytail Reviewer for #70653 · codex · gpt56 · 17.2 AIC · ⌖ 5.33 AIC · ⊞ 14.7K
Comment /ponytail to run again
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Verdict: changes requested
The new parser has two correctness/robustness gaps: duplicate execution summaries are order-dependent, and unified-session processing has no total resource bound. Both can produce incorrect audit attribution or prevent audits from completing on untrusted artifacts. See the inline comments for surgical fixes.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · 2.64 AIC · ⌖ 0.689 AIC · ⊞ 1.6K
Comment /review to run again
🏗️ Design Decision Gate — ADR RequiredThis PR adds a lot of core business logic (1,470 new lines under The main decision here is to make the unified session ( 📄 Draft ADR committed:
📋 What to do next
Once the ADR is linked in the PR body, this gate will run again and check that the implementation matches the decision. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
🟡 Changes recommended
Startup attribution can misdiagnose unrelated failures as fatal model-resolution errors.
5 open issues
What changed in this PR
Extends gh aw audit to diagnose model-resolution failures from unified sessions, addressing #70648 beyond the existing Pi-only detection.
Changes:
- Adds session parsing, startup attribution, and role/model grouping.
- Reuses same-run inventory checks while preserving the legacy Pi fallback.
- Adds an advisory code, replay fixtures, and end-to-end coverage.
| File | Description |
|---|---|
pkg/cli/testdata/model_resolution_startup/39508154330/aw_session.jsonl |
Native-continuation fixture. |
pkg/cli/testdata/model_resolution_startup/39508150750/awf-reflect.json |
Same-run model inventory. |
pkg/cli/testdata/model_resolution_startup/39508150750/aw_session.jsonl |
Post-merge resolution-failure fixture. |
pkg/cli/testdata/model_resolution_startup/39508150750/agent-session.jsonl |
Error-summary-only fixture. |
pkg/cli/testdata/model_resolution_startup/39508150750/agent_execution.json |
Wrapper-state fixture. |
pkg/cli/testdata/model_resolution_startup/39499464895/awf-reflect.json |
Routed-run model inventory. |
pkg/cli/testdata/model_resolution_startup/39499464895/aw_session.jsonl |
Routed failure with classifier traffic. |
pkg/cli/testdata/model_resolution_startup/39499464895/agent-session.jsonl |
Error-summary-only fixture. |
pkg/cli/testdata/model_resolution_startup/39499464895/agent_execution.json |
Wrapper-state fixture. |
pkg/cli/testdata/model_resolution_startup/39499460077/awf-reflect.json |
Two-role failure inventory. |
pkg/cli/testdata/model_resolution_startup/39499460077/aw_session.jsonl |
Two-role resolution-failure fixture. |
pkg/cli/testdata/model_resolution_startup/39499460077/agent-session.jsonl |
Error-summary-only fixture. |
pkg/cli/testdata/model_resolution_startup/39499460077/agent_execution.json |
Wrapper-state fixture. |
pkg/cli/audit_model_resolution.go |
Parses evidence and generates findings. |
pkg/cli/audit_model_resolution_test.go |
Adds replay and audit-pipeline tests. |
pkg/cli/audit_model_availability.go |
Prioritizes session evidence and shares inventory checks. |
pkg/cli/audit_finding_codes.go |
Registers the advisory and playbook link. |
Review effort: Max
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd and /grill-with-docs (per pr-triage classification: new_feature), with a couple of /codebase-design notes. No correctness-blocking issues found — posting as COMMENT with minor, non-blocking suggestions.
📋 Key Themes & Highlights
Key Themes
- Test coverage gaps (minor): no test for the "malformed session → silent fallback to legacy Pi path" branch in
generateModelAvailabilityFindings, and no test for a run producing both a confirmed-unavailable group and an unverified group simultaneously viaclassifyModelResolutionGroups. - Doc drift (acknowledged by author):
docs/.../reference/audit.mdstill framesmodel_unavailable/model_availability_unknownas Pi-only and omitsmodel_resolution_failed. The PR description calls this out as deliberately out-of-scope; flagged inline anyway since it's a real user-facing mismatch risk. - Readability (optional):
modelResolutionContinuationReason's opaque empty/non-empty string convention and the missing explicit no-op case inappendModelAvailabilityRecommendationsare both navigability nits, not bugs — tests already confirm current behavior is intentional.
Positive Highlights
- ✅ Conservative, well-reasoned attribution logic (conclusion + exit code + no native-agent-activity) that avoids misattributing optional-agent failures to run-level startup failure
- ✅ Strong security posture: strict regex validation on engine/role/model/provider/cause before quoting into findings, symlink rejection via
validateSubagentSessionSource, bounded line reads, and strictresolved_model == nullcontract enforcement - ✅ Excellent negative-control tests (
TestAuditModelAvailabilityRepositoryAgentFailureOnSuccessIsAdvisoryand the 5 invalid-session variants) that pin down edge-case behavior precisely - ✅ Honest acknowledgment of the ambiguity limitation (multiple failed roles, can't tell which stopped startup) directly in the PR body rather than hiding it
Investigation was bounded to the pre-fetched diff, fixtures, and directly-referenced helper functions (readUnifiedSessionLine, validateUnifiedDetectionHeader, validateSubagentSessionSource); testdata fixture diffs were spot-checked rather than read in full.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 156.1 AIC · ⌖ 15.4 AIC · ⊞ 10.1K
Comment /matt to run again
Comments that could not be inline-anchored
pkg/cli/audit_model_availability.go:38
[/tdd] When readSessionModelResolutionEvidence itself returns a non-nil err (malformed/oversized header, bad JSON line, etc.), this code silently falls through to generateLegacyPiModelAvailabilityFindings with no logged distinction from the normal "no evidence found" case. There is no test asserting this fallback-on-error path.
Content redacted to fit size limit.
@copilot please address this.
pkg/cli/audit_model_resolution.go:298
[/codebase-design] modelResolutionContinuationReason encodes four conjunctive conditions (conclusion==failure, agent.execution present, non-zero exit code, no native agent activity) for attribution. The logic is correct per the tests, but the function returns an opaque reason string used purely as a non-empty/empty signal in the caller, which hides the decision table from readers at the call site.
Content redacted to fit size limit.
@copilot please address this.
pkg/cli/audit_model_availability.go:266
[/codebase-design] appendModelAvailabilityRecommendations has no case for the new AuditFindingModelResolutionFailed code. Tests confirm this is intentional (advisory-only, no recommendation), but a future maintainer scanning this switch for "all finding codes" could mistake the omission for a bug.
Content redacted to fit size limit.
@copilot please address this.
pkg/cli/audit_model_resolution_test.go:1
[/tdd] Good coverage overall (10 named acceptance tests plus 5 invalid-session variants), but I didn't find a case where classifyModelResolutionGroups produces both a confirmed model_unavailable group and an unverified model_availability_unknown group in the same run. The per-group classification loop in audit_model_resolution.go clearly supports this, but it's untested.
Content redacted to fit size limit.
@copilot please address this.
Review round: fix the valid review threadsCI is green. All 9 open threads are valid, and I'd fix them in one round:
|
…l resolution reading Co-authored-by: SivaKesava1 <11771739+SivaKesava1@users.noreply.github.com>


gh aw auditonly diagnosed model-availability failures from Pi'sagent-stdio.logmessage. It missed fail-closedmodel.resolutionrecords that the harnesses already write tousage/aw_session.jsonl, such as Copilot sub-agent runs 39499460077, 39499464895 and 39508150750. It now reads the unified session first and keeps the Pi log match only as a fallback.Session evidence (
audit_model_resolution.go, new)usage/aw_session.jsonlwith the existing boundedreadUnifiedSessionLine, requiring thesession.formatv1 header. Symlinks and non-regular files are rejected.model.resolutionevents only with the recorded provenance (model_resolution/agent/agent/model-resolution.json). Their fields are checked against the T-UAS-074 contract.agent.executionsummary (exit code, categories) and native-agent activity (session.start,assistant.*,tool.*from componentagent).Attribution
Failures are attributed as the startup cause only when all three hold: the run failed,
agent.executionexited non-zero, and there is no native agent activity. Router or classifier traffic, the wrapper'sstate: "started"and an error-summary-onlyagent-session.jsonldo not count as the agent continuing.Otherwise audit emits one low-severity advisory: new code
model_resolution_failed, titled Model Resolution Failure Recorded. This matters because a repository-agent record is identical to a declared sub-agent record, and the producer was not changed to tell them apart.When several roles failed, the finding states that the session cannot identify which role stopped startup.
Classification
awf-reflect.json, throughcheckModelAvailability, which was extracted from the Pi path with its messages unchanged.model_unavailable(high).model_availability_unknown.model_unavailable(e.g.catalog_unavailable) are reported as recorded and never confirmed as unavailable.Legacy fallback (
audit_model_availability.go)The Pi
agent-stdio.logmatch runs only when the session has no failed resolution events. It cannot double-report a failure or override a recorded cause.Example finding for 39499460077 (abridged):
Tests and fixtures
pkg/cli/testdata/model_resolution_startup/are sanitized from runs 39499460077, 39499464895, 39508150750 and 39508154330. Run 39508154330 supplies only the native-continuation events.catalog_unavailable, the continuation replay) are labelled as derived in test comments.…Run39499460077EndToEnddrivesAuditWorkflowRunthrough the fresh and cached paths with a fakeghand checks the JSON output,run_summary.json,audit.jsonand the console report.Notes for reviewers
gh aw audit 39499460077 --repo github/gh-aw --jsonwith a build of this PR; it has not been run here.lint-go-golangci: Go 1.27embedlitfindings inpkg/cli/add_interactive_workflow.go,pkg/cli/add_workflow_resolution.goandpkg/parser/mcp.go.TestWorkCommandPolicyFromConfigClosedFlagsinpkg/cli.docs/.../reference/audit.mdand.github/aw/debug-playbook.mdstill describe these findings as Pi-only and omitmodel_resolution_failed. They are left alone because this PR is limited topkg/cli.