pan-wizard 3.35.0 → 3.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3645 -0
- package/README.md +46 -52
- package/agents/pan-conductor.md +2 -3
- package/agents/pan-counterfactual.md +1 -2
- package/agents/pan-debugger.md +14 -3
- package/agents/pan-design-checker.md +1 -2
- package/agents/pan-designer.md +2 -3
- package/agents/pan-document_code.md +1 -2
- package/agents/pan-executor.md +25 -0
- package/agents/pan-hardener.md +4 -3
- package/agents/pan-integration-checker.md +1 -2
- package/agents/pan-knowledge.md +1 -2
- package/agents/pan-meta-reviewer.md +3 -3
- package/agents/pan-optimizer.md +4 -4
- package/agents/pan-phase-researcher.md +80 -475
- package/agents/pan-plan-checker.md +40 -3
- package/agents/pan-planner.md +21 -7
- package/agents/pan-previewer.md +3 -2
- package/agents/pan-project-researcher.md +72 -493
- package/agents/pan-release.md +1 -1
- package/agents/pan-reviewer.md +14 -3
- package/agents/pan-roadmapper.md +12 -7
- package/agents/pan-verifier.md +9 -4
- package/bin/install-lib.cjs +134 -14
- package/bin/install.js +59 -12
- package/commands/pan/army.md +1 -1
- package/commands/pan/autodev.md +76 -0
- package/commands/pan/cost.md +21 -1
- package/commands/pan/exec-phase.md +3 -4
- package/commands/pan/focus-auto.md +14 -7
- package/commands/pan/focus-design.md +4 -5
- package/commands/pan/focus-docs.md +24 -0
- package/commands/pan/learn.md +13 -6
- package/commands/pan/milestone-audit.md +8 -1
- package/commands/pan/milestone-done.md +10 -5
- package/commands/pan/milestone-new.md +2 -2
- package/commands/pan/new-project.md +15 -12
- package/commands/pan/plan-phase.md +15 -9
- package/commands/pan/preview.md +1 -1
- package/commands/pan/quick.md +1 -1
- package/commands/pan/review-deep.md +11 -5
- package/commands/pan/settings.md +6 -0
- package/commands/pan/verify-phase.md +6 -2
- package/docs/AGENTS.md +917 -0
- package/docs/ARCHITECTURE.md +1054 -0
- package/docs/CLI-REFERENCE.md +4582 -0
- package/docs/COMPARISON.md +116 -0
- package/docs/DEVELOPMENT.md +490 -0
- package/docs/ECOSYSTEM-REVIEW-2026-06.md +107 -0
- package/docs/ECOSYSTEM-REVIEW-2026-08.md +349 -0
- package/docs/EXAMPLES.md +584 -0
- package/docs/FAQ.md +254 -0
- package/docs/FIELD-HARVEST-2026-07.md +88 -0
- package/docs/FIELD-REPORT-army-2026-06.md +121 -0
- package/docs/HOOKS.md +638 -0
- package/docs/IMPROVEMENT-TODO.md +246 -0
- package/docs/INTERNALS.md +485 -0
- package/docs/MIGRATION-v2-to-v3.md +258 -0
- package/docs/SECURITY-HARDENING.md +230 -0
- package/docs/SKILLS-ENHANCEMENT-PLAN-V2.md +122 -0
- package/docs/SKILLS-FULL-TEXT.md +9685 -0
- package/docs/SKILLS-REFERENCE.md +1037 -0
- package/docs/TROUBLESHOOTING.md +1084 -0
- package/docs/USER-GUIDE.md +1437 -0
- package/docs/archive/SKILLS-ENHANCEMENT-PLAN.md +230 -0
- package/docs/audits/AUDIT-2026-08-e2e-ROADMAP.md +117 -0
- package/docs/audits/AUDIT-2026-08-e2e-VERIFICATION.md +693 -0
- package/docs/audits/AUDIT-2026-08-e2e.md +1546 -0
- package/docs/audits/OUTSTANDING-2026-08.md +275 -0
- package/docs/audits/STABILITY-TEST-2026-08.md +640 -0
- package/docs/branding/README-brand-draft.md +119 -0
- package/docs/branding/handoff/IMPLEMENTATION.md +205 -0
- package/docs/branding/handoff/README-brand-draft.md +119 -0
- package/docs/branding/handoff/image-prompts.md +46 -0
- package/docs/branding/image-prompts.md +46 -0
- package/docs/branding/nano-banana-prompts.txt +60 -0
- package/docs/context-monitor.md +13 -0
- package/docs/decisions/ADR-0001-strategic-feature-prioritization.md +83 -0
- package/docs/decisions/ADR-0002-copilot-cli-runtime.md +71 -0
- package/docs/decisions/ADR-0003-smart-execution.md +84 -0
- package/docs/decisions/ADR-0004-copilot-cli-interaction.md +89 -0
- package/docs/decisions/ADR-0005-command-naming.md +80 -0
- package/docs/decisions/ADR-0006-focus-commands.md +101 -0
- package/docs/decisions/ADR-0007-ship-v1.md +73 -0
- package/docs/decisions/ADR-0008-map-codebase-mermaid-togaf.md +80 -0
- package/docs/decisions/ADR-0009-production-deployment-checklist.md +68 -0
- package/docs/decisions/ADR-0010-standards-integration.md +79 -0
- package/docs/decisions/ADR-0011-help-commands-rewrite.md +64 -0
- package/docs/decisions/ADR-0012-contributors-attribution-index.md +42 -0
- package/docs/decisions/ADR-0013-strategic-feature-additions.md +53 -0
- package/docs/decisions/ADR-0014-internal-cleanup-code-quality.md +53 -0
- package/docs/decisions/ADR-0015-focus-auto-runner.md +296 -0
- package/docs/decisions/ADR-0016-enhanced-doc-sync.md +54 -0
- package/docs/decisions/ADR-0017-enhanced-focus-design.md +69 -0
- package/docs/decisions/ADR-0018-user-reality-testing.md +84 -0
- package/docs/decisions/ADR-0019-end-to-end-user-acceptance-testing.md +113 -0
- package/docs/decisions/ADR-0020-ai-drift-prevention.md +55 -0
- package/docs/decisions/ADR-0021-codebase-mapper-v2.md +76 -0
- package/docs/decisions/ADR-0022-lifecycle-completeness.md +63 -0
- package/docs/decisions/ADR-0023-opus-4-7-adoption.md +89 -0
- package/docs/decisions/ADR-0024-spec-b-v2-completion.md +137 -0
- package/docs/decisions/ADR-0025-behavioral-guardrails-layer.md +129 -0
- package/docs/decisions/ADR-0026-self-improvement-loop.md +171 -0
- package/docs/decisions/ADR-0027-doc-code-link-graph.md +164 -0
- package/docs/decisions/ADR-0028-unified-agents-skills-target.md +46 -0
- package/docs/decisions/ADR-0029-experiment-evaluator.md +76 -0
- package/docs/decisions/ADR-0030-planning-concurrency.md +37 -0
- package/docs/decisions/ADR-0031-focus-auto-backlog-source.md +47 -0
- package/docs/decisions/ADR-0032-squad-model.md +64 -0
- package/docs/decisions/ADR-0033-army-campaign.md +40 -0
- package/docs/decisions/ADR-0034-scheduled-campaigns.md +57 -0
- package/docs/decisions/ADR-0035-army-hud-dashboard.md +40 -0
- package/docs/decisions/ADR-0036-agentic-memory-architecture.md +106 -0
- package/docs/decisions/ADR-0037-pin-security-agents-to-opus.md +51 -0
- package/docs/decisions/ADR-0038-skill-aligned-decomposition.md +41 -0
- package/docs/decisions/ADR-0039-worktree-as-project-variant.md +37 -0
- package/docs/decisions/ADR-0040-memory-injection-defense.md +55 -0
- package/docs/decisions/ADR-0041-mcp-dual-era-bridge.md +47 -0
- package/docs/decisions/ADR-0042-design-parity-both-flows.md +45 -0
- package/docs/decisions/ADR-0043-addressable-planning-roots.md +56 -0
- package/docs/decisions/ADR-0044-bound-the-cached-context.md +104 -0
- package/docs/decisions/ADR-0045-agent-plugins-bundle.md +76 -0
- package/docs/decisions/ADR-0046-subagent-frontmatter-decisions.md +39 -0
- package/docs/decisions/ADR-0047-pan-harness.md +76 -0
- package/docs/decisions/ADR-0048-one-core-per-project.md +43 -0
- package/docs/decisions/ADR-0049-machine-verdicts-and-findings-ledger.md +116 -0
- package/docs/specs/ai_drift_prevention_featureai.md +286 -0
- package/docs/specs/codebase_mapper_v2_featureai.md +930 -0
- package/docs/specs/command_naming_optimization_featureai.md +930 -0
- package/docs/specs/comp_analysis_markdown_v1.md +149 -0
- package/docs/specs/continuous_autonomous_execution_featureai.md +304 -0
- package/docs/specs/contributors_attribution_index_featureai.md +476 -0
- package/docs/specs/copilot_cli_interaction_featureai.md +868 -0
- package/docs/specs/copilot_cli_runtime_featureai.md +647 -0
- package/docs/specs/custom-skills-assessment.md +461 -0
- package/docs/specs/deployment_audit_findings_featureai.md +243 -0
- package/docs/specs/doc_code_link_graph_featureai.md +253 -0
- package/docs/specs/documentation_alignment_cleanup_featureai.md +69 -0
- package/docs/specs/e2e_visual_testing_featureai.md +615 -0
- package/docs/specs/end_to_end_user_acceptance_testing_featureai.md +810 -0
- package/docs/specs/evidence-loop-plan.md +76 -0
- package/docs/specs/evidence_loop_featureai.md +497 -0
- package/docs/specs/focus-auto-optimize-category.md +449 -0
- package/docs/specs/focus-auto-optimize-superplan.md +188 -0
- package/docs/specs/focus_auto_runner_featureai.md +1102 -0
- package/docs/specs/focus_design_v2_featureai.md +197 -0
- package/docs/specs/focus_sync_v2_featureai.md +202 -0
- package/docs/specs/git_integration_overhaul_featureai.md +326 -0
- package/docs/specs/glm_zai_provider_featureai.md +200 -0
- package/docs/specs/googlecli_adoption_featureai.md +661 -0
- package/docs/specs/help_commands_rewrite_featureai.md +860 -0
- package/docs/specs/industry_analysis_strategic_additions_featureai.md +231 -0
- package/docs/specs/industry_comparison_and_feature_gaps_featureai.md +674 -0
- package/docs/specs/internal_cleanup_code_quality_featureai.md +486 -0
- package/docs/specs/investigations/README.md +31 -0
- package/docs/specs/investigations/digests/2026-09-28.md +47 -0
- package/docs/specs/investigations/digests/2026-10-08.md +62 -0
- package/docs/specs/investigations/digests/2026-10-10.md +61 -0
- package/docs/specs/investigations/features/debugger-red-loop-first.md +55 -0
- package/docs/specs/investigations/features/harness-cross-host-behaviour.md +93 -0
- package/docs/specs/investigations/features/optimize-apply-regression-gate.md +66 -0
- package/docs/specs/investigations/features/reviewer-smell-baseline.md +57 -0
- package/docs/specs/investigations/features/trace-failure-capture.md +69 -0
- package/docs/specs/lifecycle_completeness_featureai.md +754 -0
- package/docs/specs/local-first-ci.md +42 -0
- package/docs/specs/map_codebase_mermaid_togaf_featureai.md +805 -0
- package/docs/specs/market-delta-2026-09-superplan.md +310 -0
- package/docs/specs/market-ideas-2026-09.md +131 -0
- package/docs/specs/market-ideas-2026-10.md +428 -0
- package/docs/specs/market-ideas-ledger.md +177 -0
- package/docs/specs/memory-optimization-2026-10.md +285 -0
- package/docs/specs/multi-track-planning-roots.md +143 -0
- package/docs/specs/multi_model_routing_featureai.md +687 -0
- package/docs/specs/multi_model_routing_superplan.md +197 -0
- package/docs/specs/opus_47_existing_enhancements_featureai.md +247 -0
- package/docs/specs/opus_47_extended_features_featureai.md +363 -0
- package/docs/specs/opus_47_extended_features_v2_featureai.md +397 -0
- package/docs/specs/pan_focus_commands_featureai.md +2336 -0
- package/docs/specs/pan_zcode_mcp_bridge_featureai.md +120 -0
- package/docs/specs/product-excellence-superplan.md +315 -0
- package/docs/specs/product_excellence_program_2026_q4_featureai.md +365 -0
- package/docs/specs/production_deployment_readiness_featureai.md +433 -0
- package/docs/specs/production_readiness_ship_v1_featureai.md +698 -0
- package/docs/specs/real_test_enforcement_featureai.md +213 -0
- package/docs/specs/reality-check-2026-09-superplan.md +362 -0
- package/docs/specs/right-sized-ceremony.md +74 -0
- package/docs/specs/roadmap_and_competition_2026_q4_featureai.md +390 -0
- package/docs/specs/self_improvement_loop_featureai.md +875 -0
- package/docs/specs/skill-aligned-decomposition.md +155 -0
- package/docs/specs/standards_integration_featureai.md +833 -0
- package/docs/specs/testing-system-redesign-2026-09.md +267 -0
- package/docs/specs/user_reality_testing_system_featureai.md +788 -0
- package/docs/specs/watch-triggers.json +22 -0
- package/docs/specs/workflow-integration-redesign.md +742 -0
- package/docs/specs/workflow_state_consistency_featureai.md +183 -0
- package/hooks/dist/pan-context-monitor.js +9 -2
- package/hooks/dist/pan-cost-logger.js +5 -0
- package/hooks/dist/pan-guard.js +28 -5
- package/hooks/dist/pan-stop-guard.js +9 -9
- package/hooks/dist/pan-trace-logger.js +5 -0
- package/package.json +10 -2
- package/pan-wizard-core/bin/lib/agents-md.cjs +57 -8
- package/pan-wizard-core/bin/lib/autodev-report.cjs +180 -0
- package/pan-wizard-core/bin/lib/autodev.cjs +642 -0
- package/pan-wizard-core/bin/lib/ci.cjs +143 -0
- package/pan-wizard-core/bin/lib/commands.cjs +1 -1
- package/pan-wizard-core/bin/lib/config.cjs +41 -5
- package/pan-wizard-core/bin/lib/constants.cjs +27 -1
- package/pan-wizard-core/bin/lib/core.cjs +31 -14
- package/pan-wizard-core/bin/lib/cost.cjs +160 -4
- package/pan-wizard-core/bin/lib/cross-family.cjs +164 -0
- package/pan-wizard-core/bin/lib/debug-cases.cjs +104 -0
- package/pan-wizard-core/bin/lib/doc-lint.cjs +5 -3
- package/pan-wizard-core/bin/lib/failure-class.cjs +81 -0
- package/pan-wizard-core/bin/lib/findings.cjs +148 -9
- package/pan-wizard-core/bin/lib/focus.cjs +1 -1
- package/pan-wizard-core/bin/lib/git.cjs +1 -1
- package/pan-wizard-core/bin/lib/hosts.cjs +88 -0
- package/pan-wizard-core/bin/lib/init.cjs +7 -2
- package/pan-wizard-core/bin/lib/knowledge.cjs +2 -0
- package/pan-wizard-core/bin/lib/merge.cjs +50 -0
- package/pan-wizard-core/bin/lib/mutate.cjs +268 -0
- package/pan-wizard-core/bin/lib/next-action.cjs +112 -0
- package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
- package/pan-wizard-core/bin/lib/phase-gate.cjs +15 -9
- package/pan-wizard-core/bin/lib/phase-remove.cjs +91 -11
- package/pan-wizard-core/bin/lib/phase.cjs +85 -13
- package/pan-wizard-core/bin/lib/plan-lint.cjs +310 -0
- package/pan-wizard-core/bin/lib/preview.cjs +26 -4
- package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
- package/pan-wizard-core/bin/lib/research-lint.cjs +268 -0
- package/pan-wizard-core/bin/lib/review-deep.cjs +14 -22
- package/pan-wizard-core/bin/lib/review-vote.cjs +105 -0
- package/pan-wizard-core/bin/lib/roadmap.cjs +1 -0
- package/pan-wizard-core/bin/lib/runner.cjs +2 -16
- package/pan-wizard-core/bin/lib/sizing.cjs +356 -0
- package/pan-wizard-core/bin/lib/squads.cjs +1 -1
- package/pan-wizard-core/bin/lib/state-write.cjs +247 -0
- package/pan-wizard-core/bin/lib/test-gate.cjs +433 -0
- package/pan-wizard-core/bin/lib/uat.cjs +149 -0
- package/pan-wizard-core/bin/lib/usage.cjs +104 -0
- package/pan-wizard-core/bin/lib/verdict.cjs +26 -3
- package/pan-wizard-core/bin/lib/verify-plan-set.cjs +30 -1
- package/pan-wizard-core/bin/lib/verify-preflight.cjs +2 -2
- package/pan-wizard-core/bin/lib/verify-red.cjs +174 -0
- package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
- package/pan-wizard-core/bin/lib/verify-scope.cjs +143 -2
- package/pan-wizard-core/bin/lib/verify.cjs +86 -31
- package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
- package/pan-wizard-core/bin/pan-tools.cjs +257 -28
- package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
- package/pan-wizard-core/mcp/orchestrator.cjs +4 -1
- package/pan-wizard-core/references/continuation-format.md +3 -3
- package/pan-wizard-core/references/design-methodology.md +1 -1
- package/pan-wizard-core/references/guardrails.md +1 -1
- package/pan-wizard-core/references/handoff-decisions.md +1 -1
- package/pan-wizard-core/references/model-profiles.md +2 -3
- package/pan-wizard-core/references/questioning.md +24 -0
- package/pan-wizard-core/references/ui-brand.md +4 -6
- package/pan-wizard-core/references/verdict-contract.md +2 -1
- package/pan-wizard-core/templates/config.json +10 -2
- package/pan-wizard-core/templates/debug.md +1 -0
- package/pan-wizard-core/templates/design.md +5 -4
- package/pan-wizard-core/templates/discovery.md +2 -2
- package/pan-wizard-core/templates/phase-prompt.md +7 -0
- package/pan-wizard-core/templates/requirements.md +9 -0
- package/pan-wizard-core/templates/research.md +10 -0
- package/pan-wizard-core/templates/summary-complex.md +5 -1
- package/pan-wizard-core/templates/summary-minimal.md +4 -0
- package/pan-wizard-core/templates/summary-standard.md +5 -1
- package/pan-wizard-core/templates/summary.md +8 -1
- package/pan-wizard-core/workflows/add-phase.md +4 -6
- package/pan-wizard-core/workflows/assumptions.md +19 -1
- package/pan-wizard-core/workflows/diagnose-issues.md +2 -0
- package/pan-wizard-core/workflows/discuss-phase.md +4 -2
- package/pan-wizard-core/workflows/exec-lean.md +69 -0
- package/pan-wizard-core/workflows/exec-phase.md +79 -15
- package/pan-wizard-core/workflows/execute-plan.md +3 -1
- package/{commands/pan → pan-wizard-core/workflows}/focus-doc-audit.md +13 -29
- package/{commands/pan → pan-wizard-core/workflows}/focus-drift-walking.md +3 -18
- package/{commands/pan → pan-wizard-core/workflows}/focus-exec.md +8 -23
- package/{commands/pan → pan-wizard-core/workflows}/focus-plan.md +6 -20
- package/{commands/pan → pan-wizard-core/workflows}/focus-scan.md +3 -16
- package/{commands/pan → pan-wizard-core/workflows}/focus-sync.md +7 -21
- package/pan-wizard-core/workflows/health.md +6 -0
- package/pan-wizard-core/workflows/help.md +114 -77
- package/pan-wizard-core/workflows/insert-phase.md +4 -6
- package/pan-wizard-core/workflows/learn.md +3 -3
- package/pan-wizard-core/workflows/milestone-audit.md +2 -2
- package/pan-wizard-core/workflows/milestone-new.md +38 -95
- package/pan-wizard-core/workflows/new-project.md +96 -258
- package/pan-wizard-core/workflows/optimize.md +107 -5
- package/pan-wizard-core/workflows/phase-tests.md +10 -0
- package/pan-wizard-core/workflows/plan-phase.md +106 -45
- package/pan-wizard-core/workflows/profile.md +50 -0
- package/pan-wizard-core/workflows/progress.md +10 -0
- package/pan-wizard-core/workflows/quick.md +34 -43
- package/pan-wizard-core/workflows/remove-phase.md +11 -1
- package/pan-wizard-core/workflows/research-phase.md +118 -40
- package/pan-wizard-core/workflows/resume-project.md +18 -2
- package/pan-wizard-core/workflows/settings.md +33 -19
- package/pan-wizard-core/workflows/todo-check.md +6 -2
- package/pan-wizard-core/workflows/transition.md +22 -4
- package/pan-wizard-core/workflows/uat-walkthrough.md +90 -0
- package/pan-wizard-core/workflows/update.md +1 -1
- package/pan-wizard-core/workflows/verify-phase.md +39 -46
- package/scripts/build-agent-plugin.js +35 -15
- package/scripts/build-help.cjs +106 -0
- package/scripts/build-plugin.js +10 -1
- package/scripts/deprecate-old-versions.js +70 -3
- package/scripts/generate-skills-docs.py +1 -1
- package/scripts/git-hooks/pre-push +27 -0
- package/scripts/install-git-hooks.js +7 -5
- package/scripts/install-pre-push.cjs +38 -0
- package/scripts/land.cjs +151 -0
- package/scripts/local-ci.cjs +501 -0
- package/scripts/local-schedule.cjs +277 -0
- package/scripts/mutation-probe.cjs +7 -80
- package/scripts/prompt-lint.cjs +32 -0
- package/scripts/prompt-rules.cjs +156 -0
- package/scripts/run-tests.cjs +7 -1
- package/scripts/test-quality-lint.cjs +3 -3
- package/scripts/test-surface.cjs +175 -6
- package/agents/pan-research-synthesizer.md +0 -246
- package/commands/pan/audit-deployment.md +0 -386
- package/commands/pan/dashboard.md +0 -22
- package/commands/pan/discord.md +0 -19
- package/commands/pan/mcp-bridge.md +0 -143
- package/commands/pan/milestone-cleanup.md +0 -19
- package/commands/pan/milestone-gaps.md +0 -35
- package/commands/pan/optimize.md +0 -115
- package/commands/pan/profile.md +0 -76
- package/commands/pan/research-phase.md +0 -189
- package/pan-wizard-core/bin/lib/bridge.cjs +0 -269
- package/pan-wizard-core/templates/research-project/architecture.md +0 -204
- package/pan-wizard-core/templates/research-project/features.md +0 -147
- package/pan-wizard-core/templates/research-project/pitfalls.md +0 -200
- package/pan-wizard-core/templates/research-project/stack.md +0 -120
- package/pan-wizard-core/templates/research-project/summary.md +0 -170
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Evidence loop — work plan (`/superplan`, 2026-09-28)
|
|
2
|
+
|
|
3
|
+
Builds [evidence_loop_featureai.md](evidence_loop_featureai.md) plus the market-ideas items that can be built on this machine. Branch `feat/evidence-loop`. Executed by `/execplan` in two sessions, back to back.
|
|
4
|
+
|
|
5
|
+
## Baseline (measured this run — reproduce, never copy)
|
|
6
|
+
|
|
7
|
+
| Metric | Value | Reproduce |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| Version | 3.31.0 | `package.json` |
|
|
10
|
+
| Tests | 4,657 / 4,658 pass. The one failure is the CLAUDE.md counts self-audit, which the new spec file tripped (specs on disk ≠ table) and which is fixed by the counts refresh in item G-1 | `npm run test:all` |
|
|
11
|
+
| Filesystem counts | see the CLAUDE.md table (the only place they live) | the snippet in CLAUDE.md |
|
|
12
|
+
| Open TODO/FIXME in shipped code | none actionable (historical `IMPROVEMENT-TODO` markers only) | `grep -rnE "TODO\|FIXME\|HACK" bin pan-wizard-core/bin/lib hooks` |
|
|
13
|
+
| Field evidence for the premise | see spec §1.1 (trace categories, failed tool calls per spawn, optimizer use) | spec §1.1 |
|
|
14
|
+
|
|
15
|
+
## Priority classes
|
|
16
|
+
|
|
17
|
+
Classes: **P0** BROKEN · **P1** WRONG · **P2** STABILITY · **P3** MISSING TESTS · **P4** FEATURE GAPS · **P5** NEW FEATURES · **P6** DOCS · **P7** POLISH.
|
|
18
|
+
Sizes: XS 1 · S 2 · M 4 · L 10 · XL 20.
|
|
19
|
+
|
|
20
|
+
## Items
|
|
21
|
+
|
|
22
|
+
### Evidence loop (spec items; the order below is the dependency order)
|
|
23
|
+
|
|
24
|
+
| ID | Pri | Size | Pts | Title | Files | Gate / verify |
|
|
25
|
+
|---|---|---|---|---|---|---|
|
|
26
|
+
| EL-1 | P5 | M | 4 | **Verdict contract.** `verdict.cjs` (pure): `parseVerdictBlock` (last block wins, backtick/tilde, indented fences), `validateVerdict` (required fields, vocabularies, truncation, `outcome_mismatch`), `verdictFromVerificationFrontmatter` (gaps / human_verification / unrequested), `findingId`, `recordSig`, constants. Reference `references/verdict-contract.md` with the class guide | `pan-wizard-core/bin/lib/verdict.cjs`, `pan-wizard-core/references/verdict-contract.md`, `tests/verdict.test.cjs`, `tests/fixtures/module-surface.json` | every §4.3 verdict case; module surface regenerated |
|
|
27
|
+
| EL-2 | P5 | S | 2 | **Judges emit the block.** The `pan-verdict` block goes at the end of the plan-checker, reviewer and design-checker return contracts (verdict words unchanged; the class/severity mapping cites the reference) | `agents/pan-plan-checker.md`, `agents/pan-reviewer.md`, `agents/pan-design-checker.md`, `tests/verdict-agents.test.cjs` | each agent's shipped example parses; the same after conversion for all five runtimes (installed via the real installer into temp dirs) |
|
|
28
|
+
| EL-3 | P1 | S | 2 | **Review chain, part 1.** exec-phase writes the reviewer's return verbatim to `{PHASE_DIR}/{PADDED}-review.md`; review-deep reads that path (not `.planning/phases/<N>/review.md`); `parseReviewFindings` takes a `pan-verdict` block when present. Today the reviewer half of every deep review merges as zero findings | `pan-wizard-core/workflows/exec-phase.md`, `commands/pan/review-deep.md`, `pan-wizard-core/bin/lib/review-deep.cjs`, `tests/review-deep.test.cjs`, `tests/evidence-workflows.test.cjs` | a reviewer report with a block merges its findings, and the test fails on the current parser (revert-proof); workflow drift assertions |
|
|
29
|
+
| EL-4 | P1 | S | 2 | **Review chain, part 2: `--deep-review` made real.** Documented since v3.4 and read nowhere. exec-phase runs the deep review after the normal review: hardener → meta-reviewer → `review-deep merge` over the persisted review.md | `pan-wizard-core/workflows/exec-phase.md`, `commands/pan/exec-phase.md` | drift test: the step exists, is gated on the flag, names the three outputs and the merge call |
|
|
30
|
+
| EL-5 | P5 | M | 4 | **Findings ledger + verb.** `findings.cjs`: append-only `.planning/findings.jsonl`, fold (auto-fix, exemptions, reopen, deliberate dispositions stick), `record` (idempotent by record_sig, attempts, trace events `verdict_*` / `verdict_retry`), `list`, `dispose` (reason required), `debt` (by milestone). Dispatcher arm `findings`; MCP resource `pan://findings` | `pan-wizard-core/bin/lib/findings.cjs`, `pan-wizard-core/bin/pan-tools.cjs`, `pan-wizard-core/mcp/tool-registry.cjs`, `tests/findings.test.cjs`, `tests/fixtures/surface.json`, `tests/fixtures/module-surface.json` | every §4.3 findings case; `node scripts/test-surface.cjs --check`; surface-map, dispatcher-arms and MCP resource tests green |
|
|
31
|
+
| EL-6 | P5 | S | 2 | **M11: unrequested work.** `verify scope <phase>` (declared `files_modified` vs changed = the phase's plan commits by subject + summary key-files; planning tree and lockfiles excluded; `test_for_declared` hint); verifier scope step + `unrequested:` frontmatter; template; reviewer lens | `pan-wizard-core/bin/lib/verify.cjs`, `pan-wizard-core/bin/pan-tools.cjs`, `agents/pan-verifier.md`, `agents/pan-reviewer.md`, `pan-wizard-core/templates/verification-report.md`, `tests/verify-scope.test.cjs` | scope cases (git and no-git); the adapter reads `unrequested:`; template test |
|
|
32
|
+
| EL-7 | P5 | M | 4 | **Workflows record on the critical path, and dispose where they continue.** exec-phase: record review and verification (grep kept as the `\|\|` fallback), deferrals at PASS_WITH_WARNINGS and "continue anyway", no `$REVIEW_OUTPUT`. plan-phase: persist plan-check.md, branch on `record --raw`, defer at force-proceed. verify-phase: record at return. design-phase: persist design-check.md, record. milestone-audit: tech debt from `findings debt`. The verdict-path `optimize trace log` blocks are removed | `pan-wizard-core/workflows/{exec-phase,plan-phase,verify-phase,milestone-audit}.md`, `commands/pan/design-phase.md`, `tests/evidence-workflows.test.cjs` | drift assertions per step; the native-workflow drift test still green; no verdict-category trace-log call remains |
|
|
33
|
+
| EL-8 | P7 | XS | 1 | **M17 `contract` field.** `"1.0"` on `state` (load), `state json`, `progress` JSON; the resources inherit it; the additive rule goes in CLI-REFERENCE | `pan-wizard-core/bin/lib/state.cjs`, `pan-wizard-core/bin/lib/commands.cjs`, `tests/contract-field.test.cjs` | CLI outputs and the `pan://state` / `pan://progress` resources carry it |
|
|
34
|
+
| EL-9 | P5 | M | 4 | **Tool-failure capture in the trace hook.** Agent-transcript slice only: `error/tool_error` (tool, class, exit code, redacted ≤160-character message, count; ≤10 per spawn), completion `tool_calls`/`tool_errors`, `SCHEMA_V` 5, `agent-<id>.meta.json` name fallback, `execution.error_pattern_learning: false` off switch. The fixture's shape comes from a real emitted transcript | `hooks/pan-trace-logger.js`, `tests/fixtures/hooks/subagent-tool-errors-claude.json` (+ `.meta.json`), `tests/trace-logger-failures.test.cjs` | every §4.3 hook case; the capture test fails on the pre-change hook (revert-proof); hooks-e2e green |
|
|
35
|
+
| EL-10 | P5 | M | 4 | **Learn reads the signal.** `analyzeEvents`: `tool_error_patterns` (agent, tool, class, message signature; occurrences, spawns, sessions), `verdict_stats`, legacy verdict categories kept; notes derived from recurring patterns only; `optimize learn --sessions <n>` pooling; stats totals; optimizer and learn docs | `pan-wizard-core/bin/lib/optimize.cjs`, `pan-wizard-core/bin/pan-tools.cjs`, `agents/pan-optimizer.md`, `pan-wizard-core/workflows/learn.md`, `commands/pan/learn.md`, `tests/optimize-evidence.test.cjs` | analysis cases; pooled learn; legacy sessions still analyse |
|
|
36
|
+
| EL-11 | P2 | M | 4 | **Revertible apply.** `apply_id` + per-action records + a re-apply guard: today a second apply of the same report appends everything twice. `optimize revert <id\|--last>`: EOL-tolerant hash refusal, last-in-first-out per file, CRLF preserved, legacy rows reported as not revertible; stats count reverts | `pan-wizard-core/bin/lib/optimize.cjs`, `pan-wizard-core/bin/pan-tools.cjs`, `commands/pan/optimize.md`, `pan-wizard-core/workflows/optimize.md`, `tests/optimize-revert.test.cjs` | byte-for-byte round trip (LF and CRLF); refusals; the re-apply guard test fails on the current module (revert-proof) |
|
|
37
|
+
| EL-12 | P3 | S | 2 | **Harness.** Tier-0 `evidence-loop` against a deployed install: the installed trace hook fed a SubagentStop payload with a failing-tool transcript, then `findings record/dispose/debt`, `optimize learn`, `optimize apply` → `revert`. Tier-1 `tool-error-capture` defined (a model run on `uat-with-failure`; `--max-usd`) | `harness/scenarios/evidence-loop.json`, `harness/scenarios/tool-error-capture.json`, `harness/scripts/evidence-loop.cjs` | `npm run harness` tier 0 green; scenario schema checks green |
|
|
38
|
+
|
|
39
|
+
### Market-ideas items buildable here
|
|
40
|
+
|
|
41
|
+
| ID | Pri | Size | Pts | Title | Files | Gate / verify |
|
|
42
|
+
|---|---|---|---|---|---|---|
|
|
43
|
+
| Q-1 | P4 | S | 2 | **M3: planning-with-files coexistence.** Re-read the upstream layout first (a scout claim is a lead). Marker set with a dated-directory pattern; health and hygiene name the tool; the tree counts as *shared*, not foreign, when PAN's own state files are present; new info code when `.planning/` is gitignored while `commit_docs` is true | `pan-wizard-core/bin/lib/constants.cjs`, `foreign-planning.cjs`, `verify.cjs`, `hygiene.cjs`, `tests/foreign-planning.test.cjs`, `docs/CLI-REFERENCE.md` | fixture trees: dated dir + `.active_plan` → planning-with-files; shared tree → info, not refusal; ignored `.planning/` → the new code |
|
|
44
|
+
| Q-2 | P7 | XS | 1 | **M16: async observers on Claude.** Only if the host docs confirm `async` on hook entries and that an unknown key does not invalidate settings, and a race review of the trace/cost cursors under concurrent hooks comes out clean. Otherwise record the decision not to ship, with the reason | `bin/install.js`, `bin/install-lib.cjs`, `tests/`, `docs/HOOKS.md` | settings fixture; or a dated "not shipped" note in the market queue |
|
|
45
|
+
| Q-3 | P6 | XS | 1 | **M18: host-control user docs.** Only for the controls a primary source confirms, written by capability (no version-pinned model names) | `docs/USER-GUIDE.md`, `docs/TROUBLESHOOTING.md` | doc-lint and model-version lint clean |
|
|
46
|
+
| Q-4 | P1 | S | 2 | **Copilot payload field names.** Cost and trace loggers accept the documented camelCase aliases (`sessionId`, `transcriptPath`, `agentId`, `agentType`); the result is the agent type recorded, and still no per-agent transcript. The fixture is built from the GitHub hooks reference (documented, not observed; said so in its `.meta.json`) | `hooks/pan-cost-logger.js`, `hooks/pan-trace-logger.js`, `tests/fixtures/hooks/subagent-stop-copilot.json` (+ `.meta.json`), tests | a camelCase payload yields the agent type and no parent-slice tokens; the Claude fixtures are unchanged |
|
|
47
|
+
|
|
48
|
+
### Close-out
|
|
49
|
+
|
|
50
|
+
| ID | Pri | Size | Pts | Title | Files | Gate / verify |
|
|
51
|
+
|---|---|---|---|---|---|---|
|
|
52
|
+
| EL-13 | P6 | S | 2 | **Docs and decision record.** HOOKS, CLI-REFERENCE, USER-GUIDE (evidence section; the `error_pattern_learning` row), ARCHITECTURE; ADR-0049; CHANGELOG `[Unreleased]`; statuses in the investigation write-ups and index and in market items M3/M11/M12/M16/M17/M18 | `docs/…`, `CHANGELOG.md`, `docs/specs/investigations/…`, `docs/specs/market-ideas-2026-09.md` | doc-lint, link check, the no-counts rule |
|
|
53
|
+
| G-1 | — | S | 2 | **Full gate.** CLAUDE.md counts refresh; `npm run test:all`; `node scripts/test-surface.cjs --check`; coverage gate; release-check; harness tier 0; a five-runtime install into `d:\pantesting` and a smoke of the new verbs on the installed engine; commit on the branch (no push) | — | all green, and the output quoted in the final report |
|
|
54
|
+
|
|
55
|
+
**Total: 45 points** (evidence loop 35, queue items 6, close-out 4).
|
|
56
|
+
|
|
57
|
+
## Session grouping
|
|
58
|
+
|
|
59
|
+
| Session | Items | Pts | Theme | Exit criterion |
|
|
60
|
+
|---|---|---|---|---|
|
|
61
|
+
| **S1** | EL-1, EL-2, EL-3, EL-4, EL-5, EL-6, EL-7, EL-8 | 21 | Verdicts on the record: contract, judges, review chain, ledger, scope, workflows, contract field | a judge's verdict goes from agent text to ledger to `findings debt` in tests; the review chain merges reviewer findings; suite green |
|
|
62
|
+
| **S2** | EL-9, EL-10, EL-11, EL-12, Q-4, Q-1, Q-2, Q-3, EL-13, G-1 | 24 | Failures, learning and safe applies; the queue items; close-out | the hook records tool failures from a real-shaped transcript; learn shows them; apply → revert round-trips; harness tier 0 and release-check green; committed |
|
|
63
|
+
|
|
64
|
+
Ordering rationale: the P1 review-chain fixes (EL-3, EL-4) come immediately after the contract they need (EL-1, EL-2). Everything that consumes verdicts (EL-5 → EL-7) follows. S2 starts with the hook (EL-9), because learn (EL-10) and the harness (EL-12) read what it writes. Q-4 sits beside EL-9 because it edits the same loggers. The queue items come last among the builds because none of them blocks the loop.
|
|
65
|
+
|
|
66
|
+
## Deferred, with reasons and triggers
|
|
67
|
+
|
|
68
|
+
| Item | Why not now | Trigger |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `optimize verdict` (write-up rec. 2, part 2) | One apply run in 14 field projects; the apply records keep what it needs | `optimize stats` shows apply runs in ≥ 3 projects |
|
|
71
|
+
| M5 publication path | Needs the maintainer's decision on the hosting form (ADR first) | the decision |
|
|
72
|
+
| M6 OpenCode observers | Rule MI-022: do not ship a host integration nobody has seen run. The OpenCode CLI is installed here but not signed in, so the plugin cannot be exercised live | `opencode auth login` on this machine |
|
|
73
|
+
| M7 Antigravity variant | No `agy` CLI here; conformance only from docs | `agy` available |
|
|
74
|
+
| M9 turn caps on exec-waves | Blocked: the Workflow tool's `agent()` has no per-spawn turn cap | host adds one |
|
|
75
|
+
| Recording hardener/meta-reviewer findings | They already have a parsed format; the ledger covers the reviewer | a deep review whose findings need dispositions |
|
|
76
|
+
| Phantom completions from unnamed agents without transcripts (spec §1.1 side finding) | Separate trace-quality issue | spun off as its own task |
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
# Evidence loop — featureAI specification
|
|
2
|
+
|
|
3
|
+
| | |
|
|
4
|
+
|---|---|
|
|
5
|
+
| Status | BUILT `2026-09-28` on `feat/evidence-loop` — plan [evidence-loop-plan.md](evidence-loop-plan.md), both sessions executed |
|
|
6
|
+
| Branch | `feat/evidence-loop` |
|
|
7
|
+
| Inputs | [trace-failure-capture](investigations/features/trace-failure-capture.md) (ENHANCE P2), [optimize-apply-regression-gate](investigations/features/optimize-apply-regression-gate.md) (ENHANCE P3), [market-ideas queue](market-ideas-2026-09.md) M11, M12, M17 |
|
|
8
|
+
| Decision record | [ADR-0049](../decisions/ADR-0049-machine-verdicts-and-findings-ledger.md) |
|
|
9
|
+
| Runtimes | Verdicts, findings, dispositions, revert and the `contract` field work on all five runtimes. Tool-failure capture is Claude-only, because it needs per-agent transcripts. |
|
|
10
|
+
|
|
11
|
+
PAN's judging agents (verifier, plan checker, reviewer, design checker) already decide whether work passed. PAN keeps almost none of that evidence. Today:
|
|
12
|
+
|
|
13
|
+
- Verdicts are prose that each workflow re-parses in its own way.
|
|
14
|
+
- Findings disappear after the phase.
|
|
15
|
+
- Failures inside a subagent never reach the trace.
|
|
16
|
+
- `optimize apply` writes memory entries that every later agent reads, and they cannot be undone.
|
|
17
|
+
|
|
18
|
+
This feature makes the evidence explicit, durable and mechanical. There are four pieces:
|
|
19
|
+
|
|
20
|
+
1. A machine verdict contract that every judge emits.
|
|
21
|
+
2. An append-only findings ledger with recorded dispositions.
|
|
22
|
+
3. Failure capture in the trace hook.
|
|
23
|
+
4. A revertible optimizer apply.
|
|
24
|
+
|
|
25
|
+
The machine-readable outputs get a `contract` version so consumers can depend on them.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Phase 0 — Problem framing
|
|
30
|
+
|
|
31
|
+
### 0.1 Problem statement
|
|
32
|
+
|
|
33
|
+
PAN's improvement loop (`optimize trace` → `/pan:learn` → `optimize apply`) and its quality gates (plan check, review, verification, milestone audit) all run on evidence. At each point where evidence exists, it is either not recorded or recorded in a form nothing reads back:
|
|
34
|
+
|
|
35
|
+
- **Judges' verdicts live in prose.** Each workflow re-derives the outcome in its own way:
|
|
36
|
+
- exec-phase greps `status:` from verification frontmatter (`pan-wizard-core/workflows/exec-phase.md:544`).
|
|
37
|
+
- plan-phase matches the headings `## VERIFICATION PASSED` / `## ISSUES FOUND` (`plan-phase.md:449-462`).
|
|
38
|
+
- The review step pipes a `$REVIEW_OUTPUT` shell variable that nothing ever sets (`exec-phase.md:452`). A Task result is not a shell variable, so that trace event always counted "1 error" or never fired.
|
|
39
|
+
- **Findings are not kept.** The reviewer is read-only and its report is never written to disk. `/pan:review-deep` step 1 reads `.planning/phases/<N>/review.md` "written by exec-phase", but nothing writes it (`commands/pan/review-deep.md:41,63`). Even if it existed, `parseReviewFindings` wants `## Findings` bullets, while the reviewer emits `### Findings` tables. The reviewer half of every deep review has always merged as zero findings.
|
|
40
|
+
- **Findings have no disposition.** milestone-audit asks the model to reconstruct "tech debt, deferred items, warnings" from prose in each verification.md (`milestone-audit.md:76-80`). No record says a finding was deliberately deferred, dismissed or fixed, or why (market idea MI-031).
|
|
41
|
+
- **Failures inside subagents are invisible.** The trace hook writes one completion event per spawn, plus a redundancy heuristic (`hooks/pan-trace-logger.js:824,873`). It already reads the subagent's own transcript for tokens, but it never looks at the failed tool calls in it.
|
|
42
|
+
- **Optimizer applies cannot be undone.** `applyReportRecommendations` appends to memory files that every later agent reads. It logs only counts and types (`pan-wizard-core/bin/lib/optimize.cjs:752-762`), and running it twice on the same report appends everything twice.
|
|
43
|
+
- **Scope creep has no class.** No check compares what a phase changed against what its plans declared (MI-030).
|
|
44
|
+
|
|
45
|
+
**Why now:** the Growing Harness result (arXiv:2609.26760) says a loop improves from feedback only when the runtime records each failure and ties it to where it happened. PAN has that runtime hook already (the per-agent transcripts the cost ledger proved in 3.29.0). The market scan found two peers that converged on the verification side: Spec Kit's classes include "unrequested", and BMAD's review triage records a disposition with a reason.
|
|
46
|
+
|
|
47
|
+
### 0.2 Scope
|
|
48
|
+
|
|
49
|
+
| In scope | Out of scope (with reason) |
|
|
50
|
+
|---|---|
|
|
51
|
+
| `pan-verdict` block: contract, parser, validator, agent-by-agent mapping, verification.md frontmatter adapter | Rewriting the judges' prose reports (the block is appended, the prose stays for people) |
|
|
52
|
+
| Findings ledger `.planning/findings.jsonl`, `findings record/list/dispose/debt`, MCP resource `pan://findings` | A findings UI or HTML report (the phase HTML report can read the ledger later) |
|
|
53
|
+
| Workflows record verdicts on the critical path and dispose findings where they continue past them; milestone-audit reads `findings debt` | Recording findings from `/pan:review-deep`'s hardener and meta-reviewer (they have a parsed format already; follow-up) |
|
|
54
|
+
| M11: `verify scope <phase>` (mechanical candidate list), verifier `unrequested:` frontmatter, reviewer lens | Blocking a phase on unrequested work (it is a finding to dispose, not a gate) |
|
|
55
|
+
| Trace hook: `error/tool_error` events and `tool_calls`/`tool_errors` on completions, from the agent's own transcript; redaction; off switch | Capture on Codex/Copilot (payload and transcript shape unverified), Gemini (no subagent-stop event), OpenCode (no hooks: market item M6) |
|
|
56
|
+
| `optimize learn` reads the new signal; `--sessions <n>` pools sessions | `optimize verdict` (the before/after regression verdict): deferred with a trigger, see §3.8 |
|
|
57
|
+
| Revertible `optimize apply` (apply ids, action records, re-apply guard) and `optimize revert` | Automatic revert (revert stays a user decision) |
|
|
58
|
+
| M17: `contract: "1.0"` on `state`, `state json`, `progress` JSON and the resources wrapping them | Versioning every JSON output PAN has |
|
|
59
|
+
| Review chain defects found on the way: persist `review.md`, fix review-deep's path and parser, make exec-phase `--deep-review` real | Redesigning review-deep's severity ladder |
|
|
60
|
+
|
|
61
|
+
### 0.3 Success criteria
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
SC-1 A judging agent's pan-verdict block round-trips: agent text → parseVerdictBlock → ledger rows → findings list,
|
|
65
|
+
for the block examples shipped in each judging agent AND in each runtime's converted copy of it (5 runtimes).
|
|
66
|
+
SC-2 findings record is idempotent per artifact (same content twice → one verdict), numbers attempts per (agent, phase),
|
|
67
|
+
auto-fixes a re-verified agent's unreported findings (except human/unrequested), and reopens a regressed fix.
|
|
68
|
+
SC-3 findings dispose refuses deferred/dismissed/decision without --reason (exit 1); findings debt returns deferred
|
|
69
|
+
findings with reasons and lists undisposed open ones, filtered by milestone.
|
|
70
|
+
SC-4 The trace hook, given a Claude SubagentStop payload whose agent transcript holds failing tool results (fixture built
|
|
71
|
+
from a real emitted transcript's record shape), writes error/tool_error events with tool, class, exit code and a
|
|
72
|
+
redacted message; the same test fails against the pre-change hook (revert-proven).
|
|
73
|
+
SC-5 No capture from a parent-transcript slice, none when execution.error_pattern_learning is false, none outside a PAN tree.
|
|
74
|
+
SC-6 optimize apply records an apply_id with per-action records; applying the same report twice appends nothing the
|
|
75
|
+
second time; optimize revert restores a memory_append byte-for-byte (LF and CRLF files), refuses a hand-edited
|
|
76
|
+
file, and refuses out-of-order reverts on the same file.
|
|
77
|
+
SC-7 optimize learn reports tool_error_patterns and verdict_stats; --sessions <n> pools the last n sessions.
|
|
78
|
+
SC-8 state/state json/progress JSON carry contract "1.0"; the pan://state and pan://progress resources return it.
|
|
79
|
+
SC-9 review.md is written by exec-phase and parsed by review-deep (reviewer findings no longer merge as zero);
|
|
80
|
+
exec-phase --deep-review runs the deep review.
|
|
81
|
+
SC-10 Installs into all five runtimes carry the new agents, workflows and references intact (fixture installs);
|
|
82
|
+
the tier-0 harness scenario runs the loop against a deployed install; full suite, release-check and harness tier 0 green.
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 0.4 User stories
|
|
86
|
+
|
|
87
|
+
- As a PAN user finishing a milestone, I want the audit to list every finding we chose to defer, with the reason given at the time, so that tech debt comes from a record and not from the model re-reading prose.
|
|
88
|
+
- As a PAN user in a gap-closure loop, I want each re-verification to mark the previous gaps it no longer reports as fixed, and to count the attempt, so that I can see what the fix round actually resolved.
|
|
89
|
+
- As a PAN user running `/pan:learn`, I want the analysis to show which tool calls keep failing, and in which agents, across sessions. Then the optimizer writes memory from a failure that recurs, not from a guess.
|
|
90
|
+
- As a PAN user who ran `/pan:learn --apply`, I want to undo one apply exactly, without hand-editing memory files, if agents behave worse afterwards.
|
|
91
|
+
- As an MCP client author, I want `contract` on PAN's state and findings JSON, so that I can pin the shape I consume.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Phase 1 — Internal reconnaissance
|
|
96
|
+
|
|
97
|
+
### 1.1 Measured premise (re-measured `2026-09-28`, as the digest asked)
|
|
98
|
+
|
|
99
|
+
The measurements were read-only and aggregate only; no project content was copied.
|
|
100
|
+
|
|
101
|
+
Reproduce as follows:
|
|
102
|
+
- Trace files: walk `find /d -maxdepth 7 -type d -name traces -path "*/.planning/optimization/*" -not -path "/d/pantesting/*/*"` and group each `trace.jsonl` line by `type/category`.
|
|
103
|
+
- Transcripts: walk `~/.claude/projects/*/<session>/subagents/**/agent-*.jsonl` and count `tool_result` blocks with `is_error: true`.
|
|
104
|
+
|
|
105
|
+
| Measure | Field projects (14) | PAN experiment trees (44) |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| Trace events | 3,968 | 740 |
|
|
108
|
+
| `decision/agent_completion` (hook) | 3,904 (98.4%) | 334 |
|
|
109
|
+
| Prose-logged decisions (plan_verified, verification_passed, phase_complete, plans_created …) | 64 | 322 |
|
|
110
|
+
| `error/*`, `gap/*`, `correction/*` events | **0** | 30 errors, 6 gaps, 0 corrections |
|
|
111
|
+
| Projects that ran `optimize learn` / `optimize apply` | 3 / 1 (one apply run ever) | 0 / 0 |
|
|
112
|
+
| Field trees whose trace files are tracked by git | 2 of the 4 git-backed trees checked | — |
|
|
113
|
+
|
|
114
|
+
| Subagent transcripts on this machine | Field | PAN development |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| Transcripts | 1,969 | 58 |
|
|
117
|
+
| Transcripts with ≥ 1 failed tool call | 463 (23.5%) | 16 |
|
|
118
|
+
| Failed tool results | 869 (max 18 in one spawn) | 28 |
|
|
119
|
+
| Classes of failure | exit code 597 · other 108 · not found 84 · bad tool input 46 · permission denied 16 · user rejected 11 · network 7 | exit code 20 · permission 5 · not found 2 · network 1 |
|
|
120
|
+
| Tools | Bash 708 · Read 68 · Grep 30 · Edit 18 · WebFetch 14 · PowerShell 11 · Write 8 · other 12 | Bash 25 · Read 2 · WebFetch 1 |
|
|
121
|
+
|
|
122
|
+
**What this changes in the write-up's premise.** The write-up says agents never call `optimize trace log`. They do, on the success branches, roughly once per phase: 64 field events. Part of the earlier silence was the discard defect fixed in 3.29.0 (`optimize.cjs:189-199`: events were dropped when no session was active). What is true, and what this design fixes:
|
|
123
|
+
|
|
124
|
+
1. No error branch has ever logged in the field.
|
|
125
|
+
2. The verdict events carry no findings.
|
|
126
|
+
3. Nothing records the failures inside subagents. The transcripts hold about 0.44 failed tool calls per spawn, and the trace holds zero.
|
|
127
|
+
|
|
128
|
+
The optimizer loop is barely used (one apply run in the field). That shapes §3.8: the design fixes the signal and makes apply safe, and it defers the regression verdict until use exists.
|
|
129
|
+
|
|
130
|
+
**Side finding (follow-up, not built here).** 181 recent completion events name an `agent_id` with no agent type, and no transcript for them exists anywhere on disk. They look like host-internal helper agents and add zero-token noise to agent stats. This is tracked as a separate task.
|
|
131
|
+
|
|
132
|
+
### 1.2 What exists (SOURCE unless marked)
|
|
133
|
+
|
|
134
|
+
| Piece | Where | Relevance |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| Per-agent transcript resolution | `hooks/pan-trace-logger.js:566` `resolveAgentTranscript` (mirrored in `pan-cost-logger.js`) | Capture reads the same file; only when `token_source` is `agent-transcript` |
|
|
137
|
+
| Cursor-sliced transcript reading | `pan-trace-logger.js:624` `readUsageFromTranscript(path, sessionId, sinceLine)` | Failure extraction must read the same slice (resumed agents grow one file) |
|
|
138
|
+
| Batch dedup on re-fire | `pan-trace-logger.js:901` `appendTraceEvents` + `isDuplicateCompletion` | Failure events ride in the completion's batch, so a re-fire drops them too |
|
|
139
|
+
| Event-name guard | `pan-trace-logger.js:716` returns `[]` unless `hook_event_name` is absent or exactly `SubagentStop` | Harmless on Copilot: its camelCase payloads carry no event name (hooks reference). What does break there is the field names (§1.3) |
|
|
140
|
+
| Trace append with auto-session | `optimize.cjs:200` `logTraceEvent` | `findings record` logs verdict events through it |
|
|
141
|
+
| Analysis | `optimize.cjs:462` `analyzeEvents` (frequency by category; `reviewer_correction` counted by category) | Gains tool-error patterns and verdict stats; must keep counting legacy categories |
|
|
142
|
+
| Apply | `optimize.cjs:675` `applyReportRecommendations` (memory create, memory_append, note, planning_note; containment check) | Gains apply ids, action records, re-apply guard |
|
|
143
|
+
| Severity ladder | `review-deep.cjs:27` `SEVERITIES = critical, high, medium, low, info` | Reused as the verdict severity vocabulary (one ladder in PAN) |
|
|
144
|
+
| Mechanical verdict cross-check | `verify.cjs:471` `reconcilePhase` | Pattern for `verify scope`: derive signals in code, let the agent judge |
|
|
145
|
+
| Plan scope | plan frontmatter `files_modified` (`templates/phase-prompt.md:21`; required by `frontmatter.cjs:352`); summary `key-files` | Declared vs reported scope for M11 |
|
|
146
|
+
| Commit convention | `{type}({phase}-{plan}): …` (`agents/pan-executor.md:331`) | `verify scope` finds the phase's commits by subject |
|
|
147
|
+
| Reserved config key | `execution.error_pattern_learning` (`config.cjs:81`; documented as "Reserved — written by the defaults but not read", `docs/USER-GUIDE.md:579`) | Becomes the capture off switch; no new key |
|
|
148
|
+
| Hook payload fixtures with provenance | `tests/fixtures/hooks/*.json` + `.meta.json` | New fixture follows the same rule: structure from a real emission, synthetic values |
|
|
149
|
+
| Attempt numbers | `resolve-model --attempt` (`core.cjs:842-946`); the ledger never records them because the hook cannot see them (M8 status) | The findings ledger derives attempts from its own history instead |
|
|
150
|
+
|
|
151
|
+
Real transcript shape of a failed tool call (read `2026-09-28` from a PAN development subagent transcript; structure only):
|
|
152
|
+
- A `type: "user"` record carries `message.content[] = {type: "tool_result", tool_use_id, is_error: true, content: <string>}`, plus top-level `toolUseResult` (string, prefixed `Error: `) and `sourceToolAssistantUUID`.
|
|
153
|
+
- The tool name comes from the matching `{type: "tool_use", id, name, input}` block in the preceding assistant record.
|
|
154
|
+
- For Bash the first content line is `Exit code <n>`, and the useful line follows it.
|
|
155
|
+
- Beside each `agent-<id>.jsonl` the host writes `agent-<id>.meta.json` with `agentType`, `description` and `toolUseId`. This is a fallback for the agent name when the payload has no `agent_type`.
|
|
156
|
+
|
|
157
|
+
### 1.3 Runtime compatibility
|
|
158
|
+
|
|
159
|
+
| Runtime | Judges emit block / workflows record | Hook capture | Why |
|
|
160
|
+
|---|---|---|---|
|
|
161
|
+
| Claude | yes | yes | per-agent transcripts proven by the cost ledger (3.29.0) |
|
|
162
|
+
| Codex | yes | no | `SubagentStop` registered, per-agent transcript layout unverified; the hook finds no agent file and records no failures |
|
|
163
|
+
| Gemini | yes | no | no subagent-completion event (`HOOK_EVENT_MAP.gemini.subagentStop = null`) |
|
|
164
|
+
| OpenCode | yes | no | no hooks registered (`HOOK_EVENT_MAP.opencode = null`; observers are market item M6) |
|
|
165
|
+
| Copilot | yes | no | `subagentStop` registered. Copilot's hooks reference (docs.github.com, read `2026-09-28`, documented only) gives the camelCase payload `sessionId`, `transcriptPath`, `agentId`, `agentType`, `agentName` and `response` (the subagent's final text), with no `hook_event_name`, and a single session transcript. There is no per-subagent file. PAN's loggers read only the snake_case names, so on Copilot they see no agent and no transcript (plan item Q-4) |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Phase 2 — Competitive analysis
|
|
170
|
+
|
|
171
|
+
Sources were read on `2026-09-21` for the market ledger and on `2026-09-28` for the digest.
|
|
172
|
+
|
|
173
|
+
| Peer / source | What it does | What PAN takes | What PAN does not take |
|
|
174
|
+
|---|---|---|---|
|
|
175
|
+
| Growing Harness (arXiv:2609.26760 v2) | The runtime records execution traces; failures are localised to the function they passed through; changes are kept only if a held-out gate does not drop, otherwise rolled back | Runtime-recorded, localised failures (`command, phase, agent, tool`); every change revertible | The automatic held-out gate: a PAN project has no fixed task set, and one apply run in the field does not justify the verb yet (§3.8) |
|
|
176
|
+
| Spec Kit `/speckit.converge` (MI-030) | Classes missing / partial / contradicts / unrequested; "completion claims are not evidence" | The four classes, verbatim, as the verification side of the class vocabulary | Its whole-spec convergence pass |
|
|
177
|
+
| BMAD review triage (MI-031) | Every finding ends as patch / defer / dismiss-with-reason / decision-needed, never silently | Dispositions `fixed / deferred / dismissed / decision`, reason required for the last three | Human-only triage (PAN's workflows dispose where they continue past a finding) |
|
|
178
|
+
| gsd-core (MI-029) | Escalates the model tier on failure, capped | Nothing new: PAN has it (M8). The ledger now supplies the attempt number the hook could not see | — |
|
|
179
|
+
| Claude Code host | Per-agent transcripts, `agent-<id>.meta.json`, SubagentStop payload | Read-only use of both | Writing anything into the host's transcript tree |
|
|
180
|
+
|
|
181
|
+
Where PAN is different: the evidence stays in the project's own `.planning/`, in files with a `contract` version. Judges emit it; code records it; nothing leaves the machine (MI-056: no usage telemetry).
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Phase 3 — Design
|
|
186
|
+
|
|
187
|
+
### 3.1 Architecture
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
judging agent ──returns text──▶ orchestrator (workflow)
|
|
191
|
+
(plan-checker, reviewer, │ writes the text verbatim to the phase dir
|
|
192
|
+
design-checker: pan-verdict │ NN-plan-check.md · NN-review.md · NN-design-check.md
|
|
193
|
+
block; verifier: frontmatter) ▼ (verifier writes NN-verification.md itself)
|
|
194
|
+
pan-tools findings record --phase N --file F --raw
|
|
195
|
+
│ parse (verdict.cjs) → ledger rows (findings.cjs)
|
|
196
|
+
│ → trace event verdict_passed / verdict_failed / verdict_retry
|
|
197
|
+
▼
|
|
198
|
+
prints the native verdict → the workflow branches on it
|
|
199
|
+
│ continuing past findings? → findings dispose … --reason
|
|
200
|
+
▼
|
|
201
|
+
milestone-audit ◀── findings debt ── .planning/findings.jsonl ──▶ findings list · pan://findings
|
|
202
|
+
|
|
203
|
+
subagent stops ─▶ pan-trace-logger (Claude) ── own transcript slice ─▶ error/tool_error events
|
|
204
|
+
+ tool_calls/tool_errors on the completion
|
|
205
|
+
optimize learn [--sessions n] ─▶ tool_error_patterns · verdict_stats ─▶ pan-optimizer report
|
|
206
|
+
optimize apply ─▶ applied.jsonl {apply_id, actions[]} ──▶ optimize revert <apply_id>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 3.2 Decisions
|
|
210
|
+
|
|
211
|
+
**D1 — Verdict capture is a verb the workflow needs. The hook does not parse verdicts.** This answers the write-up's open question: *should agents emit a machine verdict line that the hook reads?* Agents do emit one, but a verb reads it, not the hook:
|
|
212
|
+
- The verb works on all five runtimes; per-agent transcripts exist on one.
|
|
213
|
+
- It sits on the critical path. The workflow branches on the verb's output, which replaces the grep and heading matches it does today. The call is the step that gives the answer, not a side instruction the model can skip.
|
|
214
|
+
- There is one writer per verdict, so no two-path dedup ambiguity arises.
|
|
215
|
+
|
|
216
|
+
The hook keeps what only it can see: the failed tool calls inside the subagent.
|
|
217
|
+
*Rejected:* hook-parsed verdicts (Claude-only, and a second writer beside the workflow); keeping prose `optimize trace log` calls (proven not to fire on error branches).
|
|
218
|
+
|
|
219
|
+
**D2 — One block, for the judges that return text; the verifier keeps its frontmatter.** The plan checker, reviewer and design checker append a fenced `pan-verdict` JSON block to their return. The verifier already writes a machine contract, the verification.md frontmatter that `/pan:plan-phase --gaps` consumes. `findings record` reads that frontmatter through an adapter instead of asking the verifier to repeat it in a second block that could disagree with it. M11 extends the frontmatter with `unrequested:`.
|
|
220
|
+
*Rejected:* a block in verification.md too (two sources of truth in one file); parsing each judge's prose (the review-deep table/bullet mismatch shows how that fails).
|
|
221
|
+
|
|
222
|
+
**D3 — Persist every judge's report in the phase directory.** The reviewer, plan checker and design checker stay read-only, as their role requires. The orchestrator writes the returned text verbatim to `{PHASE_DIR}/{PADDED}-review.md`, `-plan-check.md` or `-design-check.md` with the Write tool. That fixes review-deep's dangling input and makes each verdict an artifact that can be recorded. None of these names match `isPlanFile`, `isSummaryFile` or `isVerificationFile`.
|
|
223
|
+
|
|
224
|
+
**D4 — An append-only project ledger, folded on read.** `.planning/findings.jsonl` holds `verdict`, `finding` and `disposition` rows. The ledger is never rewritten, so parallel writers and interrupted runs cannot lose an update. The same pattern is used by `metrics/tokens.jsonl` and `trace.jsonl`. One project file rather than one file per phase: phase numbers continue across milestones (`milestone-new.md:269`), and each row also records its milestone.
|
|
225
|
+
|
|
226
|
+
**D5 — Deterministic identity and idempotency.**
|
|
227
|
+
- `record_sig` is the hash of the EOL-normalised input artifact. Recording the same artifact twice is a no-op that returns the first verdict. This is why verify-phase and exec-phase may both record the same verification.md safely.
|
|
228
|
+
- A finding's `id` is a hash of (phase, agent, class, where, normalised summary). The same finding reported again keeps its id.
|
|
229
|
+
- `attempt` is 1 plus the number of distinct earlier verdicts by the same agent on the same phase.
|
|
230
|
+
|
|
231
|
+
**D6 — Status comes from the record, with two automatic rules.**
|
|
232
|
+
- **Auto-fix.** When agent A records a new verdict on phase P, every *open* finding from A's earlier verdicts on P that the new verdict does not report becomes `fixed`, with reason `not reported by A at attempt k`. This is how a gap-closure round closes gaps.
|
|
233
|
+
- **Reopen.** A `fixed` finding that a newer verdict reports again is open again (a regression).
|
|
234
|
+
- **Exemptions.** `human` and `unrequested` findings are never auto-fixed: a re-verification does not re-check them, so silence is not evidence. Deliberate dispositions (`deferred`, `dismissed`, `decision`) are never overridden by a later report.
|
|
235
|
+
- **Known limit.** A finding whose wording changes between attempts appears as fixed and re-opened under a new id. The open count stays right.
|
|
236
|
+
|
|
237
|
+
**D7 — Dispositions are explicit and need a reason.** `fixed`, `deferred`, `dismissed` and `decision` come from BMAD's patch/defer/dismiss/decision-needed. A reason is required for the last three; the verb refuses without one (exit 1). This is M12's "a dismissal without a reason fails the check", enforced at the write rather than in a template. Workflows dispose where they continue past a finding:
|
|
238
|
+
- warnings accepted at `PASS_WITH_WARNINGS` are deferred with that reason;
|
|
239
|
+
- "continue anyway" at `NEEDS_FIXES` is deferred with that reason;
|
|
240
|
+
- "force proceed" after three plan revisions is deferred with that reason.
|
|
241
|
+
|
|
242
|
+
**D8 — Failure capture reads only the subagent's own transcript slice.** Capture happens only when `token_source` is `agent-transcript`; the parent-slice fallback would book the session's failures to one spawn. It uses the same cursor slice as the token read, so a resumed agent is not counted twice. Rules:
|
|
243
|
+
- One `error/tool_error` event per distinct (tool, class, message signature) per spawn, carrying an occurrence `count`.
|
|
244
|
+
- At most 10 events per spawn; the rest are reflected in the completion's `tool_errors` total.
|
|
245
|
+
- A failure is data, not a verdict: TDD red runs and grep-no-match exit codes are expected. `optimize learn` weighs recurrence across spawns and sessions, never a single occurrence.
|
|
246
|
+
|
|
247
|
+
**D9 — Redaction is new, and mandatory.** The write-up assumed "the same rules the cost ledger uses". There are none: the ledger stores no text. Trace files are committed in some projects (§1.1), so the message is redacted before it is stored:
|
|
248
|
+
- key/value secrets (`token=…`, `Authorization: …`, `password: …`);
|
|
249
|
+
- known token prefixes (`sk-`, `ghp_`/`gho_`/`ghs_`, `xox[abp]-`, `AKIA…`, JWT `eyJ…`);
|
|
250
|
+
- any run of 32 or more base64/hex characters;
|
|
251
|
+
- URL query strings;
|
|
252
|
+
- the user's home directory, which becomes `~`.
|
|
253
|
+
|
|
254
|
+
The message is also capped at 160 characters. `execution.error_pattern_learning: false`, a reserved key that finally gets its meaning, turns capture off.
|
|
255
|
+
|
|
256
|
+
**D10 — Apply records make revert exact and prevent double applies.**
|
|
257
|
+
- Each `optimize apply` gets an `apply_id`. Every action is recorded with its path, its kind (`created`/`appended`), the exact appended text, and the hash of the EOL-normalised file after the write.
|
|
258
|
+
- An action whose signature is already applied (and not reverted) is skipped with `already applied in <apply_id>`.
|
|
259
|
+
- `optimize revert <apply_id|--last>` deletes created files and truncates appended spans. It refuses:
|
|
260
|
+
- a file whose normalised hash no longer matches (edited since the apply);
|
|
261
|
+
- a file a *later* unreverted apply also touched (reverts are last-in, first-out per file).
|
|
262
|
+
- It preserves CRLF files byte-for-byte: it detects `\r\n`, works in LF, and writes back in the file's own style.
|
|
263
|
+
- Legacy rows without an `apply_id` stay readable and are reported as not revertible.
|
|
264
|
+
|
|
265
|
+
**D11 — `contract` is a version string with an additive rule.** `"1.0"` on the verdict block, on the `findings` outputs and on the M17 state/progress JSON. Rules:
|
|
266
|
+
- Fields may be added within a major version and are never renamed or removed.
|
|
267
|
+
- Readers accept any `1.x` and ignore unknown fields.
|
|
268
|
+
- An unknown major is refused.
|
|
269
|
+
|
|
270
|
+
**D12 — `verify scope` is the mechanical half of M11.** It returns the phase's changed files that its plans did not declare:
|
|
271
|
+
- **Changed** = files touched by the phase's plan commits (subject `{type}({phase}-{plan}):`, no merges, bounded history), plus the summaries' `key-files`.
|
|
272
|
+
- **Declared** = the union of the plans' `files_modified`.
|
|
273
|
+
|
|
274
|
+
From the difference it:
|
|
275
|
+
- excludes the planning tree and lockfiles;
|
|
276
|
+
- tags tests that match a declared file's stem with `hint: test_for_declared`, so the verifier can accept supporting work quickly.
|
|
277
|
+
|
|
278
|
+
The verifier judges the candidates and records the real ones as `unrequested:`. The reviewer gets the same lens for behaviour.
|
|
279
|
+
|
|
280
|
+
### 3.3 Contract: the `pan-verdict` block (`contract "1.0"`)
|
|
281
|
+
|
|
282
|
+
The judge appends it as the last element of its return:
|
|
283
|
+
|
|
284
|
+
````markdown
|
|
285
|
+
```pan-verdict
|
|
286
|
+
{"contract":"1.0","agent":"pan-reviewer","phase":"03","verdict":"NEEDS_FIXES","outcome":"fail",
|
|
287
|
+
"findings":[{"class":"defect","severity":"high","where":"src/utils/parser.ts:42","summary":"parse() drops the final token"}]}
|
|
288
|
+
```
|
|
289
|
+
````
|
|
290
|
+
|
|
291
|
+
| Field | Required | Values |
|
|
292
|
+
|---|---|---|
|
|
293
|
+
| `contract` | yes | `"1.x"` (a bare `1` is accepted and normalised) |
|
|
294
|
+
| `agent` | yes (or `--agent`) | the agent's name, `^[a-z][a-z0-9-]*$` |
|
|
295
|
+
| `outcome` | yes | `pass` · `fail` · `needs_human` |
|
|
296
|
+
| `verdict` | no | the agent's own word (`NEEDS_FIXES`, `issues_found`, `GAPS` …) |
|
|
297
|
+
| `phase` | no | informational; `--phase` wins, a mismatch is a warning |
|
|
298
|
+
| `findings[]` | no | at most 100; each `{class, severity, where?, summary}` |
|
|
299
|
+
| `findings[].class` | yes | `missing` · `partial` · `contradicts` · `unrequested` · `defect` · `risk` · `quality` · `human` |
|
|
300
|
+
| `findings[].severity` | yes | `critical` · `high` · `medium` · `low` · `info` (review-deep's ladder) |
|
|
301
|
+
| `findings[].where` | no | `path[:line]` or `plan-file#task`, 200 characters max |
|
|
302
|
+
| `findings[].summary` | yes | 300 characters max (longer is truncated with a warning) |
|
|
303
|
+
|
|
304
|
+
Parsing rules:
|
|
305
|
+
- The **last** fenced block whose info string is exactly `pan-verdict` wins. Backtick or tilde fences are accepted, and so is leading indentation: the host indents framed subagent results.
|
|
306
|
+
- Unknown class or severity values are recorded as `quality` / `info` and reported in `warnings[]`.
|
|
307
|
+
- If a known agent's `verdict` maps to a different outcome than the one given, `outcome_mismatch` is added to the warnings. The block's outcome is still recorded.
|
|
308
|
+
- A missing block, invalid JSON, an unsupported major or a missing required field → exit 1 with `{error, reason}`, so a workflow's `||` fallback runs.
|
|
309
|
+
|
|
310
|
+
Native verdict → outcome (`KNOWN_VERDICTS`):
|
|
311
|
+
|
|
312
|
+
| Agent | pass | fail | needs_human |
|
|
313
|
+
|---|---|---|---|
|
|
314
|
+
| pan-verifier | `passed` | `gaps_found` | `human_needed` |
|
|
315
|
+
| pan-plan-checker | `passed` | `issues_found` | — |
|
|
316
|
+
| pan-reviewer | `PASS`, `PASS_WITH_WARNINGS` | `NEEDS_FIXES` | — |
|
|
317
|
+
| pan-design-checker | `PASS` | `GAPS` | — |
|
|
318
|
+
|
|
319
|
+
Class guide, shipped in `references/verdict-contract.md`:
|
|
320
|
+
|
|
321
|
+
| Judge | Mapping |
|
|
322
|
+
|---|---|
|
|
323
|
+
| plan checker | requirement coverage → `missing`; task completeness, verification derivation, spec sufficiency, decision trace → `partial`; dependency correctness → `defect`; key links, test coverage, Nyquist → `missing`; scope sanity → `risk`; context compliance → `contradicts`; standards → `quality`. Blocker → `high`, warning → `medium`, info → `info` |
|
|
324
|
+
| reviewer | Convention → `quality`; Security → `risk`; Code Quality → `defect`; work no plan asked for → `unrequested`. ERROR → `high`, WARNING → `medium`, INFO → `info` |
|
|
325
|
+
| design checker | requirement coverage → `missing`; architecture conformance → `contradicts`; threat coverage → `risk`; scope discipline → `unrequested`; others → `partial`; every gap `high` unless the checker marks it a caveat (`medium`) |
|
|
326
|
+
|
|
327
|
+
**verification.md adapter** (used when the file has no block):
|
|
328
|
+
- `status` gives the verdict; the outcome comes from the table above.
|
|
329
|
+
- `gaps[]` → `missing` (failed) or `partial` (partial), `high` or `medium`. `where` is the first artifact path; `summary` is the truth plus the reason.
|
|
330
|
+
- `human_verification[]` → `human`, `info`.
|
|
331
|
+
- `unrequested[]` (new) → `unrequested`, `low`, where `path`, summary `what`.
|
|
332
|
+
|
|
333
|
+
### 3.4 Contract: the findings ledger (`.planning/findings.jsonl`, row `v: 1`)
|
|
334
|
+
|
|
335
|
+
```json
|
|
336
|
+
{"v":1,"kind":"verdict","ts":"…","verdict_id":"v_3f2a…","record_sig":"9c1e…","phase":"03","milestone":"v1.1","agent":"pan-verifier","verdict":"gaps_found","outcome":"fail","attempt":2,"source":".planning/phases/03-auth/03-verification.md","finding_ids":["f_81ab…"],"by_severity":{"high":1},"warnings":[]}
|
|
337
|
+
{"v":1,"kind":"finding","ts":"…","id":"f_81ab…","verdict_id":"v_3f2a…","phase":"03","milestone":"v1.1","agent":"pan-verifier","class":"missing","severity":"high","where":"src/auth/login.ts","summary":"login never checks the password — handler returns 200"}
|
|
338
|
+
{"v":1,"kind":"disposition","ts":"…","id":"f_5d0c…","disposition":"fixed","reason":"not reported by pan-verifier at attempt 2","auto":true,"verdict_id":"v_3f2a…"}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Rules:
|
|
342
|
+
- A finding row is written once per id. A verdict re-reporting an id lists it in `finding_ids`.
|
|
343
|
+
- Every recorded input produces exactly one `appendFileSync` of all its rows.
|
|
344
|
+
- `source` is a POSIX path relative to the project.
|
|
345
|
+
- **Status fold.** The latest disposition wins, except that `fixed` gives way to `open` when a newer verdict lists the id. With no disposition the finding is `open`.
|
|
346
|
+
|
|
347
|
+
### 3.5 Contract: trace events
|
|
348
|
+
|
|
349
|
+
The verdict events are written by `findings record` through `logTraceEvent`; the tool-error events by the hook, whose trace schema `v` moves from 4 to 5.
|
|
350
|
+
|
|
351
|
+
| Type/category | Written by | Context |
|
|
352
|
+
|---|---|---|
|
|
353
|
+
| `decision/verdict_passed` · `error/verdict_failed` · `decision/verdict_needs_human` | `findings record` (not on a duplicate) | `agent, phase, verdict, attempt, findings, by_severity, by_class, verdict_id`; impact `major` for a failure with a `critical`/`high` finding, else `minor` |
|
|
354
|
+
| `correction/verdict_retry` | `findings record`, when attempt ≥ 2 and the previous verdict failed | `agent, phase, attempt, previous_outcome, outcome, auto_fixed, reopened, verdict_id` |
|
|
355
|
+
| `error/tool_error` | trace hook, agent-transcript path only | `tool, error_class, exit_code, message, message_sig, count, command, agent_id`; impact `minor` |
|
|
356
|
+
| `decision/agent_completion` (existing) | trace hook | gains `tool_calls`, `tool_errors` (null unless read from the agent's own transcript) |
|
|
357
|
+
|
|
358
|
+
`error_class` is one of: `exit_code`, `permission_denied`, `not_found`, `tool_input`, `edit_precondition`, `user_rejected`, `network_or_timeout`, `other`. These are the classes measured in §1.1.
|
|
359
|
+
|
|
360
|
+
`analyzeEvents` counts the legacy categories alongside the new ones:
|
|
361
|
+
- `verification_passed`/`_gaps`/`_human_needed`, `plan_verified`, `plan_checker_issues`, `reviewer_correction` and `reviewer_warnings` are all counted, so old sessions still analyse.
|
|
362
|
+
- `summary.reviewer_corrections` counts the legacy category plus `verdict_failed` by `pan-reviewer`.
|
|
363
|
+
|
|
364
|
+
### 3.6 Contract: apply records (`optimization/applied.jsonl`)
|
|
365
|
+
|
|
366
|
+
```json
|
|
367
|
+
{"ts":"…","kind":"apply","apply_id":"apl_20260928_141501_7c2e","report":"sess_auto_20260928-report.md","applied_count":2,"skipped_count":1,"applied_types":["memory_append","note"],
|
|
368
|
+
"actions":[{"i":0,"type":"memory_append","path":".planning/memory/pan-executor.md","kind":"appended","text":"\n- run the suite with npm run test:all","sha256_after":"…","action_sig":"…"}]}
|
|
369
|
+
{"ts":"…","kind":"revert","apply_id":"apl_20260928_141501_7c2e","reverted":[0],"refused":[]}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### 3.7 CLI surface
|
|
373
|
+
|
|
374
|
+
| Command | Output (`--raw`) | Notes |
|
|
375
|
+
|---|---|---|
|
|
376
|
+
| `findings record --phase N (--file P \| --text T \| --stdin) [--agent A]` | JSON `{contract, recorded, duplicate, verdict_id, agent, verdict, outcome, attempt, findings, new, auto_fixed, reopened, warnings}` (`--raw`: the native verdict, else the outcome) | exit 1 on unparseable input; exit 0 whatever the outcome (a failed verdict is data) |
|
|
377
|
+
| `findings list [--phase N] [--agent A] [--status S] [--class C] [--milestone V]` | `{contract, findings[], counts}` | also the MCP resource `pan://findings` |
|
|
378
|
+
| `findings dispose (<id>… \| --phase N [--agent A] --open) --as D [--reason R]` | `{contract, disposed[], skipped[]}` | reason required for `deferred`/`dismissed`/`decision` |
|
|
379
|
+
| `findings debt [--milestone V]` | `{contract, milestone, phases[{phase, deferred[], open[]}], deferred_count, open_count}` | defaults to the current milestone |
|
|
380
|
+
| `verify scope <phase>` | `{phase, declared[], changed[], candidates[{path, hint}], excluded[]}` | read-only; git optional (falls back to summaries) |
|
|
381
|
+
| `optimize revert (<apply_id> \| --last)` | `{apply_id, reverted[], refused[{i, path, reason}], status}` | status `reverted` · `partial` · `nothing_to_revert` |
|
|
382
|
+
| `optimize learn --sessions <n>` | as today, plus `pooled_sessions[]` | pools the last n sessions by start time |
|
|
383
|
+
|
|
384
|
+
### 3.8 The regression verdict: deferred, with a trigger
|
|
385
|
+
|
|
386
|
+
`optimize verdict <apply_id>` would compare judge failure rates in the sessions before and after an apply. The data it needs will exist after this feature: verdicts in every session, and apply timestamps with ids. What does not exist is use: one apply run across 14 field projects. Building the verb now would add surface for no user. The apply records keep everything it needs, so it can be added later without a migration.
|
|
387
|
+
|
|
388
|
+
**Trigger:** `optimize stats` shows apply runs in three or more projects. **Answer to the write-up's owner questions:**
|
|
389
|
+
1. Yes, ship revert first, together with the signal.
|
|
390
|
+
2. The loop is worth fixing (signal and safety) but not worth growing (verdict) until it is used.
|
|
391
|
+
|
|
392
|
+
### 3.9 Files
|
|
393
|
+
|
|
394
|
+
| File | Change |
|
|
395
|
+
|---|---|
|
|
396
|
+
| `pan-wizard-core/bin/lib/verdict.cjs` (new) | pure: `parseVerdictBlock`, `validateVerdict`, `verdictFromVerificationFrontmatter`, `findingId`, `recordSig`, constants (`VERDICT_CONTRACT`, `FINDING_CLASSES`, `OUTCOMES`, `DISPOSITIONS`, `KNOWN_VERDICTS`, `AUTO_FIX_EXEMPT`) |
|
|
397
|
+
| `pan-wizard-core/bin/lib/findings.cjs` (new) | ledger IO and fold: `readLedger`, `foldFindings`, `recordVerdict`, `disposeFindings`, `listFindings`, `findingsDebt`, `cmdFindings*` |
|
|
398
|
+
| `pan-wizard-core/bin/pan-tools.cjs` | `case 'findings'` arm; `verify scope` sub-arm; `optimize revert` and `learn --sessions` |
|
|
399
|
+
| `pan-wizard-core/bin/lib/verify.cjs` | `scopePhase()` + `cmdVerifyScope` |
|
|
400
|
+
| `pan-wizard-core/bin/lib/optimize.cjs` | apply ids, action records, re-apply guard, `revertApply`, `cmdOptimizeRevert`; `analyzeEvents` tool-error patterns and verdict stats; pooled learn; stats count reverts |
|
|
401
|
+
| `pan-wizard-core/bin/lib/review-deep.cjs` | `parseReviewFindings` takes findings from a `pan-verdict` block when present |
|
|
402
|
+
| `pan-wizard-core/bin/lib/state.cjs`, `commands.cjs` | `contract: "1.0"` on `state` (load), `state json`, `progress` JSON |
|
|
403
|
+
| `pan-wizard-core/mcp/tool-registry.cjs` | resource `pan://findings` |
|
|
404
|
+
| `hooks/pan-trace-logger.js` | `readTranscriptSlice`, `extractToolFailures`, `classifyToolError`, `redactErrorText`, `errorCaptureEnabled`; completion gains `tool_calls`/`tool_errors`; `SCHEMA_V` 5; agent name falls back to `agent-<id>.meta.json` |
|
|
405
|
+
| `agents/pan-plan-checker.md`, `pan-reviewer.md`, `pan-design-checker.md` | the `pan-verdict` block in their return contracts; the reviewer's unrequested lens |
|
|
406
|
+
| `agents/pan-verifier.md`, `templates/verification-report.md` | `unrequested:` frontmatter, a scope step that runs `verify scope` |
|
|
407
|
+
| `pan-wizard-core/references/verdict-contract.md` (new) | the contract, the class guide, examples; loaded by the judges |
|
|
408
|
+
| `workflows/exec-phase.md` | persist review.md; `findings record` for review and verification (grep kept as the fallback); dispositions on continue; `--deep-review` step; drop the `$REVIEW_OUTPUT` and verdict trace-log blocks |
|
|
409
|
+
| `workflows/plan-phase.md` | persist plan-check.md; record; branch on the verb; dispose at force-proceed; drop the two checker trace-log blocks |
|
|
410
|
+
| `workflows/verify-phase.md` | record at return; drop the two trace-log blocks |
|
|
411
|
+
| `workflows/milestone-audit.md` | tech debt and undisposed findings from `findings debt` |
|
|
412
|
+
| `commands/pan/design-phase.md` | persist design-check.md; record |
|
|
413
|
+
| `commands/pan/review-deep.md` | reviewer path `{phase_dir}/{padded}-review.md`; exec-phase writes it (now true) |
|
|
414
|
+
| `commands/pan/exec-phase.md`, `optimize.md`, `learn.md`; `workflows/optimize.md`, `learn.md`; `agents/pan-optimizer.md` | document record/dispose, revert, `--sessions`, the new analysis fields |
|
|
415
|
+
| `harness/scenarios/evidence-loop.json` (new, tier 0) + `harness/scripts/evidence-loop.cjs` | the loop against a deployed install, model-free |
|
|
416
|
+
| `harness/scenarios/tool-error-capture.json` (new, tier 1) | a model run on the `uat-with-failure` seed; asserts a captured `tool_error` (paid, `--max-usd`) |
|
|
417
|
+
| Tests | see §4.3 |
|
|
418
|
+
| Docs | `docs/HOOKS.md`, `CLI-REFERENCE.md`, `USER-GUIDE.md` (evidence section; the `error_pattern_learning` row), `ARCHITECTURE.md` (ledger), `CHANGELOG.md`, ADR-0049; the two investigation write-ups and M11/M12/M17 marked BUILT |
|
|
419
|
+
|
|
420
|
+
Installer and manifest: no installer code changes. The new reference, agents and workflows ship through the existing copy steps and appear in `pan-file-manifest.json` like any core file. The new modules ship under `pan-wizard-core/bin/lib/`. Fixture installs prove each runtime carries them intact.
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## Phase 4 — Specification output
|
|
425
|
+
|
|
426
|
+
### 4.1 Implementation steps (dependency order)
|
|
427
|
+
|
|
428
|
+
1. `verdict.cjs` and its tests, which pin the contract before anything consumes it.
|
|
429
|
+
2. `findings.cjs` + dispatcher arm + `pan://findings` + tests; regenerate `module-surface.json` and `surface.json`.
|
|
430
|
+
3. `verify scope` + tests.
|
|
431
|
+
4. Agents, reference and template (the block, the class guide, `unrequested:`) + per-runtime conversion tests.
|
|
432
|
+
5. Workflows and commands (record, persist, dispose, deep-review, milestone-audit) + drift tests.
|
|
433
|
+
6. `review-deep.cjs` block path + test.
|
|
434
|
+
7. Trace hook capture + fixture + revert-proof.
|
|
435
|
+
8. `optimize` analysis, pooled learn, apply records, revert + tests.
|
|
436
|
+
9. M17 `contract` + tests.
|
|
437
|
+
10. Harness scenarios, docs, ADR, CHANGELOG, counts; the full gate run.
|
|
438
|
+
|
|
439
|
+
### 4.2 Runtime matrix
|
|
440
|
+
|
|
441
|
+
| Runtime | Supported | Notes |
|
|
442
|
+
|---|---|---|
|
|
443
|
+
| Claude | ✅ | everything, including hook capture from per-agent transcripts |
|
|
444
|
+
| Codex | ✅ (no capture) | verbs, block, workflows; the hook finds no per-agent transcript and records completions only |
|
|
445
|
+
| Gemini | ✅ (no capture) | verbs, block, workflows; no subagent-completion event |
|
|
446
|
+
| OpenCode | ✅ (no capture) | verbs, block, workflows; no hooks until M6 |
|
|
447
|
+
| Copilot | ✅ (no capture) | verbs, block, workflows; payload unverified (§5) |
|
|
448
|
+
|
|
449
|
+
### 4.3 Tests required
|
|
450
|
+
|
|
451
|
+
| Area | Cases |
|
|
452
|
+
|---|---|
|
|
453
|
+
| `verdict.cjs` | last block wins; tilde fence and indented fence; pretty and one-line JSON; missing block, invalid JSON, contract 2.0, missing outcome (all errors); unknown class/severity (recorded + warning); `outcome_mismatch`; >100 findings; long summary truncated; `contract: 1` normalised; adapter: gaps failed/partial, human items, unrequested, status→outcome |
|
|
454
|
+
| `findings.cjs` | record then list; duplicate artifact (same record_sig) is a no-op; attempts 1→2; auto-fix of unreported findings; human/unrequested exempt; reopen of a regressed fix; deferred not overridden by a re-report; dispose each disposition; missing reason refused (exit 1); unknown id skipped; bulk `--open` by agent; debt by milestone with deferred + open; `--raw` prints the native verdict; not a PAN project → error; trace events written (verdict_failed, verdict_retry) and none on a duplicate |
|
|
455
|
+
| `verify scope` | declared vs changed from summaries; from git commits by subject; lockfile and planning-tree exclusion; test-for-declared hint; no git repo → summaries only; unknown phase → error |
|
|
456
|
+
| Agents / conversion | each judge's shipped block example parses; the same after conversion for all five runtimes; the verifier template carries `unrequested:`; the reference ships to every runtime |
|
|
457
|
+
| Workflows (drift) | exec-phase records review and verification, persists review.md, keeps the grep fallback, disposes on continue, runs deep review on `--deep-review`, has no `$REVIEW_OUTPUT`; plan-phase records and disposes at force-proceed; verify-phase records; milestone-audit reads `findings debt`; review-deep's reviewer path is the phase-dir form; no remaining verdict-category `optimize trace log` calls |
|
|
458
|
+
| `review-deep.cjs` | a reviewer report with a block merges its findings (fails on the current parser) |
|
|
459
|
+
| Trace hook | fixture from the real record shape: tool_error events with tool, class, exit code, redacted message; dedupe with count; cap at 10; completion `tool_calls`/`tool_errors`; parent-slice path records none; `error_pattern_learning: false` records none; non-PAN directory writes nothing; resumed agent (cursor) not double counted; redaction cases (token, bearer, AKIA, JWT, long hex, home dir, query string); meta.json agent-name fallback; revert-proof against the pre-change hook |
|
|
460
|
+
| `optimize` | apply writes apply_id and records; second apply of the same report appends nothing; revert of memory_append byte-for-byte (LF and CRLF); revert of a created memory file; refuse hand-edited; refuse out-of-order on the same file; `--last`; legacy rows reported not revertible; analysis tool_error_patterns (spawns, sessions) and verdict_stats; `--sessions 2` pools; legacy verdict categories still counted |
|
|
461
|
+
| M17 | `state` / `state json` / `progress` carry `contract: "1.0"`; the MCP resources return it |
|
|
462
|
+
| Harness | tier 0 `evidence-loop` green on a packed install; tier 1 `tool-error-capture` defined (runs with `--max-usd`) |
|
|
463
|
+
|
|
464
|
+
### 4.4 Documentation updates
|
|
465
|
+
|
|
466
|
+
- `docs/HOOKS.md`: capture, redaction, the off switch, the runtime limits.
|
|
467
|
+
- `docs/CLI-REFERENCE.md`: the `findings` verb, `verify scope`, `optimize revert`, `learn --sessions`, the contract rule.
|
|
468
|
+
- `docs/USER-GUIDE.md`: an evidence-loop section, and the `execution.error_pattern_learning` row, which is no longer "Reserved".
|
|
469
|
+
- `docs/ARCHITECTURE.md`: the ledger and verdict flow.
|
|
470
|
+
- ADR-0049, and CHANGELOG `[Unreleased]`.
|
|
471
|
+
- Status lines in the two investigation write-ups, the investigations index and the market-ideas queue.
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Phase 5 — Risk assessment
|
|
476
|
+
|
|
477
|
+
| Risk | Impact | Mitigation |
|
|
478
|
+
|---|---|---|
|
|
479
|
+
| A judge omits the block or emits invalid JSON | Medium: the verdict is not recorded | Exit 1 → each workflow keeps its current parse as the `\|\|` fallback, so control flow never depends on the new verb alone |
|
|
480
|
+
| Workflow prose changes regress the phase pipeline | High | Drift tests on every edited step; fallbacks kept; tier-0 harness on a deployed install; the tier-1/2 chain scenarios remain the behavioural check |
|
|
481
|
+
| Secrets in captured error text end up in committed traces | High | Mandatory redaction with tests, 160-character cap, off switch; nothing leaves `.planning/` |
|
|
482
|
+
| Noise: expected failures (TDD red, grep no match) read as problems | Medium | Class and count recorded; learn ranks by recurrence across spawns and sessions; the optimizer is told never to write memory from one occurrence |
|
|
483
|
+
| Auto-fix marks a reworded finding fixed | Low | Documented; open count stays correct; human/unrequested exempt; deliberate dispositions never overridden |
|
|
484
|
+
| Revert deletes user content | High | Hash check (EOL-tolerant) refuses any file changed since the apply; last-in, first-out per file; created files only deleted when unchanged |
|
|
485
|
+
| Hook slowdown at SubagentStop | Low | One extra read of the agent's own file, capture skipped on every other path |
|
|
486
|
+
| Copilot completions recorded as `unknown` with zero tokens (existing, not introduced). The documented camelCase payload names every field differently from what the loggers read; the event-name guard is not the cause, because camelCase payloads carry no event name | Medium | Plan item Q-4: accept the documented camelCase aliases in both loggers, with a fixture built from the reference; a live probe before any claim that Copilot rows are right. Tool-failure capture stays off on Copilot either way (no per-subagent transcript) |
|
|
487
|
+
| Ledger growth | Low | Rows are small (a few KB per phase); one file per project |
|
|
488
|
+
| Two writers append at once (parallel judges) | Low | One `appendFileSync` per record call; the fold tolerates any interleaving |
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## Answers to the write-ups' open questions
|
|
493
|
+
|
|
494
|
+
- *Keep or delete the workflow-prose `optimize trace log` calls the hook makes redundant?* Delete the verdict-path calls: `findings record` writes those events on every runtime. Keep the decisions only the orchestrator knows (memory primed, wave complete, phase complete, plans created, auto-mode bypasses).
|
|
495
|
+
- *Is the verdict match stable enough, or should the verifier and plan-checker emit a machine line?* Emit a machine block, read by a verb rather than by the hook (D1, D2).
|
|
496
|
+
- *Ship revert alone first?* Revert ships with the signal. The verdict verb waits for use (§3.8).
|
|
497
|
+
- *Is the optimize loop worth the investment?* Fixing the signal and making apply safe is worth it. Growing it is not, until it is used.
|