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,116 @@
|
|
|
1
|
+
# ADR-0049: Machine verdicts and the findings ledger
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
**Accepted — 2026-10-12** by the maintainer (recorded in `docs/specs/product_excellence_program_2026_q4_featureai.md` §3.4). Evidence-bound finding closure and stable finding ids (item V6 of that program) landed as the amendment to D5 and D6 below (`2026-10-12`).
|
|
6
|
+
|
|
7
|
+
Proposed — 2026-09-28; shipped in v3.32.0 (2026-09-29). Implemented on `feat/evidence-loop` (spec `docs/specs/evidence_loop_featureai.md`, plan `docs/specs/evidence-loop-plan.md`); the maintainer accepts or amends it at release review. The decisions below were made in `/featureAI` on the maintainer's instruction to design, plan and build the evidence loop from the 2026-09-28 investigation and the September market-ideas queue.
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
PAN's judges already decide whether work passed. The plan checker gates plans, the reviewer gates code, the design checker gates designs, and the verifier gates phases. What PAN did not have is a record of those decisions. Measured on 2026-09-28 (aggregate counts only, spec §1.1):
|
|
12
|
+
|
|
13
|
+
- **Verdicts were prose that each workflow parsed its own way.**
|
|
14
|
+
- exec-phase grepped `status:` from the verification frontmatter.
|
|
15
|
+
- plan-phase matched headings.
|
|
16
|
+
- The review step read an error count from a shell variable nothing set.
|
|
17
|
+
- **The reviewer's report was never saved.** `/pan:review-deep` read a `review.md` that no step wrote, from a path no phase directory has. Its parser also wanted bullet findings, while the reviewer writes tables. The reviewer half of every deep review therefore merged as zero findings.
|
|
18
|
+
- **Nothing recorded a decision about a finding.** No record said a finding had been deferred, dismissed or fixed, or why. Milestone audits reconstructed tech debt from prose.
|
|
19
|
+
- **The optimisation loop saw no failures in the field.**
|
|
20
|
+
- Across 14 field projects: 3,968 trace events, zero `error`, `gap` or `correction` events.
|
|
21
|
+
- Across 1,969 subagent transcripts on the same machine: 869 failed tool calls, 23.5% of spawns affected.
|
|
22
|
+
- The failure signal depended on agents choosing to call `optimize trace log`. They did on success branches and never on error branches.
|
|
23
|
+
- **`optimize apply` could not be undone.** Running it twice on one report appended everything twice.
|
|
24
|
+
|
|
25
|
+
Two peers converged on the verification side (market ideas MI-030 and MI-031):
|
|
26
|
+
- Spec Kit's convergence classes: missing, partial, contradicts, unrequested.
|
|
27
|
+
- BMAD's review triage: every finding ends as patch, defer, dismiss-with-reason or decision, and never silently.
|
|
28
|
+
|
|
29
|
+
The Growing Harness paper (arXiv:2609.26760) supports runtime-recorded, localised failures and revertible changes.
|
|
30
|
+
|
|
31
|
+
## Decision
|
|
32
|
+
|
|
33
|
+
**D1: Verdict capture is a verb the workflow needs, not a hook.** `pan-tools findings record` reads a judge's report and prints the verdict the workflow branches on. That replaces the greps and heading matches, and the verdict gets recorded because the workflow needs the answer. It works on all five runtimes; per-agent transcripts exist on one. There is one writer per verdict.
|
|
34
|
+
|
|
35
|
+
**D2: One machine block for the judges that return text; the verifier keeps its frontmatter.**
|
|
36
|
+
- The plan checker, reviewer and design checker end their report with a fenced `pan-verdict` JSON block: `contract` `"1.0"`, agent, the agent's own verdict word, outcome `pass`/`fail`/`needs_human`, and findings, each with a class, severity, location and summary.
|
|
37
|
+
- The last block in a report wins.
|
|
38
|
+
- The verifier's verification.md frontmatter already is a machine contract, the one `/pan:plan-phase --gaps` consumes. A frontmatter adapter reads it, rather than asking the verifier for a second block that could disagree with it. The frontmatter gains `unrequested:` (M11).
|
|
39
|
+
|
|
40
|
+
**D3: Reports are saved in the phase directory by the orchestrator.** The judges stay read-only. The orchestrator writes the returned text verbatim to `NN-review.md`, `NN-plan-check.md` or `NN-design-check.md`.
|
|
41
|
+
|
|
42
|
+
**D4: An append-only project ledger, folded on read.** `.planning/findings.jsonl` holds verdict, finding and disposition rows.
|
|
43
|
+
- Status is derived, never stored: the latest disposition wins, and `fixed` gives way to `open` when a newer verdict reports the finding again.
|
|
44
|
+
- One file per project, because phase numbers continue across milestones; each row also records its milestone.
|
|
45
|
+
- It is the same append-only pattern as the cost and trace ledgers.
|
|
46
|
+
|
|
47
|
+
**D5: Deterministic identities.**
|
|
48
|
+
- A recorded artifact is identified by its line-ending-normalised content hash, so recording it twice is a no-op.
|
|
49
|
+
- A finding's id hashes its phase, agent, class, location and normalised summary.
|
|
50
|
+
- `attempt` counts one agent's verdicts on one phase.
|
|
51
|
+
|
|
52
|
+
**D6: Automatic status changes only where the evidence supports them.**
|
|
53
|
+
- ~~A new verdict closes the same agent's earlier open findings on that phase that it no longer reports.~~ **Amended `2026-10-12` (program V6):** silence is not evidence. An earlier open finding closes only when the judge answers it `resolved` with evidence (a `resolutions` entry in its block, or a truth in the verifier's `re_verification.gaps_closed`), or, for a `code-fact:<fact>` finding (program V9), when that fact passes. A finding the new verdict neither reports nor answers stays open and is listed as `unaddressed`; `still_present` counts as a re-report. The `human`/`unrequested` exemption is retired with the rule it exempted from.
|
|
54
|
+
- Deliberate dispositions are never overridden by a later report.
|
|
55
|
+
|
|
56
|
+
**D5 amendment (`2026-10-12`, program V6):** a reported finding whose exact id is new but which matches an earlier finding of the same agent and phase (same class family, where `missing` and `partial` are one family; same file, ignoring line numbers; same truth or a summary with token overlap of at least one half) keeps the earlier id. `findings list --phase N --agent A` reports `churn`, the share of ids that appear or disappear between consecutive reports.
|
|
57
|
+
|
|
58
|
+
**D7: Dispositions need reasons, and workflows dispose what they continue past.** The vocabulary is `fixed`, `deferred`, `dismissed`, `decision`. The last three require a reason, and the verb refuses without one. Workflows record the reason whenever a phase moves on with findings open:
|
|
59
|
+
- warnings accepted at review;
|
|
60
|
+
- "continue anyway" at `NEEDS_FIXES`;
|
|
61
|
+
- "force proceed" after the plan revision limit;
|
|
62
|
+
- design caveats after the design revision limit.
|
|
63
|
+
|
|
64
|
+
Milestone audits read `findings debt`.
|
|
65
|
+
|
|
66
|
+
**D8: The trace hook captures the failures only it can see.** On the agent-transcript path only, the hook records failed tool calls as `error/tool_error` events:
|
|
67
|
+
- grouped per spawn, at most 10 events;
|
|
68
|
+
- redacted before they are written, because some projects commit their traces;
|
|
69
|
+
- `execution.error_pattern_learning: false` turns capture off; the key was reserved until now.
|
|
70
|
+
|
|
71
|
+
Verdicts do not go through the hook (D1).
|
|
72
|
+
|
|
73
|
+
**D9: Every optimizer apply is recorded, and a revert refuses what it cannot undo safely.**
|
|
74
|
+
- An `apply_id` with per-action records makes `optimize revert` exact.
|
|
75
|
+
- A revert refuses hand-edited files, and reverts are last-in, first-out per file.
|
|
76
|
+
- Applying the same report twice writes nothing the second time.
|
|
77
|
+
- The advisory before/after `optimize verdict` is deferred until the loop is used: one apply run existed in 14 field projects. Trigger: apply runs in three or more projects.
|
|
78
|
+
|
|
79
|
+
**D10: `contract` versions the machine-readable outputs.** `"1.0"` appears on the verdict block, on the `findings` outputs, and on `state`, `state json`, `progress` and their MCP resources (M17). The rule is additive within a major version; readers ignore unknown fields.
|
|
80
|
+
|
|
81
|
+
## Rejected alternatives
|
|
82
|
+
|
|
83
|
+
- **The hook parses verdicts from transcripts.** It works on one runtime of five, and it would make a second writer beside the workflow, with ambiguous deduplication.
|
|
84
|
+
- **Keep the prose `optimize trace log` calls for verdicts.** Measured: in the field they fired on success branches and never on error branches.
|
|
85
|
+
- **A `pan-verdict` block in verification.md too.** Two sources of truth in one file. The frontmatter is already the contract `plan-phase --gaps` reads.
|
|
86
|
+
- **Parse each judge's prose format.** The reviewer-table versus deep-review-bullet mismatch is the failure mode. One contract, one parser.
|
|
87
|
+
- **Dispositions in the verification template.** The status would live in files the model rewrites. The verb enforces the reason at the write, and the ledger keeps the history.
|
|
88
|
+
- **A per-phase findings file.** It would need phase-directory resolution in every writer, and milestone audits read across phases anyway.
|
|
89
|
+
- **Automatic revert on regression.** A PAN project has no fixed held-out task set, so any regression signal is advisory. Revert stays a user decision.
|
|
90
|
+
|
|
91
|
+
## Consequences
|
|
92
|
+
|
|
93
|
+
- **Positive.**
|
|
94
|
+
- Workflows branch on one parsed verdict per judge, with the old reads kept as fallbacks.
|
|
95
|
+
- Milestone audits get tech debt with the reasons recorded at the time.
|
|
96
|
+
- Gap-closure rounds show what they resolved.
|
|
97
|
+
- `/pan:review-deep` finally merges the reviewer's findings.
|
|
98
|
+
- The optimiser sees failures and ranks them by recurrence.
|
|
99
|
+
- An apply can be undone.
|
|
100
|
+
- **Negative, accepted.**
|
|
101
|
+
- ~~A finding reworded between attempts appears as fixed and re-opened under a new id.~~ Fixed by the D5 amendment: a rewording keeps its id.
|
|
102
|
+
- Since the D6 amendment, a judge that does not answer its open findings leaves them open, so a phase can carry open findings past a passing verdict until someone answers or disposes them.
|
|
103
|
+
- The judges' reports gain a block of JSON at the end.
|
|
104
|
+
- The phase directory gains up to three report files.
|
|
105
|
+
- **Negative, mitigated.**
|
|
106
|
+
- Captured error text could hold secrets. It is redacted and capped, with an off switch.
|
|
107
|
+
- An unparseable block leaves the verdict unrecorded, so every workflow keeps its previous parse as the `||` fallback.
|
|
108
|
+
- **Runtime reach.** Verdicts, findings, dispositions, revert and `contract` work on all five runtimes. Tool-failure capture is Claude-only: it needs per-agent transcripts.
|
|
109
|
+
- Copilot's documented camelCase payload is now read by both loggers, so its spawns carry their agent name. There are still no failures, because Copilot has no per-subagent transcript.
|
|
110
|
+
- Gemini has no subagent-completion event, and OpenCode registers no hooks.
|
|
111
|
+
|
|
112
|
+
## Verification
|
|
113
|
+
|
|
114
|
+
- Unit suites for the contract, the ledger, the scope check, the hook capture (fixture shaped from real transcript records), revert, and the workflow drift. Each fix was revert-proven against the committed code.
|
|
115
|
+
- Tier-0 harness scenario `evidence-loop`: the whole loop runs green through a deployed install.
|
|
116
|
+
- Tier-1 `tool-error-capture`, first run 2026-09-28 ($0.50): a real subagent's failed `npm test` was captured from its own transcript by the installed hook.
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# AI Drift Prevention System — Feature Specification
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-03-07
|
|
4
|
+
**Version:** 1.0
|
|
5
|
+
**Status:** Proposed
|
|
6
|
+
**ADR:** ADR-0020
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Problem Statement
|
|
11
|
+
|
|
12
|
+
AI drift occurs when an AI coding assistant gradually deviates from a project's plan, conventions, coding standards, and architectural decisions during extended sessions or across session boundaries. This manifests as: using wrong patterns (e.g., `console.log` instead of `output()`), forgetting file naming conventions, straying from planned task scope, inventing unplanned features, or losing track of project state. For PAN Wizard's target users — developers using AI assistants for complex multi-session projects — drift is the #1 cause of wasted context tokens, rework, and subtle bugs.
|
|
13
|
+
|
|
14
|
+
## Demand Evidence
|
|
15
|
+
|
|
16
|
+
| Evidence Type | Source | Finding |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| Personal pain (user-stated) | This conversation | User explicitly asked for drift prevention analysis |
|
|
19
|
+
| Community pattern | Reddit, HN, Dev.to | Universal complaint: "AI forgets conventions mid-session" |
|
|
20
|
+
| PAN Wizard's own CLAUDE.md | Project conventions | Extensive convention docs = evidence drift is actively managed |
|
|
21
|
+
| Competitor parity | Cursor (.cursorrules), Aider (CONVENTIONS.md) | Every major tool has SOME drift prevention |
|
|
22
|
+
| Industry trend | 2026 guardrails movement | Shift from speed to quality — drift prevention is table-stakes |
|
|
23
|
+
|
|
24
|
+
## Success Criteria
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
SC-1: AI sessions produce code matching project conventions >=95% of the time (measurable via drift score)
|
|
28
|
+
SC-2: Cross-session context loss reduced — AI can resume with conventions in <2 commands
|
|
29
|
+
SC-3: Drift detection runs in <200ms on typical projects
|
|
30
|
+
SC-4: Works across Claude Code, OpenCode, Gemini CLI, Codex, Copilot CLI (all 5 runtimes)
|
|
31
|
+
SC-5: No regression in existing 1510+ tests
|
|
32
|
+
SC-6: Zero runtime dependencies maintained
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Competitive Landscape
|
|
36
|
+
|
|
37
|
+
### Current State (March 2026)
|
|
38
|
+
|
|
39
|
+
| Tool | Convention Docs | Active Enforcement | Drift Scoring | Cross-Session |
|
|
40
|
+
|---|---|---|---|---|
|
|
41
|
+
| **PAN Wizard** | Standards + CONVENTIONS.md | None (passive) | **None** | State + Resume + Memory |
|
|
42
|
+
| **Aider** | CONVENTIONS.md | None | None | Git log |
|
|
43
|
+
| **Cursor** | .cursor/rules/*.mdc | None | None | None |
|
|
44
|
+
| **Cline** | .clinerules | Human review | None | None |
|
|
45
|
+
| **Windsurf** | Rules files | None | None | Memory |
|
|
46
|
+
| **Copilot WS** | Spec files | None | None | None |
|
|
47
|
+
| **CodeScene** | External | CI quality gates | Quality score | External |
|
|
48
|
+
| **Codacy** | External | Real-time | Quality score | External |
|
|
49
|
+
|
|
50
|
+
**Key Finding:** No tool has built-in, zero-dependency drift scoring. PAN is already the leader in drift prevention infrastructure. The gap is measurement and active enforcement.
|
|
51
|
+
|
|
52
|
+
### Novel Approaches from Industry Research
|
|
53
|
+
|
|
54
|
+
1. **Structured protocols** — Output structured summaries with rationale
|
|
55
|
+
2. **Guardrail + Validation pairs** — Rules + automated checks working together
|
|
56
|
+
3. **Circuit breakers** — Warning threshold + hard threshold
|
|
57
|
+
4. **Multi-agent layered validation** — Writer -> Critic -> Tester -> Compliance
|
|
58
|
+
5. **Git-based isolation** — Every action reversible via worktrees
|
|
59
|
+
6. **Spec-driven development** — Specs as primary artifacts
|
|
60
|
+
|
|
61
|
+
## Strategic Analysis
|
|
62
|
+
|
|
63
|
+
### Blue Ocean Framework
|
|
64
|
+
|
|
65
|
+
| Action | Decision |
|
|
66
|
+
|---|---|
|
|
67
|
+
| **ELIMINATE** | External tool dependencies, IDE-specific monitoring |
|
|
68
|
+
| **REDUCE** | Manual convention checking, human-in-the-loop friction |
|
|
69
|
+
| **RAISE** | Convention enforcement: passive -> active. Drift detection: post-hoc -> during-execution |
|
|
70
|
+
| **CREATE** | **Drift Score** (quantitative, nobody has this). Convention Checker (zero-dep). Drift Report. Pre-commit gate. |
|
|
71
|
+
|
|
72
|
+
### Moat Score: 28/30
|
|
73
|
+
|
|
74
|
+
| Moat Type | Score |
|
|
75
|
+
|---|---|
|
|
76
|
+
| Context Engineering | 5/5 |
|
|
77
|
+
| Cross-Platform | 4/5 |
|
|
78
|
+
| Developer Experience | 5/5 |
|
|
79
|
+
| Zero Dependencies | 5/5 |
|
|
80
|
+
| State Persistence | 4/5 |
|
|
81
|
+
| Verification Quality | 5/5 |
|
|
82
|
+
|
|
83
|
+
### Recommendation
|
|
84
|
+
|
|
85
|
+
**Build** — PAN Wizard already has the strongest drift prevention infrastructure. Add quantitative Drift Score and automated convention checking to become the only tool answering "how much did the AI drift?" No other tool can answer this today. This is a Blue Ocean opportunity at Genesis stage in the Wardley map.
|
|
86
|
+
|
|
87
|
+
## Design
|
|
88
|
+
|
|
89
|
+
### Architecture
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
pan-tools.cjs → 'drift-check' case
|
|
93
|
+
→ verify.cjs: cmdDriftCheck(cwd, raw, args)
|
|
94
|
+
→ parseConventionRules(content) -- from CONVENTIONS.md
|
|
95
|
+
→ getChangedFiles(cwd, sinceRef) -- git diff --name-only
|
|
96
|
+
→ checkFileConventions(path, content, rules) -- per file
|
|
97
|
+
→ calculateDriftScore(violations, filesChecked)
|
|
98
|
+
→ output(result, raw, summary)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Convention Rule Format
|
|
102
|
+
|
|
103
|
+
Rules extracted from CONVENTIONS.md markdown code blocks:
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
## Error Handling
|
|
107
|
+
- Use `safeReadFile()` instead of `existsSync()` + `readFileSync()`
|
|
108
|
+
- Wrap all `writeFileSync` calls in try-catch
|
|
109
|
+
|
|
110
|
+
## Output
|
|
111
|
+
- Use `output(data, raw, label)` — never `console.log` for JSON output
|
|
112
|
+
- Use `error(message)` — never `console.error` or `throw` to user
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Parsed into:
|
|
116
|
+
```json
|
|
117
|
+
[
|
|
118
|
+
{"id": "safe-read", "antiPattern": "existsSync", "message": "Use safeReadFile() instead of existsSync+readFileSync", "severity": "warning"},
|
|
119
|
+
{"id": "output-fn", "antiPattern": "console\\.log", "message": "Use output() instead of console.log", "severity": "error"},
|
|
120
|
+
{"id": "error-fn", "antiPattern": "console\\.error", "message": "Use error() instead of console.error", "severity": "error"}
|
|
121
|
+
]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Built-in PAN Convention Rules
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const BUILTIN_CONVENTION_RULES = [
|
|
128
|
+
{ id: 'no-console-log', antiPattern: /\bconsole\.log\b/, message: 'Use output() instead of console.log', severity: 'error', fileGlob: '*.cjs' },
|
|
129
|
+
{ id: 'no-console-error', antiPattern: /\bconsole\.error\b/, message: 'Use error() instead of console.error', severity: 'error', fileGlob: '*.cjs' },
|
|
130
|
+
{ id: 'no-existsSync', antiPattern: /\bexistsSync\b/, message: 'Use safeReadFile() or fileAccessible() instead of existsSync', severity: 'warning', fileGlob: '*.cjs' },
|
|
131
|
+
{ id: 'no-throw-to-user', antiPattern: /\bthrow new Error\b/, message: 'Use error() function instead of throw', severity: 'warning', fileGlob: '*.cjs' },
|
|
132
|
+
{ id: 'cmd-naming', antiPattern: /^function\s+(?!cmd)[a-z]+\w*\(cwd,\s*raw/, message: 'Public command functions should be named cmd*', severity: 'info', fileGlob: 'lib/*.cjs' },
|
|
133
|
+
{ id: 'toPosix-paths', antiPattern: /output\([^)]*path\.join/, message: 'Wrap path.join() in toPosix() for output', severity: 'warning', fileGlob: '*.cjs' },
|
|
134
|
+
{ id: 'write-try-catch', antiPattern: /writeFileSync\b(?![^]*catch)/, message: 'Wrap writeFileSync in try-catch', severity: 'warning', fileGlob: '*.cjs' },
|
|
135
|
+
];
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Drift Score Formula
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
drift_score = min(1.0, weighted_violations / (files_checked * max_rules_per_file))
|
|
142
|
+
|
|
143
|
+
where:
|
|
144
|
+
weighted_violations = sum(3 for errors, 1 for warnings, 0.5 for info)
|
|
145
|
+
max_rules_per_file = total_rules * 0.3 (30% expected violation ceiling)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Score interpretation:
|
|
149
|
+
- 0.0 - 0.2: **Clean** — minimal or no drift
|
|
150
|
+
- 0.2 - 0.5: **Low** — some convention deviations, review recommended
|
|
151
|
+
- 0.5 - 0.8: **Medium** — significant drift, action recommended
|
|
152
|
+
- 0.8 - 1.0: **High** — severe drift, conventions being ignored
|
|
153
|
+
|
|
154
|
+
### Command Interface
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
pan-tools drift-check [--since <ref>] [--threshold <0.0-1.0>] [--files <path,...>]
|
|
158
|
+
|
|
159
|
+
Arguments:
|
|
160
|
+
--since <ref> Git ref to diff against (default: HEAD)
|
|
161
|
+
--threshold <n> Pass/fail threshold (default: 0.5)
|
|
162
|
+
--files <paths> Comma-separated specific files to check
|
|
163
|
+
|
|
164
|
+
Output (JSON):
|
|
165
|
+
{
|
|
166
|
+
"drift_score": 0.35,
|
|
167
|
+
"verdict": "low",
|
|
168
|
+
"violations": [
|
|
169
|
+
{"file": "lib/verify.cjs", "line": 45, "rule": "no-console-log", "message": "Use output() instead of console.log", "severity": "error"}
|
|
170
|
+
],
|
|
171
|
+
"violation_count": 3,
|
|
172
|
+
"files_checked": 8,
|
|
173
|
+
"conventions_loaded": 12,
|
|
174
|
+
"summary": "drift: 0.35 (low) — 3 violations in 8 files"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
Exit codes: 0 = pass, 1 = fail (above threshold)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Error Handling
|
|
181
|
+
|
|
182
|
+
| Condition | Output | Behavior |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| No CONVENTIONS.md | `{"drift_score": 0, "violations": [], "summary": "no conventions loaded"}` | Graceful pass |
|
|
185
|
+
| Not a git repo | `{"error": "git repository not found"}` | Clean error |
|
|
186
|
+
| Invalid --threshold | `{"error": "threshold must be 0.0-1.0"}` | Arg validation |
|
|
187
|
+
| No changed files | `{"drift_score": 0, "violations": [], "summary": "no files changed"}` | Clean pass |
|
|
188
|
+
| Invalid regex in convention | Skip rule, add warning | Degraded but functional |
|
|
189
|
+
|
|
190
|
+
## Feature Ladder
|
|
191
|
+
|
|
192
|
+
| Version | Scope | Value | Effort |
|
|
193
|
+
|---|---|---|---|
|
|
194
|
+
| **v0 (MVP)** | `drift-check` command + rule parser + git diff + built-in rules + score | Quantitative drift measurement | S-M (18 pts) |
|
|
195
|
+
| **v1** | Pre-commit hook + drift-report.md + health --drift + verify integration | Automated prevention in workflow | M (16 pts) |
|
|
196
|
+
| **v2** | Cross-session trends + auto-discovery + custom rule DSL + per-runtime profiles | Drift analytics and learning | L (30 pts) |
|
|
197
|
+
|
|
198
|
+
## Implementation Tasks
|
|
199
|
+
|
|
200
|
+
| # | ID | Title | Files | Effort | Pts | Priority |
|
|
201
|
+
|---|---|---|---|---|---|---|
|
|
202
|
+
| 1 | D.1 | Convention rule parser | verify.cjs | S | 2 | P2 |
|
|
203
|
+
| 2 | D.2 | File convention checker | verify.cjs | S | 2 | P2 |
|
|
204
|
+
| 3 | D.3 | Drift score calculator | verify.cjs | XS | 1 | P2 |
|
|
205
|
+
| 4 | D.4 | cmdDriftCheck orchestrator | verify.cjs | M | 4 | P2 |
|
|
206
|
+
| 5 | D.5 | CLI dispatcher routing | pan-tools.cjs | XS | 1 | P2 |
|
|
207
|
+
| 6 | D.6 | Health check --drift | verify.cjs | S | 2 | P3 |
|
|
208
|
+
| 7 | D.7 | Built-in convention rules | constants.cjs | S | 2 | P3 |
|
|
209
|
+
| 8 | D.8 | Test suite (20+ tests) | tests/drift-check.test.cjs | M | 4 | P2 |
|
|
210
|
+
| 9 | D.9 | Documentation | README, USER-GUIDE, CHANGELOG | S | 2 | P4 |
|
|
211
|
+
|
|
212
|
+
**Total: 20 points (v0 MVP)**
|
|
213
|
+
|
|
214
|
+
### Dependency Graph
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
D.7 (Constants) ──> D.1 (Parser) ──> D.2 (Checker) ──> D.3 (Score) ──> D.4 (Command)
|
|
218
|
+
├──> D.5 (Dispatch)
|
|
219
|
+
├──> D.6 (Health)
|
|
220
|
+
└──> D.8 (Tests) ──> D.9 (Docs)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Test Plan
|
|
224
|
+
|
|
225
|
+
### Test Pyramid (enforced)
|
|
226
|
+
|
|
227
|
+
| Level | Count | What It Catches |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| Unit | 8+ | Rule parsing, file checking, score calculation |
|
|
230
|
+
| Integration | 6+ | Git diff, arg parsing, JSON output, thresholds |
|
|
231
|
+
| E2E | 2+ | Full workflow with real conventions |
|
|
232
|
+
|
|
233
|
+
### Key Test Cases
|
|
234
|
+
|
|
235
|
+
1. parseConventionRules: empty content -> []
|
|
236
|
+
2. parseConventionRules: markdown with code blocks -> extracted rules
|
|
237
|
+
3. parseConventionRules: invalid regex -> skipped, no crash
|
|
238
|
+
4. checkFileConventions: clean file -> 0 violations
|
|
239
|
+
5. checkFileConventions: console.log in .cjs -> violation
|
|
240
|
+
6. checkFileConventions: existsSync usage -> warning
|
|
241
|
+
7. calculateDriftScore: 0 violations -> 0.0
|
|
242
|
+
8. calculateDriftScore: errors weighted 3x
|
|
243
|
+
9. calculateDriftScore: capped at 1.0
|
|
244
|
+
10. cmdDriftCheck: no conventions -> score 0
|
|
245
|
+
11. cmdDriftCheck: with violations -> correct JSON
|
|
246
|
+
12. cmdDriftCheck: --threshold exceeded -> exit 1
|
|
247
|
+
13. cmdDriftCheck: --files specific path
|
|
248
|
+
14. cmdDriftCheck: non-git dir -> error
|
|
249
|
+
15. cmdDriftCheck: --since HEAD~3
|
|
250
|
+
16. cmdDriftCheck: --raw output format
|
|
251
|
+
17. Built-in rules match PAN patterns
|
|
252
|
+
18. CRLF line endings handled
|
|
253
|
+
19. Binary files skipped
|
|
254
|
+
20. Large file (>100KB) skipped
|
|
255
|
+
|
|
256
|
+
## Security
|
|
257
|
+
|
|
258
|
+
- **Attack surface:** Read-only analysis. No code modification. No external calls.
|
|
259
|
+
- **Path safety:** Applied via execFileSync (no shell injection) + path.resolve + project root check.
|
|
260
|
+
- **Output sanitization:** toPosix paths, no absolute paths, no env vars, no stack traces.
|
|
261
|
+
- **Content validation:** Regex try-catch for convention rules. No eval/Function.
|
|
262
|
+
|
|
263
|
+
## Risk Register
|
|
264
|
+
|
|
265
|
+
| Risk | Probability | Impact | Mitigation |
|
|
266
|
+
|---|---|---|---|
|
|
267
|
+
| False positive violations | Medium | Medium | Severity levels + configurable threshold |
|
|
268
|
+
| Convention format variations | Medium | Low | Built-in rules as fallback |
|
|
269
|
+
| Cross-platform paths | Medium | Medium | toPosix(), CRLF-safe patterns |
|
|
270
|
+
| Performance on large repos | Low | Low | File count limit (100), size limit (100KB) |
|
|
271
|
+
|
|
272
|
+
## Sources
|
|
273
|
+
|
|
274
|
+
- [Guardrails for Agentic Coding](https://jvaneyck.wordpress.com/2026/02/22/guardrails-for-agentic-coding-how-to-move-up-the-ladder-without-lowering-your-bar/)
|
|
275
|
+
- [AI Code Quality in 2026](https://tfir.io/ai-code-quality-2026-guardrails/)
|
|
276
|
+
- [8 Tactics to Reduce Context Drift](https://lumenalta.com/insights/8-tactics-to-reduce-context-drift-with-parallel-ai-agents)
|
|
277
|
+
- [AI Coding Agents: Coherence Through Orchestration](https://mikemason.ca/writing/ai-coding-agents-jan-2026/)
|
|
278
|
+
- [Codified Context (arxiv)](https://arxiv.org/html/2602.20478v1)
|
|
279
|
+
- [Cursor Rules Guide 2026](https://www.agentrulegen.com/guides/cursor-rules-guide)
|
|
280
|
+
- [Aider Conventions](https://aider.chat/docs/usage/conventions.html)
|
|
281
|
+
- [How We Prevent AI Agent Drift](https://dev.to/singhdevhub/how-we-prevent-ai-agents-drift-code-slop-generation-2eb7)
|
|
282
|
+
- [CodeScene AI Guardrails](https://codescene.com/resources/use-cases/prevent-ai-generated-technical-debt)
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
*Generated by /featureAI — 2026-03-07*
|