pan-wizard 3.36.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 +36 -48
- 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 +1 -2
- package/agents/pan-document_code.md +1 -2
- package/agents/pan-hardener.md +2 -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 +79 -488
- package/agents/pan-plan-checker.md +12 -2
- package/agents/pan-planner.md +10 -6
- package/agents/pan-previewer.md +1 -2
- package/agents/pan-project-researcher.md +70 -499
- package/agents/pan-release.md +1 -1
- package/agents/pan-reviewer.md +9 -3
- package/agents/pan-roadmapper.md +12 -7
- package/agents/pan-verifier.md +7 -2
- 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/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/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 +31 -2
- package/pan-wizard-core/bin/lib/constants.cjs +27 -1
- package/pan-wizard-core/bin/lib/core.cjs +22 -10
- package/pan-wizard-core/bin/lib/cost.cjs +14 -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/failure-class.cjs +81 -0
- package/pan-wizard-core/bin/lib/findings.cjs +34 -4
- package/pan-wizard-core/bin/lib/focus.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 +16 -5
- 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.cjs +48 -4
- package/pan-wizard-core/bin/lib/plan-lint.cjs +150 -1
- package/pan-wizard-core/bin/lib/preview.cjs +23 -4
- package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
- package/pan-wizard-core/bin/lib/research-lint.cjs +150 -3
- 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/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/uat.cjs +149 -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 +37 -1
- package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
- package/pan-wizard-core/bin/lib/verify.cjs +59 -4
- package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
- package/pan-wizard-core/bin/pan-tools.cjs +168 -27
- package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
- package/pan-wizard-core/references/continuation-format.md +3 -3
- package/pan-wizard-core/references/guardrails.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 +5 -1
- package/pan-wizard-core/templates/debug.md +1 -0
- package/pan-wizard-core/templates/discovery.md +2 -2
- package/pan-wizard-core/templates/requirements.md +9 -0
- 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 +36 -8
- 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 +31 -53
- 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 +86 -43
- 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/research-phase.md +118 -40
- package/pan-wizard-core/workflows/resume-project.md +18 -2
- package/pan-wizard-core/workflows/settings.md +21 -24
- 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 +2 -2
- package/scripts/build-agent-plugin.js +35 -15
- 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/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 +9 -2
- 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 -210
- package/pan-wizard-core/templates/research-project/features.md +0 -153
- package/pan-wizard-core/templates/research-project/pitfalls.md +0 -206
- package/pan-wizard-core/templates/research-project/stack.md +0 -126
- package/pan-wizard-core/templates/research-project/summary.md +0 -170
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
require-code-mention: true
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# ADR-0026: Self-Improvement Loop — Idea → External Build → Harvest → Promote → Ship
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
Accepted (shipped 2026-04-27 across waves W1-W4 as v3.7.0)
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
PAN Wizard v3.5+ shipped a complete intra-project learning loop: `pan-trace-logger` captures every agent spawn, `/pan:learn` invokes `pan-optimizer` to analyze the session, `/pan:optimize apply` writes findings to `.planning/memory/`. Each user project's PAN install learns about its own codebase over time.
|
|
13
|
+
|
|
14
|
+
What was missing: the **PAN tool itself** did not learn. Every release shipped frozen behavioral rules (`references/`, workflows, agent prose). Real-world session data — the gold mine of "what shortcuts AI agents take, where verification fails, which guardrails fire" — stayed trapped in user projects' `.planning/optimization/` directories. The next release of PAN had no idea what the previous release's sessions discovered.
|
|
15
|
+
|
|
16
|
+
The MEMORY.md note "Cross-Session Learning (PATTERNS.md auto-capture)" was deferred for exactly this reason — it needed a design spec. Spec was written 2026-04-27 (`docs/specs/self_improvement_loop_featureai.md`). This ADR records the decisions made implementing it.
|
|
17
|
+
|
|
18
|
+
## Decision
|
|
19
|
+
|
|
20
|
+
Ship a **cross-project meta-learning loop** as v3.7.0 across four additive waves. The loop:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
1. /pan:experiment new <slug> --idea idea.md → scaffold isolated project outside source repo
|
|
24
|
+
2. /pan:experiment run <slug> → spawn external AI session, observe
|
|
25
|
+
3. /pan:experiment harvest <slug> → copy telemetry back to <source>/experiments/<slug>/
|
|
26
|
+
4. /pan:learn --experiment <slug> → run pan-optimizer over harvested data
|
|
27
|
+
5. pan-tools learn promote --pattern <id> → write findings to pan-wizard-core/learnings/{universal,internal}/
|
|
28
|
+
6. ship as next release → patterns auto-load via workflow cross-references
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Architecture decisions recorded here
|
|
32
|
+
|
|
33
|
+
**1. Two-tier learnings layout (`universal/` ships, `internal/` does not).**
|
|
34
|
+
|
|
35
|
+
`pan-wizard-core/learnings/universal/` ships to all 5 runtime install dirs alongside `references/`. `pan-wizard-core/learnings/internal/` stays source-only. The installer (`bin/install.js`) explicitly strips `learnings/internal/` after the recursive copy. Rationale: PAN-development-specific patterns ("always commit individually because of the source repo's hooks") must NOT leak into user installs as universal advice. A negative test in `tests/scenarios/learnings-installed.test.cjs` enforces this.
|
|
36
|
+
|
|
37
|
+
**2. Manual promote gate (no auto-promote in v3.7).**
|
|
38
|
+
|
|
39
|
+
`pan-tools learn promote` requires explicit `--pattern <id> --scope <s> --topic <t>` flags. The human picks scope and topic. Auto-promote (rules-based confidence threshold) is deferred to v3.8+ once 10+ manual promotes inform the filter design. Risk of bad auto-promote: a single misclassified PAN-internal pattern shipping as universal advice would silently pollute every user install. Manual gate eliminates this for v3.7.
|
|
40
|
+
|
|
41
|
+
**3. Subprocess runner, not VSCode UI automation.**
|
|
42
|
+
|
|
43
|
+
`runner.cjs` uses Node's `spawnSync` to invoke external runtimes headlessly (`claude -p`, `codex exec`, `gemini -p`, `opencode <prompt>`). Initial design considered driving a separate VSCode window via Playwright (Session 33 added the infrastructure), but: (a) GUI dependency adds cross-platform display setup, (b) headless display drivers are flaky, (c) CLI subprocess is sufficient for autonomous runs. Playwright stays for testing PAN inside VSCode, not for the experiment runner. GitHub Copilot CLI is **opt-out** — no documented headless prompt mode known.
|
|
44
|
+
|
|
45
|
+
**4. Observation-only watchdog agent.**
|
|
46
|
+
|
|
47
|
+
`pan-experiment-runner` agent has tools `[Read, Bash, Glob, Grep]` only — explicitly NO `Edit` or `Write`. The agent watches the experiment's `.planning/run-state.json`, decides when stop conditions fire, and reports back. It does NOT inject prompts mid-flight or fix problems in the experiment. Cleaner failure semantics: if the external session gets stuck, the timeout/circuit-breaker fires; PAN doesn't try to "save" it. Every intervention path would be a new bug surface.
|
|
48
|
+
|
|
49
|
+
**5. Experiments live outside the source repo.**
|
|
50
|
+
|
|
51
|
+
`PAN_EXPERIMENTS_ROOT_DEFAULT` is `~/pan-experiments/` (configurable via `--root`). `experiment.cjs newExperiment` refuses to scaffold inside `PAN_SOURCE_ROOT`. Mirror of the existing installer guard — the experiment folder gets a fresh PAN install, and that install would conflict with the source repo's own files.
|
|
52
|
+
|
|
53
|
+
**6. spawnSync over async spawn.**
|
|
54
|
+
|
|
55
|
+
Initial implementation used `child_process.spawn` with a custom poll-loop using `Atomics.wait`. This blocked the main thread, preventing the child's `exit` event from firing (event loop starved). Switched to `spawnSync` which has native timeout support and exits cleanly across platforms. Trade-off: real-time progress streaming is impossible in synchronous mode — `onProgress` callback fires once after exit with the full captured stdout/stderr. Documented as W3-or-later work to migrate to async/Promise mode if real-time streaming becomes load-bearing.
|
|
56
|
+
|
|
57
|
+
**7. Harvest writes inside the source repo.**
|
|
58
|
+
|
|
59
|
+
`harvestExperiment` copies telemetry to `<source-repo>/experiments/<slug>/`. This is INSIDE the source repo intentionally — harvested data becomes part of the source's git history alongside the spec/ADR/code that drove the promote decision. The PAN_SOURCE_ROOT guard (which prohibits writing the experiment ITSELF inside source) does not apply to harvest — different operation, different rules. The `experiments/` directory is intentionally not gitignored; small harvests are committed; large raw traces (`optimization/traces/sess_*/trace.jsonl`) may be gitignored selectively in the future if size becomes an issue.
|
|
60
|
+
|
|
61
|
+
**8. Streaming progress deferred.**
|
|
62
|
+
|
|
63
|
+
Original spec called for real-time `onProgress` callback during `runExperiment`. Synchronous spawnSync semantics don't support real-time streams. For W2-W4, output is captured-and-emitted-once. Real-time streaming becomes a v3.7.x or v3.8 follow-up if the autonomous loop produces sessions long enough that progress visibility matters more than synchronous CLI shape.
|
|
64
|
+
|
|
65
|
+
### Explicit deferrals (documented, not shipped)
|
|
66
|
+
|
|
67
|
+
- **Auto-promote** (rules-based confidence threshold filter) — v3.8+
|
|
68
|
+
- **Cross-experiment aggregation** (promote a pattern based on N experiments instead of 1) — v3.8+
|
|
69
|
+
- **VSCode UI automation as runner path** — keep CLI; Playwright stays for tests only
|
|
70
|
+
- **Bidirectional control mid-experiment** — observation-only by design
|
|
71
|
+
- **GitHub Copilot CLI runner** — no headless prompt mode known; document limitation
|
|
72
|
+
- **Container-isolated experiments** — process isolation via separate folder is sufficient for v3.7
|
|
73
|
+
- **Real-time progress streaming** — captured-and-emitted-once is sufficient
|
|
74
|
+
- **Experiment replay from a specific phase** — needs idempotency design
|
|
75
|
+
- **Promoting from a parsed report file** — v3.7 takes pattern data inline via flags; report-parser is v3.7.x
|
|
76
|
+
|
|
77
|
+
## Consequences
|
|
78
|
+
|
|
79
|
+
### Positive
|
|
80
|
+
|
|
81
|
+
- **PAN ships smarter every release.** Findings from real builds become part of the next product version.
|
|
82
|
+
- **Two-tier delivery** keeps PAN-internal patterns out of user installs without manual judgment per file.
|
|
83
|
+
- **Zero regressions.** All v3.6.0 behavioral guardrails still work; v3.7.0 is purely additive.
|
|
84
|
+
- **Test coverage:** 2627 → 2670+ across waves, with negative tests on the universal/internal split (one of the highest-stakes invariants).
|
|
85
|
+
- **Existing infrastructure reused:** `optimize.cjs` analysis, `pan-optimizer` agent, `references/` delivery channel, `createScenarioRunner` for tests, `focus.cjs` budget+circuit-breaker pattern.
|
|
86
|
+
- **Manual promote gate** keeps the human in the loop for the highest-leverage step.
|
|
87
|
+
|
|
88
|
+
### Negative
|
|
89
|
+
|
|
90
|
+
- **Module count grew from 27 to 29.** Surface expansion. Mitigation: `experiment.cjs` and `runner.cjs` have clear single responsibilities; both are documented in `ARCHITECTURE.md`.
|
|
91
|
+
- **`spawnSync` is synchronous and blocks pan-tools.cjs during a real run.** Real-time progress visibility is degraded. Mitigation: `runner.runExperiment` is invoked manually by the user; nothing else is competing for the main thread during a deliberate experiment run.
|
|
92
|
+
- **Harvest data may grow unbounded.** A trace.jsonl from a large experiment can be MB-sized. v3.7 commits it whole; v3.8+ may add gitignore rules or compression.
|
|
93
|
+
- **Topic-file frontmatter format is bespoke** (not standard YAML). Reason: zero-runtime-deps constraint. The parser is a 30-line minimal implementation. If a topic file is hand-edited and breaks the format, `listPromotedPatterns` skips it silently. Mitigation: `learnings/README.md` documents that topic files are AI-managed.
|
|
94
|
+
- **Auto-promote deferred to v3.8.** Manual gate is friction. Rationale: bad auto-promotes ship to all users; better to be slow than wrong.
|
|
95
|
+
- **GitHub Copilot CLI is excluded from the runner path.** Documented limitation. Copilot users can still scaffold experiments and consume promoted learnings, just not drive the runner.
|
|
96
|
+
|
|
97
|
+
### Neutral / Tradeoffs considered
|
|
98
|
+
|
|
99
|
+
- **Why not use a YAML library?** Zero-deps constraint. The frontmatter parser is 30 lines; a YAML library would be the first runtime dep ever shipped by PAN.
|
|
100
|
+
- **Why a single-pattern per promote command?** Multi-pattern batch would couple unrelated decisions. Each pattern gets a deliberate human review.
|
|
101
|
+
- **Why ship the `pan-experiment-runner` agent in W2 instead of bundling agent + module in W4?** The agent is the natural orchestrator for the runner. Shipping them together keeps the user-facing surface coherent.
|
|
102
|
+
|
|
103
|
+
## Implementation Notes
|
|
104
|
+
|
|
105
|
+
### Files added (W1-W4 cumulative)
|
|
106
|
+
|
|
107
|
+
| File | Wave | Purpose |
|
|
108
|
+
|------|------|---------|
|
|
109
|
+
| `pan-wizard-core/bin/lib/experiment.cjs` | W1 (extended W3) | 28th core module |
|
|
110
|
+
| `pan-wizard-core/bin/lib/runner.cjs` | W2 | 29th core module |
|
|
111
|
+
| `pan-wizard-core/templates/idea.md` | W1 | 27th template |
|
|
112
|
+
| `pan-wizard-core/learnings/README.md` | W1 | tier explainer |
|
|
113
|
+
| `pan-wizard-core/learnings/{universal,internal}/.gitkeep` | W1 | dir placeholders |
|
|
114
|
+
| `commands/pan/experiment.md` | W1 (extended W2-W3) | 52nd command |
|
|
115
|
+
| `agents/pan-experiment-runner.md` | W2 | 21st agent |
|
|
116
|
+
| `tests/experiment.test.cjs` | W1 (extended W3) | 21 unit tests |
|
|
117
|
+
| `tests/runner.test.cjs` | W2 | 12 unit tests |
|
|
118
|
+
| `tests/learn-promote.test.cjs` | W4 | 13 unit tests |
|
|
119
|
+
| `tests/scenarios/experiment-lifecycle.test.cjs` | W3 | 6 scenario tests |
|
|
120
|
+
| `tests/scenarios/learnings-installed.test.cjs` | W4 | 15 scenario tests (3×5 runtimes) |
|
|
121
|
+
| `docs/decisions/ADR-0026-self-improvement-loop.md` | W4 | this ADR |
|
|
122
|
+
| `docs/specs/self_improvement_loop_featureai.md` | W1 (commit `6a96c21`) | spec |
|
|
123
|
+
|
|
124
|
+
### Files modified
|
|
125
|
+
|
|
126
|
+
- `pan-wizard-core/bin/lib/optimize.cjs` — added promote/list-promoted/unpromote
|
|
127
|
+
- `pan-wizard-core/bin/pan-tools.cjs` — registered experiment + learn promote subcommands
|
|
128
|
+
- `commands/pan/learn.md` — added `--experiment <slug>` flag docs
|
|
129
|
+
- `pan-wizard-core/workflows/{exec-phase,plan-phase,verify-phase,execute-plan}.md` — reference `learnings/universal/`
|
|
130
|
+
- `bin/install.js` — two-tier guard strips `learnings/internal/` from installs
|
|
131
|
+
- `package.json` — version bump to 3.7.0
|
|
132
|
+
- `CHANGELOG.md`, `docs/USER-GUIDE.md`, `docs/ARCHITECTURE.md`, `MEMORY.md` — documentation
|
|
133
|
+
|
|
134
|
+
### Cumulative deltas (v3.6.0 → v3.7.0)
|
|
135
|
+
|
|
136
|
+
- Tests: 2588 → ~2670+ (+82+)
|
|
137
|
+
- Core modules: 27 → 29 (+2)
|
|
138
|
+
- Agents: 20 → 21 (+1)
|
|
139
|
+
- Commands: 51 → 52 (+1)
|
|
140
|
+
- Templates: 26 → 27 (+1)
|
|
141
|
+
- New top-level dir under pan-wizard-core: `learnings/{universal,internal}/`
|
|
142
|
+
|
|
143
|
+
### Rollback plan
|
|
144
|
+
|
|
145
|
+
The layer is entirely additive. Rollback steps if telemetry reveals a regression:
|
|
146
|
+
|
|
147
|
+
- Remove `pan-wizard-core/bin/lib/{experiment,runner}.cjs` — dispatcher commands degrade to "command not found"
|
|
148
|
+
- Remove `agents/pan-experiment-runner.md` — agent unavailable; users fall back to manual experiment runs
|
|
149
|
+
- Remove `pan-wizard-core/learnings/` — no shipped patterns; workflow cross-references resolve to "directory not found" but workflows continue
|
|
150
|
+
- Remove the `learnings/internal/` strip from `bin/install.js` — restores pre-v3.7 install behavior
|
|
151
|
+
- Revert workflow cross-references — workflows function identically without the new line
|
|
152
|
+
- Revert `optimize.cjs` extensions — `pan-tools learn promote/unpromote/list-promoted` become "command not found"
|
|
153
|
+
|
|
154
|
+
No schema changes, no manifest format changes. Rollback is a commit-level revert.
|
|
155
|
+
|
|
156
|
+
### References
|
|
157
|
+
|
|
158
|
+
- Source spec: `docs/specs/self_improvement_loop_featureai.md` (created 2026-04-27)
|
|
159
|
+
- Predecessor: ADR-0025 (v3.6.0 behavioral guardrails layer — proved `references/` delivery channel)
|
|
160
|
+
- Predecessor: Session 31 — circular optimization loop (proved trace + analyze + apply pattern)
|
|
161
|
+
- Test infrastructure: `tests/helpers.cjs createScenarioRunner` (Session 18)
|
|
162
|
+
- Budget+circuit-breaker pattern: `pan-wizard-core/bin/lib/focus.cjs` (Session 26 / ADR-0015)
|
|
163
|
+
|
|
164
|
+
## Future scope
|
|
165
|
+
|
|
166
|
+
- **v3.8.0**: auto-promote (rules-based filter, AI-confidence threshold) once 10+ manual promotes inform the design
|
|
167
|
+
- **v3.8.0**: cross-experiment aggregation — promote a pattern based on N experiments
|
|
168
|
+
- **v3.8+**: real-time progress streaming via async/Promise mode if needed
|
|
169
|
+
- **v3.9+**: container-isolated experiments if process isolation proves insufficient
|
|
170
|
+
- **v3.9+**: experiment-replay-from-phase if idempotency story is solved
|
|
171
|
+
- **v3.7.x**: report-file parser for promote (extract pattern from `experiments/<slug>/learnings/report-*.md` instead of inline flags)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
require-code-mention: true
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# ADR-0027: Doc–Code Link Graph — `@pan:` Source Anchors & `links validate` Lint
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
Accepted — 2026-05-03. Ships in v3.8.0. Implemented in `pan-wizard-core/bin/lib/links.cjs` (`links validate`; also wired into `pan-tools validate health --links`). Spec: `docs/specs/doc_code_link_graph_featureai.md`.
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
PAN's planning surface is a graph in everything but enforcement. ADRs reference specs, specs reference phases, phases reference modules, learnings reference workflows. The relationships exist; the integrity does not. When a module is renamed, a phase archived, or an ADR superseded, no tooling notices the dangling references — they surface as agent confusion ("I cannot find the file referenced in the plan") during exec, which is the worst possible time.
|
|
13
|
+
|
|
14
|
+
We have one partial mechanism today: `must_haves.key_links` in plan-file frontmatter, verified by `cmdVerifyKeyLinks` in [verify.cjs:376](../../pan-wizard-core/bin/lib/verify.cjs#L376). It checks that a regex pattern occurs in a target file. Its scope is narrow:
|
|
15
|
+
|
|
16
|
+
- Per-plan-file declaration only — ADRs, specs, learnings, references, and workflows have no link contract.
|
|
17
|
+
- Frontmatter-only — body-text references like "see ADR-0021" are not validated.
|
|
18
|
+
- One-directional — docs declare what they reference; **code does not declare which docs anchor it**. Renaming a module silently strands its ADR.
|
|
19
|
+
- No reverse query — "what depends on this ADR?" requires `grep`.
|
|
20
|
+
|
|
21
|
+
The recently-surveyed external project [`1st1/lat.md`](https://github.com/1st1/lat.md) demonstrates the missing half: `// @lat: [[section-id]]` source comments tie code to its documentation, and a single lint walks the whole graph. lat.md's full feature set (semantic search, MCP server, libsql, tree-sitter, TypeScript) is incompatible with PAN's zero-runtime-deps + CJS posture, but the **annotation convention and graph-lint pattern translate cleanly** and require no dependencies.
|
|
22
|
+
|
|
23
|
+
This ADR records the smallest valuable slice: an annotation convention for source files, a frontmatter assertion for docs that require a code backlink, and a single lint that walks both sides.
|
|
24
|
+
|
|
25
|
+
## Decision
|
|
26
|
+
|
|
27
|
+
Add a doc–code link graph as an additive extension to existing PAN doc/lint infrastructure. **Three** elements ship together; everything else is deferred.
|
|
28
|
+
|
|
29
|
+
### 1. Source-code annotation convention: `// @pan: <doc-id>`
|
|
30
|
+
|
|
31
|
+
Source files in `pan-wizard-core/`, `bin/`, `hooks/`, `commands/`, and `agents/` may carry one or more anchor comments:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
// @pan: ADR-0026
|
|
35
|
+
// @pan: docs/specs/self_improvement_loop_featureai.md
|
|
36
|
+
// @pan: learnings/universal/test-isolation
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Rules:
|
|
40
|
+
|
|
41
|
+
- **Comment style is host-language idiomatic.** `//` for `.cjs`/`.js`, `#` for shell/Python, HTML comments for `.md`. The scanner accepts any of these so long as the literal token `@pan:` appears.
|
|
42
|
+
- **Doc IDs are paths or known short forms.** `ADR-NNNN` resolves to `docs/decisions/ADR-NNNN-*.md`; everything else is a repo-relative path.
|
|
43
|
+
- **An anchor is a claim**: "this file is a load-bearing implementation of that doc." Annotations are not required everywhere; they are required only where the *doc* asserts it (see element 3).
|
|
44
|
+
- **The convention is documentation, not gating.** Missing or incorrect anchors are lint findings, not commit blockers, until the team opts a doc into `require-code-mention`.
|
|
45
|
+
|
|
46
|
+
### 2. Doc-side frontmatter: `require-code-mention: true`
|
|
47
|
+
|
|
48
|
+
Any markdown doc — ADR, spec, learning, reference — may add a frontmatter field:
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
---
|
|
52
|
+
require-code-mention: true
|
|
53
|
+
---
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The lint then asserts that **at least one** source file under the scanned roots carries an `@pan:` anchor resolving to this doc. Docs without the field are treated as advisory; the absence of code mentions is silent.
|
|
57
|
+
|
|
58
|
+
This mirrors lat.md's `require-code-mention: true` semantics one-for-one. The choice of which docs opt in is the user's, not the tool's. Initial defaults (suggested, not enforced): all `docs/decisions/ADR-*.md` for accepted ADRs; specs are opt-in.
|
|
59
|
+
|
|
60
|
+
### 3. New CLI: `pan-tools links validate`
|
|
61
|
+
|
|
62
|
+
A single command produces a graph-integrity report. It runs three passes:
|
|
63
|
+
|
|
64
|
+
1. **Forward link resolution.** Walks `docs/`, `pan-wizard-core/{workflows,templates,references,learnings}/`, `commands/`, `agents/` for inline `[[<id>]]` references and frontmatter `must_haves.key_links` entries. Each link must resolve to a real file (and section, when supplied).
|
|
65
|
+
2. **Backlink contract.** For every doc with `require-code-mention: true`, scan source roots for `@pan:` anchors resolving to that doc. Zero matches → finding.
|
|
66
|
+
3. **Anchor target existence.** For every `@pan:` anchor, the resolved target must exist. A renamed ADR with a stale anchor → finding.
|
|
67
|
+
|
|
68
|
+
Output shape mirrors existing `validate health` JSON: `{ ok, findings: [{ type, severity, source, target, detail }] }`. Subcommands: `validate` (default), `--strict` (exit 1 on any finding), `--json` (machine output for hooks).
|
|
69
|
+
|
|
70
|
+
Implementation slot: a new `links.cjs` module under `pan-wizard-core/bin/lib/`, registered in `pan-wizard-core/bin/pan-tools.cjs`. The forward-link walker reuses the doc-lint walker in [pan-wizard-core/bin/lib/doc-lint/walk.js](../../pan-wizard-core/bin/lib/doc-lint/walk.js); the frontmatter parser reuses [frontmatter.cjs](../../pan-wizard-core/bin/lib/frontmatter.cjs); the source scanner is a 30-line regex over the source roots. No new runtime dependencies.
|
|
71
|
+
|
|
72
|
+
### What this ADR explicitly does NOT add
|
|
73
|
+
|
|
74
|
+
- **Inline `[[wiki-link]]` rendering or rewriting.** The lint *checks* such links; nothing transforms them.
|
|
75
|
+
- **`pan-tools links refs <doc>` (reverse-index query).** Implementable on top of the same scanner; deferred to a follow-up phase to keep this ADR small.
|
|
76
|
+
- **`pan-tools links expand <file>` (inline ref content into a prompt).** Belongs near `context-budget.cjs` and needs a budget contract; deferred.
|
|
77
|
+
- **Semantic search, embeddings, MCP server, vector DB.** Out of scope — violates zero-deps and overlaps with Claude Code's own MCP plumbing.
|
|
78
|
+
- **Tree-sitter / AST parsing.** Regex over comment lines is sufficient and stays consistent with [codebase.cjs](../../pan-wizard-core/bin/lib/codebase.cjs)'s regex-not-AST stance (per ADR-0021).
|
|
79
|
+
- **Auto-creation of anchors.** Humans place `@pan:` anchors; the tool does not infer them.
|
|
80
|
+
- **Pre-commit hook integration.** Runs on demand and inside `validate health`; commit-time enforcement is opt-in via `--strict` in user CI, not bundled.
|
|
81
|
+
|
|
82
|
+
## Consequences
|
|
83
|
+
|
|
84
|
+
### Positive
|
|
85
|
+
|
|
86
|
+
- **One name for one concept.** "Link graph" supersedes the ad-hoc mix of `key_links`, body-text refs, and unwritten conventions.
|
|
87
|
+
- **Renames stop being silent breakages.** Moving an ADR or renaming a `.cjs` module produces a finding the next time `validate links` runs.
|
|
88
|
+
- **Bidirectional traceability.** `@pan:` anchors make the implementation-of-an-ADR question answerable from the code side, not only the doc side.
|
|
89
|
+
- **Drop-in for existing infrastructure.** `key_links` keeps working; new lint subsumes it as a special case (frontmatter-declared link is just one shape of forward link).
|
|
90
|
+
- **Zero new runtime dependencies.** Pure CJS + regex + existing walkers.
|
|
91
|
+
- **Composable with `validate health`.** The umbrella health check can call `links validate` once `--full`-style cost is acceptable; intermediate solution is a separate top-level command.
|
|
92
|
+
|
|
93
|
+
### Negative
|
|
94
|
+
|
|
95
|
+
- **One more lint to keep green.** Docs with `require-code-mention: true` will fail the lint if their anchor module is deleted; someone must intervene.
|
|
96
|
+
- **Anchors are noise in source files.** A `.cjs` module implementing two ADRs and a spec carries three comment lines. Mitigation: anchors cluster at the top of the file under a single banner; convention documented.
|
|
97
|
+
- **The convention is human-enforced.** Nothing makes contributors place `@pan:` anchors; only the *doc-side* `require-code-mention` flag is enforced. This is deliberate — an over-eager rule ("every module must declare an anchor") would generate noise without improving the graph.
|
|
98
|
+
- **Two link styles coexist for one release.** Existing `must_haves.key_links` regex-based entries and new `[[<id>]]` inline references both pass `validate links`. Migration is opt-in, not forced. Authors of new docs should prefer inline refs; legacy `key_links` continue to work.
|
|
99
|
+
- **Doc-lint coverage expands.** `doc-lint.cjs` and `links.cjs` will overlap. Mitigation: `doc-lint.cjs` continues to handle prose/style; `links.cjs` owns reference integrity. Boundary is "is this about *this file's* shape, or about *cross-file* relationships?"
|
|
100
|
+
|
|
101
|
+
### Neutral / Tradeoffs considered
|
|
102
|
+
|
|
103
|
+
- **Why a new module, not an extension of `verify.cjs`?** `verify.cjs` is plan-file-centric (`cmdVerifyKeyLinks`, `cmdVerifyPlanStructure`); the link graph spans all docs and code. A focused module keeps both clean.
|
|
104
|
+
- **Why not a single `[[wiki]]` syntax to replace `key_links`?** `key_links` carries an extra field — a regex pattern — that asserts not just "the file exists" but "the file contains this token." Inline `[[wiki]]` is reference-only. They serve different needs; both stay.
|
|
105
|
+
- **Why `@pan:` and not a runtime-prefixed token (`@pan-claude:`)?** PAN ships into 5 runtimes from one source; the anchor describes a relationship in *PAN-the-tool*'s graph, independent of which runtime the reader is using.
|
|
106
|
+
- **Why opt-in `require-code-mention` rather than scan-everything?** Some docs are aspirational (future ADRs, design notes). Forcing a code mention for every doc in `docs/` would either be spammed with anchors-of-convenience or hold ADRs hostage to implementation status.
|
|
107
|
+
|
|
108
|
+
## Implementation Notes
|
|
109
|
+
|
|
110
|
+
### Files added
|
|
111
|
+
|
|
112
|
+
| File | Purpose |
|
|
113
|
+
|------|---------|
|
|
114
|
+
| `pan-wizard-core/bin/lib/links.cjs` | New core module — graph walker + lint |
|
|
115
|
+
| `commands/pan/links.md` | New command — exposes `links validate` |
|
|
116
|
+
| `tests/links.test.cjs` | Unit tests for forward/backlink/anchor passes |
|
|
117
|
+
| `tests/scenarios/links-graph.test.cjs` | Scenario test — full repo against the lint |
|
|
118
|
+
| `docs/specs/doc_code_link_graph_featureai.md` | Spec (W0 prerequisite) |
|
|
119
|
+
|
|
120
|
+
### Files modified
|
|
121
|
+
|
|
122
|
+
- `pan-wizard-core/bin/pan-tools.cjs` — register `links` subcommand.
|
|
123
|
+
- `pan-wizard-core/bin/lib/verify.cjs` — `cmdValidateConsistency` calls into `links.validateAll()` for a graph summary line in `validate health` output (advisory, not blocking).
|
|
124
|
+
- `pan-wizard-core/bin/lib/frontmatter.cjs` — recognize `require-code-mention` as a known field (no parser changes; it's already preserved).
|
|
125
|
+
- `docs/USER-GUIDE.md`, `docs/CLI-REFERENCE.md`, `docs/ARCHITECTURE.md` — document the convention and command.
|
|
126
|
+
- `CLAUDE.md` counts table — module count and command count update on ship.
|
|
127
|
+
|
|
128
|
+
### Rollout phases
|
|
129
|
+
|
|
130
|
+
| Phase | Scope | Gate |
|
|
131
|
+
|-------|-------|------|
|
|
132
|
+
| W0 | Spec at `docs/specs/doc_code_link_graph_featureai.md` | Reviewed |
|
|
133
|
+
| W1 | `links.cjs` + dispatcher + unit tests for forward-link & anchor-target passes | All tests green |
|
|
134
|
+
| W2 | Backlink-contract pass + `require-code-mention` opt-in + scenario test | `validate links` green against current repo |
|
|
135
|
+
| W3 | Wire summary line into `validate health` + docs + opt three accepted ADRs into `require-code-mention: true` as the canary | `validate health` shows graph row; canary ADRs have anchors |
|
|
136
|
+
|
|
137
|
+
`refs` and `expand` follow as separate ADRs (or as v3.8 phases) once the graph itself is trustworthy.
|
|
138
|
+
|
|
139
|
+
### Rollback plan
|
|
140
|
+
|
|
141
|
+
Entirely additive. Steps:
|
|
142
|
+
|
|
143
|
+
- Remove `pan-wizard-core/bin/lib/links.cjs` — `pan-tools links validate` becomes "command not found".
|
|
144
|
+
- Remove the `links.validateAll()` call from `cmdValidateConsistency` — `validate health` returns to its pre-W3 shape.
|
|
145
|
+
- Strip `require-code-mention: true` from the canary ADRs (or leave them; the field is harmless when no lint reads it).
|
|
146
|
+
- `@pan:` comments are valid host-language comments and harmless if the lint is removed.
|
|
147
|
+
|
|
148
|
+
No schema changes, no manifest changes. Rollback is a commit-level revert.
|
|
149
|
+
|
|
150
|
+
### References
|
|
151
|
+
|
|
152
|
+
- Predecessor: `cmdVerifyKeyLinks` in [verify.cjs](../../pan-wizard-core/bin/lib/verify.cjs#L376) — frontmatter-declared link verification (the link graph's first slice)
|
|
153
|
+
- Predecessor: ADR-0021 (Codebase Mapper v2) — established regex-not-AST as the codebase-analysis stance
|
|
154
|
+
- Predecessor: ADR-0026 (Self-Improvement Loop) — established the `learnings/{universal,internal}/` two-tier delivery; its docs become natural opt-in candidates for `require-code-mention`
|
|
155
|
+
- External inspiration: [`1st1/lat.md`](https://github.com/1st1/lat.md) — `// @lat:` annotation convention and `lat check` graph lint. The full project (TS, libsql, tree-sitter, MCP server, embeddings) is rejected; the convention and the lint pattern are adopted.
|
|
156
|
+
- Related infrastructure: [doc-lint.cjs](../../pan-wizard-core/bin/lib/doc-lint.cjs) and the walker in [doc-lint/walk.js](../../pan-wizard-core/bin/lib/doc-lint/walk.js) — reused, not duplicated
|
|
157
|
+
|
|
158
|
+
## Future scope
|
|
159
|
+
|
|
160
|
+
- **`pan-tools links refs <doc>`** — reverse query: "what files anchor or reference this doc?" Cheap once the scanner exists; separate ADR or v3.8 phase.
|
|
161
|
+
- **`pan-tools links expand <file>`** — inline `[[<id>]]` content into a prompt before sending to an agent, gated by [context-budget.cjs](../../pan-wizard-core/bin/lib/context-budget.cjs). Replaces a class of "the agent didn't have the ADR loaded" failures.
|
|
162
|
+
- **Auto-anchor suggestion in `pan-optimizer`** — when the optimizer harvests a session that touches `<file>` and a recently-modified ADR, propose an `@pan:` anchor as a learning. Only after the manual graph is stable.
|
|
163
|
+
- **Promote `key_links` to a special-cased forward link** — eventual unification, contingent on a low-friction migration story for existing plan files.
|
|
164
|
+
- **Commit-hook gate** — opt-in via repo-local hooks once the graph has been green for two release cycles.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ADR-0028: Unified `.agents/skills/` Build Target
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
Accepted — Phase 1 shipped 2026-06-10 (`--unified-skills` opt-in: runtime-neutral compiler `convertClaudeCommandToUnifiedSkill()`, all five runtimes wired, proprietary-surface sweep, manifest + uninstall integration). Phase 2 substantially shipped same day: shared runtime-neutral core at `.agents/pan-wizard-core/` (skills no longer depend on which runtime installed last) and ref-counted shared-tree uninstall (last tracker removes and prunes). Agent-ref canonicalization shipped 2026-06-11: shared content references canonical agent-definition copies at `.agents/pan-wizard-core/agents/` instead of the installing runtime's agents dir — shared-tree content is now runtime-neutral end to end. Still open before default-on: per-runtime live discovery gates. Phase 3 first half (AGENTS.md universal rules layer) shipped 2026-06-11: local installs contribute a marker-fenced PAN section to the project's AGENTS.md with a CLAUDE.md `@AGENTS.md` bridge and ref-counted uninstall; plugin/marketplace packaging remains. (Promotes item 10 of `docs/ECOSYSTEM-REVIEW-2026-06.md` §4 out of proposal status; supersedes the per-runtime command-tree strategy for command-shaped content.)
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
PAN Wizard ships the same command/workflow/reference content to five runtimes by converting it five times into five proprietary layouts (`.claude/commands/`, `.codex/`, `.gemini/`, `.opencode/commands/`, `.github/skills/`). The installer carries a converter, a sweep path, and a manifest section per runtime, and every runtime format change (three of which landed in v3.9.0 alone — Codex, Copilot, OpenCode) is a PAN maintenance event.
|
|
9
|
+
|
|
10
|
+
Between January and June 2026 the ecosystem converged on the **Agent Skills standard**: a `SKILL.md`-per-directory tree under `.agents/skills/` (project) or `~/.agents/skills/` (user), read natively by all five PAN target runtimes. Two additional facts sharpen the opportunity:
|
|
11
|
+
|
|
12
|
+
- **PAN already writes the tree.** The v3.9.0 Codex migration (ecosystem review item 7) moved Codex skills to `.agents/skills/` after live verification that the old `$CODEX_HOME/skills` location was dead. The compile-to-skills path exists and is tested; it is simply only wired to one runtime.
|
|
13
|
+
- **Antigravity CLI** (Gemini CLI's successor for individual accounts, effective 2026-06-18) reads `.agents/skills/` natively. The recorded decision (review item 1, 2026-06-10) is to serve Antigravity through this tree rather than build a bespoke sixth runtime — which makes the unified target the *only* planned delivery path for an entire user population, not merely a simplification.
|
|
14
|
+
|
|
15
|
+
The cost of the status quo is structural: five copies of identical content drift independently, the installer is the largest unfactored surface in the codebase, and each new runtime (Antigravity will not be the last) multiplies the work instead of adding a consumer.
|
|
16
|
+
|
|
17
|
+
## Decision
|
|
18
|
+
|
|
19
|
+
Compile command-shaped content — `commands/pan/*.md`, workflow protocols, and agent-loaded references — **once**, into a standard `.agents/skills/` tree, and make that tree the canonical install surface for every runtime. Keep per-runtime conversion only for artifacts that are genuinely runtime-specific:
|
|
20
|
+
|
|
21
|
+
| Artifact | Strategy |
|
|
22
|
+
|---|---|
|
|
23
|
+
| Commands / workflows / references | **Unified:** one compile pass → `.agents/skills/pan-*/SKILL.md` (project root for `--local`, `~/.agents/skills/` for global) |
|
|
24
|
+
| Agents (subagent definitions) | Per-runtime (formats genuinely differ: Claude markdown, Codex TOML, Copilot `.agent.md`, OpenCode `permission` maps) |
|
|
25
|
+
| Hooks | Per-runtime (event names and schemas differ; see review item 13 for the mapping-table follow-up) |
|
|
26
|
+
| Settings / config / statusline | Per-runtime (documented read paths differ) |
|
|
27
|
+
|
|
28
|
+
### Rollout gates
|
|
29
|
+
|
|
30
|
+
1. **Per-runtime verification gate.** A runtime flips from its proprietary command tree to the shared tree only after a live discovery smoke test on that runtime (the standard's adoption claims were corroborated during the June 2026 review, but PAN verifies before building — the Codex migration caught a dead install location exactly this way).
|
|
31
|
+
2. **Opt-in first.** Phase 1 ships behind `--unified-skills`; fresh installs default to it only once all five runtimes pass the gate. Upgrades sweep the legacy per-runtime trees the same way the v3.9.0 Codex migration swept `.codex/skills/pan-*`.
|
|
32
|
+
3. **Frontmatter adapter, not lowest common denominator.** Runtime-specific frontmatter (e.g. Claude's `context: fork`, `allowed-tools`) is emitted into SKILL.md and relied on being ignored by runtimes that don't consume it; anything that *breaks* a runtime's parser is handled by the compile pass, not by forking the content.
|
|
33
|
+
|
|
34
|
+
### Phasing
|
|
35
|
+
|
|
36
|
+
- **Phase 1 (v4.0-alpha):** extract the Codex skills-compile path into a runtime-neutral compiler (pure functions, unit-tested); wire all runtimes behind `--unified-skills`; per-runtime live gates.
|
|
37
|
+
- **Phase 2 (v4.0):** default-on for fresh installs; upgrade sweep; manifest consolidation (single `../.agents/skills/` key space — the out-of-tree manifest convention from the Codex migration generalizes).
|
|
38
|
+
- **Phase 3 (v4.x):** the tree becomes the substrate for plugin/marketplace packaging (review item 11) and the `AGENTS.md` universal rules layer (item 14).
|
|
39
|
+
|
|
40
|
+
## Consequences
|
|
41
|
+
|
|
42
|
+
**Positive.** One source of truth for command content ends the five-way drift class permanently. The installer's largest conversion surface collapses into one compiler plus thin per-runtime adapters. New runtimes (Antigravity first) become consumers of an existing tree — near-zero marginal cost. Gemini-individual users displaced on 2026-06-18 get full PAN command coverage without a sixth runtime.
|
|
43
|
+
|
|
44
|
+
**Negative / risks.** A shared tree is a shared failure domain: a compiler bug ships to every runtime at once (mitigated by the per-runtime live gates and the existing scenario-test matrix). Discovery semantics may differ subtly between runtimes (precedence vs. proprietary trees during the transition; the sweep ordering matters). Users who hand-edited installed command files lose those edits in the sweep (same trade accepted in the v3.9.0 Codex migration; patch-backup machinery already skips out-of-tree keys by design and needs extension rather than invention).
|
|
45
|
+
|
|
46
|
+
**Explicitly out of scope.** Hooks unification (item 13), agent-format unification (no standard exists), MCP-server delivery (item 16).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# ADR-0029: Optional LLM Evaluator for the Self-Improvement Runner
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
Proposed — design spike only (IMPROVEMENT-TODO P2). Per its acceptance criteria, **no implementation until this ADR is reviewed and accepted by the maintainer.**
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
The v3.7.0 self-improvement loop (`runner.cjs`, `experiment.cjs`, ADR-0026) stops experiments on deterministic signals: process exit, a wall-clock timeout, a circuit breaker, and milestone-completion detection that reads `status:` out of the experiment's `state.md` (`STOP_REASONS`: success / error / timeout / circuit_breaker / manual / incomplete). For experiments whose goal is structural — "does this workflow reach milestone completion?" — this is exactly right.
|
|
9
|
+
|
|
10
|
+
It is blunt for experiments whose success criterion is genuinely qualitative: *did prompt variant B produce a better plan than variant A? Is the generated summary actually faithful to the diff?* Today those experiments stop on iteration count or timeout, and a human reads the transcripts. Claude Code's `/goal` command demonstrated the worker/evaluator split — a separate small model judging completion after every turn — but it is Claude-only and outside PAN's surface.
|
|
11
|
+
|
|
12
|
+
The temptation to resist: PAN has spent multiple releases (v3.6 guardrails, the verify/preflight/health work) moving the *planning* lifecycle toward deterministic gates. Reintroducing LLM-as-judge into phase, focus, verify, or retro would be a regression dressed as a feature. The experiment runner is the one subsystem where the work being evaluated is itself probabilistic, so probabilistic judgment is category-appropriate there — and only there.
|
|
13
|
+
|
|
14
|
+
## Decision
|
|
15
|
+
|
|
16
|
+
Add an **opt-in, pluggable evaluator** to `runner.cjs`, off by default, with the host runtime's own CLI as the only shipped backend.
|
|
17
|
+
|
|
18
|
+
### 1. Scope fence
|
|
19
|
+
|
|
20
|
+
The evaluator is consumed by `runner.cjs` only. `phase`, `focus`, `verify`, `retro`, and every other lifecycle path keep their deterministic gates untouched — this ADR explicitly does not create a precedent. Growing the scope requires a new ADR carrying evidence that a specific deterministic gate demonstrably cannot express the needed check.
|
|
21
|
+
|
|
22
|
+
### 2. Evaluator contract
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
evaluate({ transcript, goal }) → { done: boolean, reason: string }
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `transcript`: tail of the experiment transcript (size-capped; newest content wins).
|
|
29
|
+
- `goal`: the experiment's goal condition string, authored in the experiment's `idea.md` frontmatter (`evaluator_goal:`).
|
|
30
|
+
- The verdict and reason are appended to the experiment's run log as `evaluator` events, alongside the existing metrics records — auditable after the fact, consumed by `/pan:learn` like any other signal.
|
|
31
|
+
- A `done: true` verdict stops the run with a new stop reason `evaluator_done`; `done: false` lets it continue. The evaluator can only ever *stop earlier* than the deterministic bounds — the iteration cap and timeout remain the hard ceiling, so a broken evaluator can never extend a run.
|
|
32
|
+
|
|
33
|
+
### 3. Model access — zero-runtime-dependency posture
|
|
34
|
+
|
|
35
|
+
Three options were evaluated:
|
|
36
|
+
|
|
37
|
+
| Option | Verdict |
|
|
38
|
+
|---|---|
|
|
39
|
+
| Anthropic SDK behind a config flag | Rejected — introduces the project's first runtime dependency (even optional, it lands in `package.json` and the supply chain); duplicates auth the host CLI already has. |
|
|
40
|
+
| Shell to the host runtime's CLI | **Adopted.** `runner.cjs` already spawns `claude -p` (and other runtimes via its adapter table) with `spawnSync`; the evaluator reuses the same mechanism, auth, and `billing_pool: "agent_sdk"` tagging. Zero new dependencies. |
|
|
41
|
+
| Pluggable interface, no default backend | Adopted as the shape: the CLI backend is just the default plug. `experiment.evaluator.command` accepts any executable honoring the contract (prompt on argv/stdin, JSON verdict on stdout), so non-Claude hosts or air-gapped users can supply their own. |
|
|
42
|
+
|
|
43
|
+
Configuration (all under `.planning/config.json` → `experiment.evaluator`):
|
|
44
|
+
|
|
45
|
+
- `enabled`: `false` (default). Nothing changes for anyone who doesn't opt in.
|
|
46
|
+
- `command`: defaults to the host runtime's CLI in print mode with a small fast model (Haiku-class) — evaluation is a cheap classification call, not reasoning work.
|
|
47
|
+
- `interval`: evaluate every N iterations (default 1), capped by `max_checks` (default = the experiment's iteration cap) so evaluator spend is bounded and predictable.
|
|
48
|
+
- `timeout_ms`: per-call timeout (default 60 000).
|
|
49
|
+
|
|
50
|
+
### 4. Which experiment shapes qualify
|
|
51
|
+
|
|
52
|
+
- **Benefit:** prompt-variant comparison, output-quality judgment, "did the agent's answer satisfy this rubric" — anything where the goal lives in natural language and no file/exit-code encodes it.
|
|
53
|
+
- **Must remain deterministic:** any experiment whose success is wired to phase or verify state (milestone completion, plan counts, test results). The runner refuses the evaluator (`config error`) when the experiment also declares a milestone-based success condition — one experiment, one stop authority.
|
|
54
|
+
|
|
55
|
+
### 5. Failure modes
|
|
56
|
+
|
|
57
|
+
| Failure | Behavior |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `enabled` but CLI/credentials missing | Warn once at run start, disable for the run, fall back to deterministic stops. The experiment proceeds. |
|
|
60
|
+
| Evaluator call timeout | Log an `evaluator_timeout` event, count it as "not done", continue. |
|
|
61
|
+
| Ambiguous/unparseable response | Treat as "not done", log `evaluator_ambiguous`; after 3 consecutive ambiguous responses, disable for the run with a warning (a misconfigured judge must not silently burn the budget). |
|
|
62
|
+
| Evaluator says done but milestone state disagrees | Not possible by construction — see §4: milestone-governed experiments cannot enable the evaluator. |
|
|
63
|
+
|
|
64
|
+
Every failure degrades to today's behavior. The evaluator can reduce wasted iterations; it can never make a run less safe than the deterministic bounds.
|
|
65
|
+
|
|
66
|
+
### 6. Cross-runtime behavior
|
|
67
|
+
|
|
68
|
+
The runner is the only consumer. With `enabled: false` (the default), non-Claude runtimes see zero change. With it enabled, the `command` is host-agnostic — any CLI honoring the contract works; the Claude default is convenience, not coupling.
|
|
69
|
+
|
|
70
|
+
## Consequences
|
|
71
|
+
|
|
72
|
+
**Positive.** Qualitative experiments get a stop condition that matches their nature, bounded by the existing deterministic ceiling. Evaluator verdicts become auditable log events that `/pan:learn` can mine. No new dependencies; no new auth surface; spend rides the already-tagged Agent SDK pool.
|
|
73
|
+
|
|
74
|
+
**Negative / risks.** An LLM judge is itself probabilistic — verdicts will sometimes be wrong; the mitigation is that wrong verdicts only ever end runs early, never extend them, and the transcript+reason trail makes bad judgments visible. Config surface grows by one section. The "one stop authority" rule (§4) must be enforced in code, not docs, or scope creep starts here.
|
|
75
|
+
|
|
76
|
+
**Acceptance criteria for implementation (unchanged from IMPROVEMENT-TODO):** behind `experiment.evaluator.enabled`, off by default; no change to phase/focus/verify/retro code paths; documented in `commands/pan/experiment.md` and workflows only after this ADR is accepted.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# ADR-0030: `.planning/` Concurrency Hardening — Advisory Locks + Atomic Writes
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
Accepted — v1 (best-effort) shipped 2026-06-11: `lock.cjs` primitive (`withFileLock`, `writeFileAtomic`) wired into `writeStateMd()`. Wider adoption and strict mode are the documented escalation path below.
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
PAN was designed for one agent driving one project. The fleet/agent-teams era breaks that assumption: parallel exec waves, hierarchical orchestration (`pan-conductor`), and background loops can all touch `.planning/` concurrently. The exposure classes:
|
|
9
|
+
|
|
10
|
+
1. **Lost updates** — `state.md`, `roadmap.md`, `requirements.md` are read-modify-write: two agents read, both write, one update vanishes. `state.md` is the hottest (every phase/plan transition).
|
|
11
|
+
2. **Torn reads** — a reader catches a half-written file. PAN already hardened readers (`readStateSafe`, null-checked parses), but the write side could still produce the torn state being defended against.
|
|
12
|
+
3. **Append races** — `tokens.jsonl`, bus channels. Single `appendFileSync` calls of one line are effectively atomic on local filesystems; lowest risk, no change needed now.
|
|
13
|
+
|
|
14
|
+
Constraints: zero runtime dependencies, synchronous CJS call sites, cross-platform (Windows/NTFS + POSIX), and — critically — **no new failure mode for the single-agent majority**.
|
|
15
|
+
|
|
16
|
+
## Decision
|
|
17
|
+
|
|
18
|
+
Ship `lock.cjs` with two primitives, applied incrementally:
|
|
19
|
+
|
|
20
|
+
1. **`writeFileAtomic(path, content)`** — temp file + rename, same directory. Readers never observe a partial file. (Windows rename-over-open-handle refusal falls back to a direct write, preserving today's semantics at worst.)
|
|
21
|
+
2. **`withFileLock(path, fn, opts)`** — advisory `<path>.lock` via atomic exclusive-create (`wx` flag), bounded retry with synchronous sleep (`Atomics.wait` — no busy-wait), and stale-lock stealing (default 10 s — a crashed holder must not deadlock the project).
|
|
22
|
+
|
|
23
|
+
**v1 semantics are best-effort:** when the lock cannot be acquired within the retry budget (default ~1 s), the critical section runs *unlocked* — exactly today's behavior. Concurrent fleets get lost-update protection in the overwhelmingly common case; single-agent users see zero behavioral change and zero new errors. The return value reports `locked: false` so future callers can escalate.
|
|
24
|
+
|
|
25
|
+
**First adopter:** `writeStateMd()` — every state.md write now serializes behind `state.md.lock` and lands atomically.
|
|
26
|
+
|
|
27
|
+
### Escalation path (not yet scheduled)
|
|
28
|
+
|
|
29
|
+
- Adopt the lock in the other RMW writers (roadmap, requirements, milestone files) — mechanical now that the primitive exists.
|
|
30
|
+
- **Strict mode** behind `.planning/config.json → concurrency.strict`: lock timeout returns `{error: 'lock_timeout'}` instead of falling back, for fleets that prefer failing loudly to last-write-wins.
|
|
31
|
+
- Merge semantics (CRDT-ish section merging) were considered and rejected for now: PAN's files are human-readable markdown with section structure, and a wrong automatic merge is worse than a lost update that `validate consistency` can detect. Revisit only with evidence of real-world contention that locking doesn't solve.
|
|
32
|
+
|
|
33
|
+
## Consequences
|
|
34
|
+
|
|
35
|
+
**Positive.** Lost-update and torn-write protection for the hottest file with zero dependencies and zero behavior change for existing users; a reusable primitive the remaining writers can adopt mechanically; stale-steal means crashed agents never wedge a project.
|
|
36
|
+
|
|
37
|
+
**Negative / risks.** Advisory locks only bind cooperating writers — direct `fs.writeFileSync` calls bypass them (the module-decomposition work makes such sites easy to find). Best-effort fallback means a pathological 40-writer pileup can still lose an update; that is the strict-mode trade, deliberately deferred. Lock files in `.planning/` are transient litter if a process is SIGKILLed mid-hold — bounded by the 10 s stale steal.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# ADR-0031: Backlog Source + Parallel-Research/Serial-Build/Parallel-Verify for `/pan:focus-auto`
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
Accepted — 2026-06-12. Folds the genuinely-new ideas from a project-local `/focus-loop` campaign command (built in the MontyHall compiler project) into the existing `/pan:focus-auto` runner, generalized and opt-in.
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
`/pan:focus-auto` (ADR-0015) runs continuous improvement campaigns by **scanning the codebase by category** (cleanup / tests / security / …), then looping scan → plan → exec → commit with a 5-layer safety harness and budget/context stops.
|
|
9
|
+
|
|
10
|
+
A downstream project built its own loop command, `/focus-loop`, that solved three problems focus-auto doesn't:
|
|
11
|
+
|
|
12
|
+
1. **Work selection from a curated roadmap, not a code scan.** Some campaigns work a human-prioritized backlog (an OUTSTANDING tracker, a roadmap with ranked items) rather than whatever grep finds. Scan-driven selection can't express "do the next-best item from my roadmap."
|
|
13
|
+
2. **Parallelized research/verify around a serial build.** The proven shape is *parallel read-only research → exactly one serial implementer/builder → parallel read-only adversarial verify*. focus-auto runs these sequentially; the Workflow tool now makes the fan-out cheap.
|
|
14
|
+
3. **End-of-loop integrity gate.** Per-item incremental commits can leave cross-item orphans (a symbol defined only in an uncommitted file; a combined state that doesn't build clean). A single clean-build seal at loop end, plus staging-miss and orphan audits at commit time, catch this class.
|
|
15
|
+
|
|
16
|
+
That command was **~70% identical to focus-auto** and **deeply project-specific** in its content — hardcoded item IDs, test counts, build scripts, dual-platform Windows/Linux build trees, and a "builds must be serial because two corrupt the shared tree" premise that is a property of *that* project, not a universal one. Shipping it verbatim would have been the worst runtime-agnosticism violation in PAN's command set, and a near-duplicate of an existing command.
|
|
17
|
+
|
|
18
|
+
## Decision
|
|
19
|
+
|
|
20
|
+
Adopt the three ideas as **generalized, opt-in extensions to `/pan:focus-auto`** — not a second loop command.
|
|
21
|
+
|
|
22
|
+
### 1. `--source scan|backlog` (default `scan`)
|
|
23
|
+
|
|
24
|
+
- `scan` — today's behavior: category-scoped code scan via `focus scan`.
|
|
25
|
+
- `backlog` — rank actionable items from PAN's existing planning surface (`roadmap.md` phase/item checkboxes, `requirements.md` REQ rows) by `(UserValue + TimeCriticality + RiskReduction) / Effort`, derived from the *current* document so the order never goes stale. No project-specific item-ID lists are ever hardcoded; the ranking reads whatever the roadmap contains.
|
|
26
|
+
|
|
27
|
+
`source` is stored in the auto-run state (`.planning/focus/auto-run.json`) and validated against `FOCUS_SOURCES`.
|
|
28
|
+
|
|
29
|
+
### 2. Optional Workflow-parallel research/verify (opt-in)
|
|
30
|
+
|
|
31
|
+
- `--parallel-research` / `--parallel-verify` — when set, the per-item research and verify stages fan out via the Workflow tool (read-only agents); the implement/exec stage stays a single agent. Default off → today's sequential behavior, so nothing changes for existing users.
|
|
32
|
+
- The **serial-build invariant** (at most one builder at a time) is honored only when the project declares a shared-build-tree constraint in `.planning/config.json` (`concurrency.serial_build: true`). It is **off by default** — most projects build in parallel safely. This is the key generalization: the MontyHall command treated serial-build as a universal law; PAN treats it as a per-project opt-in.
|
|
33
|
+
|
|
34
|
+
### 3. Opt-in integrity gates
|
|
35
|
+
|
|
36
|
+
- `--clean-seal` — after the loop's last item, run one clean build + full verification (commands come from `config.json → verification`/`build`, never hardcoded) to catch cross-item orphans. Off by default.
|
|
37
|
+
- **Staging-miss guard** and **orphan audit** at commit time — generalizable commit-quality checks (no implementer-touched file left unstaged; HEAD references no symbol defined only in an uncommitted file). These are advisory checks the runner already has the information to perform.
|
|
38
|
+
|
|
39
|
+
### What is explicitly NOT adopted
|
|
40
|
+
|
|
41
|
+
Everything project-specific from `/focus-loop`: hardcoded ADR/item IDs, test counts, build/factory scripts, dual-platform assumptions, hardcoded attribution (PAN uses `processAttribution`), and the "serial-build is mandatory" premise. The MontyHall `/focus-loop` stays a correct, project-local command — that is the right home for content that specific.
|
|
42
|
+
|
|
43
|
+
## Consequences
|
|
44
|
+
|
|
45
|
+
**Positive.** One runner gains backlog-driven campaigns and an optional parallel pipeline without a duplicate command; the new commit/seal gates improve commit quality for any project; the serial-build constraint is available to projects that need it (declared, not assumed). The pattern itself is promoted as a universal learning (`learnings/universal/`) so it informs planning even where the flags aren't used.
|
|
46
|
+
|
|
47
|
+
**Negative / risks.** focus-auto's command doc grows; the backlog ranker depends on roadmap/requirements being maintained (degrades to "no actionable items" when they aren't, which is a correct stop condition). Parallel research/verify only helps when the host runtime has the Workflow tool — it's a no-op fallback to sequential elsewhere.
|