pan-wizard 3.12.3 → 3.13.1

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.
Files changed (46) hide show
  1. package/README.md +2 -1
  2. package/agents/pan-debugger.md +2 -2
  3. package/agents/pan-hardener.md +5 -2
  4. package/agents/pan-meta-reviewer.md +2 -1
  5. package/agents/pan-planner.md +16 -0
  6. package/agents/pan-reviewer.md +2 -1
  7. package/bin/install-lib.cjs +8 -0
  8. package/bin/install.js +3 -2
  9. package/commands/pan/audit-deployment.md +8 -8
  10. package/commands/pan/focus-auto.md +10 -6
  11. package/commands/pan/hygiene.md +69 -0
  12. package/commands/pan/milestone-done.md +3 -2
  13. package/hooks/dist/pan-cost-logger.js +54 -6
  14. package/hooks/dist/pan-trace-logger.js +41 -5
  15. package/package.json +1 -1
  16. package/pan-wizard-core/bin/lib/constants.cjs +40 -0
  17. package/pan-wizard-core/bin/lib/cost.cjs +26 -1
  18. package/pan-wizard-core/bin/lib/hud.cjs +14 -2
  19. package/pan-wizard-core/bin/lib/hygiene.cjs +447 -0
  20. package/pan-wizard-core/bin/lib/knowledge.cjs +28 -12
  21. package/pan-wizard-core/bin/lib/learn-index.cjs +17 -0
  22. package/pan-wizard-core/bin/lib/memory.cjs +146 -3
  23. package/pan-wizard-core/bin/lib/skill-align.cjs +364 -0
  24. package/pan-wizard-core/bin/lib/verify.cjs +10 -0
  25. package/pan-wizard-core/bin/pan-tools.cjs +47 -1
  26. package/pan-wizard-core/learnings/index.json +262 -10
  27. package/pan-wizard-core/learnings/internal/external-research.md +13 -1
  28. package/pan-wizard-core/learnings/universal/adversarial-verification.md +45 -0
  29. package/pan-wizard-core/learnings/universal/audit-convergence.md +33 -0
  30. package/pan-wizard-core/learnings/universal/autonomous-loop.md +4 -4
  31. package/pan-wizard-core/learnings/universal/external-tool-truth.md +21 -0
  32. package/pan-wizard-core/learnings/universal/fix-campaigns.md +45 -0
  33. package/pan-wizard-core/learnings/universal/flaky-triage.md +33 -0
  34. package/pan-wizard-core/learnings/universal/golden-sets.md +33 -0
  35. package/pan-wizard-core/learnings/universal/harness-isolation.md +21 -0
  36. package/pan-wizard-core/learnings/universal/integration-verification.md +33 -0
  37. package/pan-wizard-core/learnings/universal/live-path-honesty.md +45 -0
  38. package/pan-wizard-core/learnings/universal/mcp-security.md +21 -0
  39. package/pan-wizard-core/learnings/universal/migration-safety.md +21 -0
  40. package/pan-wizard-core/learnings/universal/service-security.md +21 -0
  41. package/pan-wizard-core/learnings/universal/single-source-of-truth.md +33 -0
  42. package/pan-wizard-core/learnings/universal/test-integrity.md +21 -0
  43. package/pan-wizard-core/learnings/universal/workaround-catalog.md +21 -0
  44. package/pan-wizard-core/references/model-profiles.md +23 -1
  45. package/pan-wizard-core/workflows/exec-phase.md +12 -3
  46. package/pan-wizard-core/workflows/plan-phase.md +1 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "generated_at": "2026-06-28T11:51:31.104Z",
3
+ "generated_at": "2026-07-09T15:40:55.203Z",
4
4
  "topics": [
5
5
  {
6
6
  "name": "experiment-runner",
@@ -34,10 +34,11 @@
34
34
  "P-RES-004",
35
35
  "P-RES-005",
36
36
  "P-RES-006",
37
- "P-RES-007"
37
+ "P-RES-007",
38
+ "P-RES-008"
38
39
  ],
39
- "size_bytes": 10306,
40
- "size_tokens_est": 2577,
40
+ "size_bytes": 12400,
41
+ "size_tokens_est": 3100,
41
42
  "agent_relevance": {
42
43
  "planner": "medium",
43
44
  "executor": "low",
@@ -91,6 +92,24 @@
91
92
  "reviewer": "low"
92
93
  }
93
94
  },
95
+ {
96
+ "name": "adversarial-verification",
97
+ "scope": "universal",
98
+ "file": "pan-wizard-core/learnings/universal/adversarial-verification.md",
99
+ "patterns": [
100
+ "P-ADV-001",
101
+ "P-ADV-002",
102
+ "P-ADV-003"
103
+ ],
104
+ "size_bytes": 5405,
105
+ "size_tokens_est": 1352,
106
+ "agent_relevance": {
107
+ "planner": "medium",
108
+ "executor": "low",
109
+ "verifier": "high",
110
+ "reviewer": "high"
111
+ }
112
+ },
94
113
  {
95
114
  "name": "atomic-state",
96
115
  "scope": "universal",
@@ -107,6 +126,23 @@
107
126
  "reviewer": "medium"
108
127
  }
109
128
  },
129
+ {
130
+ "name": "audit-convergence",
131
+ "scope": "universal",
132
+ "file": "pan-wizard-core/learnings/universal/audit-convergence.md",
133
+ "patterns": [
134
+ "P-AUD-001",
135
+ "P-AUD-002"
136
+ ],
137
+ "size_bytes": 3693,
138
+ "size_tokens_est": 924,
139
+ "agent_relevance": {
140
+ "planner": "high",
141
+ "executor": "low",
142
+ "verifier": "high",
143
+ "reviewer": "high"
144
+ }
145
+ },
110
146
  {
111
147
  "name": "autonomous-loop",
112
148
  "scope": "universal",
@@ -116,8 +152,8 @@
116
152
  "P-350",
117
153
  "P-360"
118
154
  ],
119
- "size_bytes": 10680,
120
- "size_tokens_est": 2670,
155
+ "size_bytes": 10667,
156
+ "size_tokens_est": 2667,
121
157
  "agent_relevance": {
122
158
  "planner": "low",
123
159
  "executor": "medium",
@@ -288,6 +324,57 @@
288
324
  "reviewer": "high"
289
325
  }
290
326
  },
327
+ {
328
+ "name": "external-tool-truth",
329
+ "scope": "universal",
330
+ "file": "pan-wizard-core/learnings/universal/external-tool-truth.md",
331
+ "patterns": [
332
+ "P-XTT-001"
333
+ ],
334
+ "size_bytes": 1621,
335
+ "size_tokens_est": 406,
336
+ "agent_relevance": {
337
+ "planner": "low",
338
+ "executor": "high",
339
+ "verifier": "high",
340
+ "reviewer": "low"
341
+ }
342
+ },
343
+ {
344
+ "name": "fix-campaigns",
345
+ "scope": "universal",
346
+ "file": "pan-wizard-core/learnings/universal/fix-campaigns.md",
347
+ "patterns": [
348
+ "P-FIX-001",
349
+ "P-FIX-002",
350
+ "P-FIX-003"
351
+ ],
352
+ "size_bytes": 4897,
353
+ "size_tokens_est": 1225,
354
+ "agent_relevance": {
355
+ "planner": "high",
356
+ "executor": "medium",
357
+ "verifier": "high",
358
+ "reviewer": "high"
359
+ }
360
+ },
361
+ {
362
+ "name": "flaky-triage",
363
+ "scope": "universal",
364
+ "file": "pan-wizard-core/learnings/universal/flaky-triage.md",
365
+ "patterns": [
366
+ "P-FLK-001",
367
+ "P-FLK-002"
368
+ ],
369
+ "size_bytes": 3309,
370
+ "size_tokens_est": 828,
371
+ "agent_relevance": {
372
+ "planner": "low",
373
+ "executor": "medium",
374
+ "verifier": "high",
375
+ "reviewer": "medium"
376
+ }
377
+ },
291
378
  {
292
379
  "name": "glob-semantics",
293
380
  "scope": "universal",
@@ -304,6 +391,39 @@
304
391
  "reviewer": "low"
305
392
  }
306
393
  },
394
+ {
395
+ "name": "golden-sets",
396
+ "scope": "universal",
397
+ "file": "pan-wizard-core/learnings/universal/golden-sets.md",
398
+ "patterns": [
399
+ "P-GLD-001",
400
+ "P-GLD-002"
401
+ ],
402
+ "size_bytes": 3215,
403
+ "size_tokens_est": 804,
404
+ "agent_relevance": {
405
+ "planner": "high",
406
+ "executor": "medium",
407
+ "verifier": "high",
408
+ "reviewer": "medium"
409
+ }
410
+ },
411
+ {
412
+ "name": "harness-isolation",
413
+ "scope": "universal",
414
+ "file": "pan-wizard-core/learnings/universal/harness-isolation.md",
415
+ "patterns": [
416
+ "P-ISO-001"
417
+ ],
418
+ "size_bytes": 1736,
419
+ "size_tokens_est": 434,
420
+ "agent_relevance": {
421
+ "planner": "high",
422
+ "executor": "medium",
423
+ "verifier": "low",
424
+ "reviewer": "low"
425
+ }
426
+ },
307
427
  {
308
428
  "name": "idempotency",
309
429
  "scope": "universal",
@@ -320,6 +440,23 @@
320
440
  "reviewer": "high"
321
441
  }
322
442
  },
443
+ {
444
+ "name": "integration-verification",
445
+ "scope": "universal",
446
+ "file": "pan-wizard-core/learnings/universal/integration-verification.md",
447
+ "patterns": [
448
+ "P-INT-001",
449
+ "P-INT-002"
450
+ ],
451
+ "size_bytes": 3075,
452
+ "size_tokens_est": 769,
453
+ "agent_relevance": {
454
+ "planner": "high",
455
+ "executor": "low",
456
+ "verifier": "high",
457
+ "reviewer": "medium"
458
+ }
459
+ },
323
460
  {
324
461
  "name": "invariants",
325
462
  "scope": "universal",
@@ -352,6 +489,56 @@
352
489
  "reviewer": "low"
353
490
  }
354
491
  },
492
+ {
493
+ "name": "live-path-honesty",
494
+ "scope": "universal",
495
+ "file": "pan-wizard-core/learnings/universal/live-path-honesty.md",
496
+ "patterns": [
497
+ "P-HON-001",
498
+ "P-HON-002",
499
+ "P-HON-003"
500
+ ],
501
+ "size_bytes": 4975,
502
+ "size_tokens_est": 1244,
503
+ "agent_relevance": {
504
+ "planner": "medium",
505
+ "executor": "high",
506
+ "verifier": "high",
507
+ "reviewer": "high"
508
+ }
509
+ },
510
+ {
511
+ "name": "mcp-security",
512
+ "scope": "universal",
513
+ "file": "pan-wizard-core/learnings/universal/mcp-security.md",
514
+ "patterns": [
515
+ "P-MCP-001"
516
+ ],
517
+ "size_bytes": 2082,
518
+ "size_tokens_est": 521,
519
+ "agent_relevance": {
520
+ "planner": "medium",
521
+ "executor": "medium",
522
+ "verifier": "medium",
523
+ "reviewer": "high"
524
+ }
525
+ },
526
+ {
527
+ "name": "migration-safety",
528
+ "scope": "universal",
529
+ "file": "pan-wizard-core/learnings/universal/migration-safety.md",
530
+ "patterns": [
531
+ "P-MIG-001"
532
+ ],
533
+ "size_bytes": 2031,
534
+ "size_tokens_est": 508,
535
+ "agent_relevance": {
536
+ "planner": "high",
537
+ "executor": "high",
538
+ "verifier": "medium",
539
+ "reviewer": "high"
540
+ }
541
+ },
355
542
  {
356
543
  "name": "numeric-edge-cases",
357
544
  "scope": "universal",
@@ -464,6 +651,39 @@
464
651
  "reviewer": "high"
465
652
  }
466
653
  },
654
+ {
655
+ "name": "service-security",
656
+ "scope": "universal",
657
+ "file": "pan-wizard-core/learnings/universal/service-security.md",
658
+ "patterns": [
659
+ "P-SVC-001"
660
+ ],
661
+ "size_bytes": 2193,
662
+ "size_tokens_est": 549,
663
+ "agent_relevance": {
664
+ "planner": "medium",
665
+ "executor": "high",
666
+ "verifier": "high",
667
+ "reviewer": "high"
668
+ }
669
+ },
670
+ {
671
+ "name": "single-source-of-truth",
672
+ "scope": "universal",
673
+ "file": "pan-wizard-core/learnings/universal/single-source-of-truth.md",
674
+ "patterns": [
675
+ "P-SSOT-001",
676
+ "P-SSOT-002"
677
+ ],
678
+ "size_bytes": 3647,
679
+ "size_tokens_est": 912,
680
+ "agent_relevance": {
681
+ "planner": "high",
682
+ "executor": "high",
683
+ "verifier": "medium",
684
+ "reviewer": "high"
685
+ }
686
+ },
467
687
  {
468
688
  "name": "streaming-io",
469
689
  "scope": "universal",
@@ -480,6 +700,22 @@
480
700
  "reviewer": "low"
481
701
  }
482
702
  },
703
+ {
704
+ "name": "test-integrity",
705
+ "scope": "universal",
706
+ "file": "pan-wizard-core/learnings/universal/test-integrity.md",
707
+ "patterns": [
708
+ "P-TI-001"
709
+ ],
710
+ "size_bytes": 1915,
711
+ "size_tokens_est": 479,
712
+ "agent_relevance": {
713
+ "planner": "medium",
714
+ "executor": "high",
715
+ "verifier": "high",
716
+ "reviewer": "high"
717
+ }
718
+ },
483
719
  {
484
720
  "name": "test-patterns",
485
721
  "scope": "universal",
@@ -547,12 +783,28 @@
547
783
  "verifier": "low",
548
784
  "reviewer": "medium"
549
785
  }
786
+ },
787
+ {
788
+ "name": "workaround-catalog",
789
+ "scope": "universal",
790
+ "file": "pan-wizard-core/learnings/universal/workaround-catalog.md",
791
+ "patterns": [
792
+ "P-WKC-001"
793
+ ],
794
+ "size_bytes": 1741,
795
+ "size_tokens_est": 436,
796
+ "agent_relevance": {
797
+ "planner": "low",
798
+ "executor": "high",
799
+ "verifier": "medium",
800
+ "reviewer": "low"
801
+ }
550
802
  }
551
803
  ],
552
804
  "totals": {
553
- "topics": 32,
554
- "patterns": 66,
555
- "size_bytes": 101338,
556
- "size_tokens_est": 25344
805
+ "topics": 47,
806
+ "patterns": 93,
807
+ "size_bytes": 148954,
808
+ "size_tokens_est": 37255
557
809
  }
558
810
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  topic: external-research
3
- last_updated: 2026-05-02T18:16:19.459Z
3
+ last_updated: 2026-07-09T14:04:40.520Z
4
4
  patterns:
5
5
  - id: P-RES-001
6
6
  summary: ACE (Zhang et al, arXiv:2510.04618, Oct 2025): summary-based context chains have brevity bias and context collapse. Treat memory as append-and-curate playbook, not paraphrase chain
@@ -30,6 +30,10 @@ patterns:
30
30
  summary: Sakana DGM (2025): in self-improvement loops, AGENT-DESIGN changes generalize across models and languages; PROMPT-FRAGMENT tweaks do not. Promote structural changes, not phrasing tweaks
31
31
  promoted_at: 2026-05-02T18:16:19.459Z
32
32
  source_experiments: [external]
33
+ - id: P-RES-008
34
+ summary: Enterprise "train on our data" asks are retrieval problems, not fine-tuning problems: schema/context LINKING is the bottleneck (BEAVER: SOTA ~10.8% on real enterprise schemas vs 80%+ on public benchmarks, ~68% of failures are schema-linking), and plain BM25 RAG beats fine-tuning alone (Tencent 160k-file study: 53.8% vs 44.2% EM; FT alone caused catastrophic forgetting; FT+RAG best at 57.4%)
35
+ promoted_at: 2026-07-09T14:04:40.520Z
36
+ source_experiments: [spec-factory]
33
37
  ---
34
38
 
35
39
  # External Research (AI-derived)
@@ -91,3 +95,11 @@ patterns:
91
95
  **Rule:** When pan-tools learn promote runs (manual gate today, possibly auto-promote in v3.8+), the promote criterion should distinguish: 1) STRUCTURAL pattern (a new agent role, a new file in .planning/, a new verification gate, a new tool-use idiom, an architectural decision) vs 2) PROMPT-FRAGMENT (specific phrasing, a worded instruction, a stylistic preference). Universal scope should be reserved for structural patterns. Prompt fragments belong in internal scope at most — they don't generalize across models or languages, so shipping them to all 5 runtimes is a bet that won't pay.
92
96
 
93
97
  **Applies in:** pan-tools learn promote --scope universal gate, optimize.cjs promotePattern criteria, future auto-promote rules
98
+
99
+ ## P-RES-008 — Enterprise "train on our data" asks are retrieval problems, not fine-tuning problems: schema/context LINKING is the bottleneck (BEAVER: SOTA ~10.8% on real enterprise schemas vs 80%+ on public benchmarks, ~68% of failures are schema-linking), and plain BM25 RAG beats fine-tuning alone (Tencent 160k-file study: 53.8% vs 44.2% EM; FT alone caused catastrophic forgetting; FT+RAG best at 57.4%)
100
+
101
+ **Evidence:** The the tech-spec factory tech-spec factory research roadmap (adversarially verified, with citations) synthesized: on BEAVER (real enterprise schemas) SOTA agents collapse to ~10.8%; roughly 68% of failures are schema-linking, not generation. The Tencent 160k-file study showed plain BM25 retrieval beating fine-tuning alone (53.8 vs 44.2 EM) with fine-tuning alone causing catastrophic forgetting. Design consequence adopted there: never dump a full schema into context — decompose into semantic units, hybrid-retrieve a small candidate set (~50), then resolve to physical names.
102
+
103
+ **Rule:** When a project asks to "train the model on our data/schema": default to retrieval-first (decompose corpus into semantic units, hybrid lexical+semantic retrieval of a small candidate set, then resolve). Treat fine-tuning as an additive step at most, never the substitute. Size context by retrieved candidates, not by dumping the schema. Expect public-benchmark performance claims to overstate enterprise reality by up to an order of magnitude.
104
+
105
+ **Applies in:** Research/planning phases for RAG or fine-tune decisions, enterprise schema tooling, context-budget design.
@@ -0,0 +1,45 @@
1
+ ---
2
+ topic: adversarial-verification
3
+ last_updated: 2026-07-09T14:21:24.882Z
4
+ patterns:
5
+ - id: P-ADV-001
6
+ summary: Two-stage audit: fan out cheap read-only finders, then one independent verifier per finding whose default stance is refute — expect a third to a half of raw findings to die, and action only survivors
7
+ promoted_at: 2026-07-09T14:04:40.513Z
8
+ source_experiments: [lending-fake-code-audit]
9
+ - id: P-ADV-002
10
+ summary: Anti-double-jeopardy: a verifier's first duty in a repeated audit is git-provenance against the prior findings register — refute anything byte-identical to already-adjudicated code, and confirm only with an explicit "not a re-report" clause naming the prior lines checked
11
+ promoted_at: 2026-07-09T14:21:24.881Z
12
+ source_experiments: [lending-audit-rounds-3-4]
13
+ - id: P-ADV-003
14
+ summary: Confirmation requires a REACHABLE trigger on the deployed surface, and severity is calibrated against named prior-round precedents — the recurring false-positive shapes are: unreachable fallback, value nothing consumes, happy-path-only proof, inverted causal mechanism, and code mirroring an authoritative sibling's intended semantics
15
+ promoted_at: 2026-07-09T14:21:24.882Z
16
+ source_experiments: [lending-audit-rounds-3-4]
17
+ ---
18
+
19
+ # Adversarial Verification (AI-derived)
20
+
21
+ > Auto-maintained by `pan-tools learn promote`. Each pattern was extracted from one or more experiment runs (see source_experiments). Patterns are **advisory** — orchestrators should weight them against current context.
22
+
23
+ ## P-ADV-001 — Two-stage audit: fan out cheap read-only finders, then one independent verifier per finding whose default stance is refute — expect a third to a half of raw findings to die, and action only survivors
24
+
25
+ **Evidence:** A production fake-code audit ran 12 read-only slice auditors and then one adversarial verifier per finding (default stance: refute). Round 1: 80 raw findings -> 36 confirmed / 44 refuted. Round 2: 34 raw -> 23 confirmed / 11 refuted. Acting on raw finder output would have wasted roughly half the remediation effort on plausible-but-wrong findings.
26
+
27
+ **Rule:** Never action raw finder output. Structure audits as: (1) parallel read-only finders raise candidate findings cheaply; (2) an independent verifier per finding, prompted to REFUTE it, with fresh context; (3) only findings that survive refutation are confirmed and actioned. Budget for a 30-55% refutation rate — if nothing is being refuted, the verifiers are rubber-stamping.
28
+
29
+ **Applies in:** Code audits, security sweeps, review pipelines, multi-agent verification stages.
30
+
31
+ ## P-ADV-002 — Anti-double-jeopardy: a verifier's first duty in a repeated audit is git-provenance against the prior findings register — refute anything byte-identical to already-adjudicated code, and confirm only with an explicit "not a re-report" clause naming the prior lines checked
32
+
33
+ **Evidence:** In a four-round production audit, every confirmed finding's verdict carried a provenance clause ("NOT a round-1 re-report — the register's only adjacent item was CONFIRMED LOW; the hunk was untouched by the remediation commits c1d1d569/acf0e03c") and refutations were proven with git ("byte-identical to the round-1 baseline; git diff shows no hunk touches these lines"). Without this, later rounds re-litigate settled findings and burn fix cycles on double-jeopardy.
34
+
35
+ **Rule:** In any repeated audit, give the verifier the prior findings register and the prior audit baseline commit. Confirmation requires an explicit statement that the finding is new or on changed code (cite the register entries checked and the commits since baseline). Refute re-reports of unchanged, already-adjudicated code — including re-litigations of already-fixed findings at a lower bar.
36
+
37
+ **Applies in:** Repeated audit rounds, review campaigns, any finder/verifier loop that runs more than once on the same tree.
38
+
39
+ ## P-ADV-003 — Confirmation requires a REACHABLE trigger on the deployed surface, and severity is calibrated against named prior-round precedents — the recurring false-positive shapes are: unreachable fallback, value nothing consumes, happy-path-only proof, inverted causal mechanism, and code mirroring an authoritative sibling's intended semantics
40
+
41
+ **Evidence:** The refutation taxonomy from a 340-line verified findings register: a parser fallback that "exists exactly as cited but is unreachable on every rendered path"; a fabricated field where "no one is shown this field — the only consumer parses another key and silently drops it"; an ALWAYS_GREEN claim whose "mechanism is inverted"; and code that "byte-for-byte mirrors the owning monitor, whose designed semantics" it inherits. Confirmed findings calibrated severity to precedent: "MED matches the round-1 precedent (arrears failed-read-as-benign-data was MED)".
42
+
43
+ **Rule:** A finding is confirmed only with a concrete failing input/state that is reachable on the deployed surface. Check the five false-positive shapes before confirming: (1) is the flagged code reachable? (2) does anything consume the value? (3) is the proof happy-path-only? (4) is the causal mechanism actually as described? (5) does the code intentionally mirror an authoritative sibling? Assign severity by citing a comparable prior finding, not freehand.
44
+
45
+ **Applies in:** Verifier prompts, audit verdict schemas, severity rubrics for multi-round reviews.
@@ -0,0 +1,33 @@
1
+ ---
2
+ topic: audit-convergence
3
+ last_updated: 2026-07-09T14:21:24.883Z
4
+ patterns:
5
+ - id: P-AUD-001
6
+ summary: Stop an iterated audit on a convergence signal — top-severity count reaches zero AND confirmed findings collapse by an order of magnitude — not on "no findings at all"; escalate the model and taper the fan-out as the tree hardens
7
+ promoted_at: 2026-07-09T14:21:24.883Z
8
+ source_experiments: [lending-audit-rounds-3-4]
9
+ - id: P-AUD-002
10
+ summary: Rotate the audit LENS and its category taxonomy each round (honesty → correctness/completeness → cross-cutting depth), explicitly excluding scope already fixed in prior rounds — re-running the same lens finds the same things
11
+ promoted_at: 2026-07-09T14:21:24.883Z
12
+ source_experiments: [lending-audit-rounds-3-4]
13
+ ---
14
+
15
+ # Audit Convergence (AI-derived)
16
+
17
+ > Auto-maintained by `pan-tools learn promote`. Each pattern was extracted from one or more experiment runs (see source_experiments). Patterns are **advisory** — orchestrators should weight them against current context.
18
+
19
+ ## P-AUD-001 — Stop an iterated audit on a convergence signal — top-severity count reaches zero AND confirmed findings collapse by an order of magnitude — not on "no findings at all"; escalate the model and taper the fan-out as the tree hardens
20
+
21
+ **Evidence:** A four-round production audit stopped when round 3's 108 confirmed (9 HIGH) dropped to round 4's 16 confirmed (0 HIGH — a ~7x collapse), declaring "no new HIGH-severity defect survived a 4th pass on a hardened tree; the codebase is converging; this is likely the last productive audit round." Convergence was partly forced: the model was escalated to the strongest tier and the agent count tapered from 152 to 39 as findings thinned — the convergence claim is only meaningful against the strongest reviewer.
22
+
23
+ **Rule:** Define the stopping rule before the audit loop starts: stop when (a) zero findings at the top severity survive verification AND (b) the confirmed count collapses relative to the prior round (~5-10x). Never require literal zero findings — a long MED/LOW tail is normal residue. As rounds progress, escalate reviewer strength and shrink fan-out; a "converged" verdict from a weak reviewer at full fan-out proves nothing.
24
+
25
+ **Applies in:** Audit campaigns, review loops, focus-loop stop conditions, quality-gate design.
26
+
27
+ ## P-AUD-002 — Rotate the audit LENS and its category taxonomy each round (honesty → correctness/completeness → cross-cutting depth), explicitly excluding scope already fixed in prior rounds — re-running the same lens finds the same things
28
+
29
+ **Evidence:** Round 1/2 audited fabrication (LIVE_FAKE_DATA, ALWAYS_GREEN, STUB_IN_PROD); round 3 switched to "a correctness/completeness/quality lens, distinct from the rounds-1/2 mock-fake honesty audit" (INCORRECT, RACE_OR_LEAK, DUPLICATION_DRIFT, MISSING_VALIDATION); round 4 went to cross-cutting depth ("atomicity, concurrency, authz depth, regulatory-math edges") plus a dedicated fix-regression pass. Each round explicitly excluded the previous rounds' fixed findings ("the 59 already-fixed mock/fake findings were explicitly excluded"), so every pass hit a genuinely different defect class.
30
+
31
+ **Rule:** Plan a repeated audit as a lens sequence, each with its own defect taxonomy: (1) honesty/fabrication, (2) correctness/completeness/error-handling, (3) cross-cutting depth (atomicity, concurrency, authorization, domain-math edges) + fix regressions. Feed each round the prior rounds' fixed-findings register as an explicit exclusion so auditors don't rediscover settled ground.
32
+
33
+ **Applies in:** Multi-round audit design, review campaign planning, quality-sweep scheduling.
@@ -9,11 +9,11 @@ patterns:
9
9
  - id: P-350
10
10
  summary: In a parallel campaign, review a branch against its merge-base (three-dot / fork-sha diff), never two-dot main..HEAD, or a moved base produces phantom deletions and false blocks
11
11
  promoted_at: 2026-06-28T00:00:00.000Z
12
- source_experiments: [abilitycompliance-army-v1.1]
12
+ source_experiments: [compliance-army-v1.1]
13
13
  - id: P-360
14
14
  summary: Campaign telemetry must be both captured (active per-step record, not just the passive hook) and trustworthy (never naive-sum a shared-session transcript — cumulative-per-turn cache-read over-counts by orders of magnitude)
15
15
  promoted_at: 2026-06-28T00:00:00.000Z
16
- source_experiments: [abilitycompliance-army-v1.1, plusb-loans-focus-auto, plusbforecasting-exec]
16
+ source_experiments: [compliance-army-v1.1, lending-focus-auto, forecasting-exec]
17
17
  ---
18
18
 
19
19
  # Autonomous Loop (AI-derived)
@@ -65,7 +65,7 @@ patterns:
65
65
 
66
66
  ## P-350 — Review a worktree branch against its merge-base, never two-dot, when the base moves
67
67
 
68
- **Evidence:** In the first production army campaign (AbilityCompliance v1.1, 6 missions), a Quality squad **BLOCK was a false positive**: the reviewer diffed `main..HEAD` (two-dot) *after* an earlier parallel mission had merged and advanced `main` past the reviewed mission's fork point — so the already-merged mission's additions appeared as **phantom deletions** in the diff. The block was disproven only by re-diffing against the merge-base. A false block burns a whole cycle; the mirror case (phantom additions hiding a genuine deletion) can wave a bad change through a gate.
68
+ **Evidence:** In the first production army campaign (the compliance project v1.1, 6 missions), a Quality squad **BLOCK was a false positive**: the reviewer diffed `main..HEAD` (two-dot) *after* an earlier parallel mission had merged and advanced `main` past the reviewed mission's fork point — so the already-merged mission's additions appeared as **phantom deletions** in the diff. The block was disproven only by re-diffing against the merge-base. A false block burns a whole cycle; the mirror case (phantom additions hiding a genuine deletion) can wave a bad change through a gate.
69
69
 
70
70
  **Rule:** Whenever you review or merge a branch whose base can advance under it (every parallel campaign):
71
71
 
@@ -77,7 +77,7 @@ patterns:
77
77
 
78
78
  ## P-360 — Campaign telemetry must be both captured and trustworthy
79
79
 
80
- **Evidence:** Three production projects showed campaign telemetry failing in *both* directions. (1) **Absent** — a full 5-mission army campaign (AbilityCompliance v1.1) produced **zero** cost/trace/bus records, although the hooks were installed, registered on `SubagentStop`, and verified working in isolation; a main-loop coordinator's work never fired `SubagentStop`, so nothing was captured. (2) **Corrupted** — two projects that *did* capture (a weeks-long focus-auto loop and a phase-exec project) logged physically-impossible figures: a single subagent record claiming billions of cache-read tokens, cache-hit pinned at 100%, and many byte-identical rows. Root cause: the transcript fallback summed `usage` across *every* assistant message in a transcript whose `session_id` is shared by all subagents — so each event re-summed the whole growing transcript, and `cache_read` (re-read every turn) multiplied by the turn count. Either way the HUD, `/pan:cost`, and `/pan:optimize` consumed nothing usable.
80
+ **Evidence:** Three production projects showed campaign telemetry failing in *both* directions. (1) **Absent** — a full 5-mission army campaign (the compliance project v1.1) produced **zero** cost/trace/bus records, although the hooks were installed, registered on `SubagentStop`, and verified working in isolation; a main-loop coordinator's work never fired `SubagentStop`, so nothing was captured. (2) **Corrupted** — two projects that *did* capture (a weeks-long focus-auto loop and a phase-exec project) logged physically-impossible figures: a single subagent record claiming billions of cache-read tokens, cache-hit pinned at 100%, and many byte-identical rows. Root cause: the transcript fallback summed `usage` across *every* assistant message in a transcript whose `session_id` is shared by all subagents — so each event re-summed the whole growing transcript, and `cache_read` (re-read every turn) multiplied by the turn count. Either way the HUD, `/pan:cost`, and `/pan:optimize` consumed nothing usable.
81
81
 
82
82
  **Rule:** For any long-running, multi-step autonomous campaign, telemetry must survive the spawn pattern *and* be numerically sane:
83
83
 
@@ -0,0 +1,21 @@
1
+ ---
2
+ topic: external-tool-truth
3
+ last_updated: 2026-07-09T14:04:40.517Z
4
+ patterns:
5
+ - id: P-XTT-001
6
+ summary: Judge external CLI success by the artifact it was supposed to produce, not by its exit code — tools return non-zero for cosmetic reasons while the real work succeeded
7
+ promoted_at: 2026-07-09T14:04:40.517Z
8
+ source_experiments: [compliance-army-v1.1]
9
+ ---
10
+
11
+ # External Tool Truth (AI-derived)
12
+
13
+ > Auto-maintained by `pan-tools learn promote`. Each pattern was extracted from one or more experiment runs (see source_experiments). Patterns are **advisory** — orchestrators should weight them against current context.
14
+
15
+ ## P-XTT-001 — Judge external CLI success by the artifact it was supposed to produce, not by its exit code — tools return non-zero for cosmetic reasons while the real work succeeded
16
+
17
+ **Evidence:** A cloud container build (az acr build) exited non-zero because the console (cp1252 codepage) crashed printing a Unicode check-mark glyph from the build output — while the image build itself had succeeded in the cloud. Automation keyed on the exit code declared the deploy broken; the reliable signal was whether the image digest resolved in the registry.
18
+
19
+ **Rule:** For external tools whose job is to produce an artifact (image, package, file, release), verify the artifact exists and resolves — digest lookup, file hash, registry query — instead of trusting the process exit code alone. Exit codes conflate the tool's own console/plumbing failures with the outcome of the work.
20
+
21
+ **Applies in:** Deploy steps, build pipelines, cloud CLIs, Windows consoles with non-UTF8 codepages.
@@ -0,0 +1,45 @@
1
+ ---
2
+ topic: fix-campaigns
3
+ last_updated: 2026-07-09T14:21:24.885Z
4
+ patterns:
5
+ - id: P-FIX-001
6
+ summary: Hand a large findings register to fixers as defect-CLASS clusters with an explicit fix order ranked by real risk — "fix the class once, apply everywhere" — not as N independent tickets
7
+ promoted_at: 2026-07-09T14:21:24.884Z
8
+ source_experiments: [lending-audit-rounds-3-4]
9
+ - id: P-FIX-002
10
+ summary: Treat the audit's own suggested fixes as UNTRUSTED input — the fix campaign's quality gate must adversarially review the guidance itself, reject flawed suggestions, and preserve the original text for the audit trail
11
+ promoted_at: 2026-07-09T14:21:24.884Z
12
+ source_experiments: [lending-audit-rounds-3-4]
13
+ - id: P-FIX-003
14
+ summary: After any fix campaign, run a dedicated FIX-REGRESSION lens: hunt fixes that are inert (read the wrong path), half-wired, or that broke a sibling — distinct from generic regression testing
15
+ promoted_at: 2026-07-09T14:21:24.885Z
16
+ source_experiments: [lending-audit-rounds-3-4]
17
+ ---
18
+
19
+ # Fix Campaigns (AI-derived)
20
+
21
+ > Auto-maintained by `pan-tools learn promote`. Each pattern was extracted from one or more experiment runs (see source_experiments). Patterns are **advisory** — orchestrators should weight them against current context.
22
+
23
+ ## P-FIX-001 — Hand a large findings register to fixers as defect-CLASS clusters with an explicit fix order ranked by real risk — "fix the class once, apply everywhere" — not as N independent tickets
24
+
25
+ **Evidence:** A 108-finding audit register was compressed into 8 shared-defect-class clusters for the fix campaign ("Many findings are the same defect class repeated — fix the class once, apply everywhere"), ordered by consequence with idempotency/duplicate-financial-writes first ("highest real-money risk"). Fixers repaired the pattern once per class instead of patching 108 sites independently, which also made per-class regression review tractable.
26
+
27
+ **Rule:** Before spawning fixers on a big findings register: cluster findings by shared defect class (same root pattern, not same file), rank clusters by real-world consequence, and hand each fixer one class with all its instances. The fix contract is "repair the class everywhere", and review happens per class — never fan out one-ticket-per-finding on a register with repeated patterns.
28
+
29
+ **Applies in:** Fix campaign planning, gap-closure batching, remediation handovers after audits.
30
+
31
+ ## P-FIX-002 — Treat the audit's own suggested fixes as UNTRUSTED input — the fix campaign's quality gate must adversarially review the guidance itself, reject flawed suggestions, and preserve the original text for the audit trail
32
+
33
+ **Evidence:** A findings register's suggestedFix for an nginx routing defect "literally recommended the broken proxy_pass form; the campaign rejected that flawed guidance in favour of the rewrite-strip. The suggestedFix text is left as-authored for the audit trail." The same round's adversarial quality reviewer also caught a fix that itself dropped a required prefix-strip (BLOCK verdict) — both the auditor's advice and the fixer's change needed independent review.
34
+
35
+ **Rule:** Auditor-suggested fixes are hypotheses, not instructions: the fixer must validate the suggestion against the real system (does the API exist? does the config form parse?) and the quality gate must review the applied change independently of the suggestion. When guidance is rejected, keep the original suggestion text unmodified in the register — the divergence is part of the audit trail.
36
+
37
+ **Applies in:** Fix campaigns consuming audit registers, remediation quality gates, handover contracts.
38
+
39
+ ## P-FIX-003 — After any fix campaign, run a dedicated FIX-REGRESSION lens: hunt fixes that are inert (read the wrong path), half-wired, or that broke a sibling — distinct from generic regression testing
40
+
41
+ **Evidence:** A round-4 audit carried a dedicated fix-regression category and found three: a round-3 "resume is amount-honest" fix that "reads the resumed amount from the wrong JSON path — the fix is inert, the blind-book MED is re-opened on Live"; a checker leg reading a field the writer never sets; and a deploy-script fix that broke plan idempotency. Ordinary test suites stayed green through all three — the fixes compiled, passed, and did nothing.
42
+
43
+ **Rule:** The audit round after a fix campaign must include an explicit fix-regression lens over the fixed sites: (1) INERT — does the fix actually execute on the live path, reading the real data shape? (2) HALF-WIRED — is every leg of the fix threaded through (writer AND reader)? (3) SIBLING BREAKAGE — did the fix change behavior a neighboring consumer depended on? Green tests do not clear a fix; re-verify the original finding's failing input now behaves.
44
+
45
+ **Applies in:** Post-fix verification rounds, gap-closure follow-ups, re-audit scheduling.
@@ -0,0 +1,33 @@
1
+ ---
2
+ topic: flaky-triage
3
+ last_updated: 2026-07-09T14:04:40.517Z
4
+ patterns:
5
+ - id: P-FLK-001
6
+ summary: A failure under contended/parallel load that passes N isolated re-runs is environmental, not a regression — triage with isolated re-runs and decompose aggregate counts into disabled/timeout/genuinely-failed before reacting
7
+ promoted_at: 2026-07-09T14:04:40.516Z
8
+ source_experiments: [montyhall-cycle-close]
9
+ - id: P-FLK-002
10
+ summary: Non-deterministic verdicts (perf, endurance, memory) need windowed statistics — widen the analysis window rather than biasing the sampler, and require 2-of-3 reproduction before a finding becomes a ticket
11
+ promoted_at: 2026-07-09T14:04:40.517Z
12
+ source_experiments: [mph-factory-limits]
13
+ ---
14
+
15
+ # Flaky Triage (AI-derived)
16
+
17
+ > Auto-maintained by `pan-tools learn promote`. Each pattern was extracted from one or more experiment runs (see source_experiments). Patterns are **advisory** — orchestrators should weight them against current context.
18
+
19
+ ## P-FLK-001 — A failure under contended/parallel load that passes N isolated re-runs is environmental, not a regression — triage with isolated re-runs and decompose aggregate counts into disabled/timeout/genuinely-failed before reacting
20
+
21
+ **Evidence:** A cycle-close investigation of "8 failed" concurrent GC tests ran the suspects isolated: pass/fail/pass, then 5/5 PASS — deterministically green alone, failing only under concurrent test-runner load. The aggregate count was also misleading: it mixed ~100 disabled tests and load-induced timeouts with only two genuine (and flaky) failures. Fixing "the regression" mid-sweep would have burned a cycle on an environmental artifact.
22
+
23
+ **Rule:** Before treating a red test as a regression: (1) re-run it isolated 3-5 times; deterministic pass in isolation + failure only under load = environmental, log it to a known-red list instead of fixing mid-sweep; (2) decompose aggregate failure counts into disabled / timed-out / genuinely-failed — never react to the headline number; (3) record the triage so the next sweep does not re-investigate.
24
+
25
+ **Applies in:** CI triage, autonomous fix loops, test-gate policies, cycle-close retrospectives.
26
+
27
+ ## P-FLK-002 — Non-deterministic verdicts (perf, endurance, memory) need windowed statistics — widen the analysis window rather than biasing the sampler, and require 2-of-3 reproduction before a finding becomes a ticket
28
+
29
+ **Evidence:** An endurance/limits harness codified: "If you find yourself wanting to wait for the system to settle before sampling, the right answer is to widen the analysis window, not to bias the sampler." Marathon failures must reproduce in 2 of 3 independent re-runs before becoming a ticket; singletons accumulate in a watch bucket that auto-promotes only after repeated appearances.
30
+
31
+ **Rule:** For perf/endurance/resource checks: never pass or fail on a single sample — use windowed signals (slopes with confidence intervals, percentiles over a window). Never bias sampling to make results stable; widen the window instead. Gate findings on independent reproduction (2-of-3); park singletons in a watch bucket that promotes on recurrence rather than discarding them.
32
+
33
+ **Applies in:** Perf gates, endurance harnesses, memory-leak detection, any statistically noisy verification.
@@ -0,0 +1,33 @@
1
+ ---
2
+ topic: golden-sets
3
+ last_updated: 2026-07-09T14:04:40.518Z
4
+ patterns:
5
+ - id: P-GLD-001
6
+ summary: "Verified" requires human-verified golden sets plus live execution checks — public benchmarks are defective at scale, and an LLM judge is only usable after calibration against human labels
7
+ promoted_at: 2026-07-09T14:04:40.518Z
8
+ source_experiments: [spec-factory]
9
+ - id: P-GLD-002
10
+ summary: Execution-gate corpus curation: admit only samples that compile AND run clean on the shipped toolchain, record every exclusion with a reason code, and regenerate by script — never hand-edit the corpus
11
+ promoted_at: 2026-07-09T14:04:40.518Z
12
+ source_experiments: [montyhall-learning-corpus]
13
+ ---
14
+
15
+ # Golden Sets (AI-derived)
16
+
17
+ > Auto-maintained by `pan-tools learn promote`. Each pattern was extracted from one or more experiment runs (see source_experiments). Patterns are **advisory** — orchestrators should weight them against current context.
18
+
19
+ ## P-GLD-001 — "Verified" requires human-verified golden sets plus live execution checks — public benchmarks are defective at scale, and an LLM judge is only usable after calibration against human labels
20
+
21
+ **Evidence:** A spec-factory evaluation standard was built on the finding that naive automated eval misjudges correct work (68.3% of original SWE-bench samples were defective). Its gates: a multi-reviewer golden set anchored to facts confirmed against ground truth; read-only execution checks against the live system; LLM-as-judge admitted only after calibration against those human labels; retrieval recall@N (leave-one-out) tracked as a health metric, not a per-case blocker.
22
+
23
+ **Rule:** Build eval golden sets from human-verified, ground-truth-confirmed cases — never trust public benchmark labels or a raw LLM judge. Add live execution checks where feasible (does it build, run, resolve). Calibrate any LLM judge against the human labels before it gates anything. Track statistical health metrics (recall@N) as trends, not per-case pass/fail.
24
+
25
+ **Applies in:** Eval pipelines, golden-set curation, LLM-as-judge deployments, agent-quality gates.
26
+
27
+ ## P-GLD-002 — Execution-gate corpus curation: admit only samples that compile AND run clean on the shipped toolchain, record every exclusion with a reason code, and regenerate by script — never hand-edit the corpus
28
+
29
+ **Evidence:** A 6,332-program language-training corpus was built with a hard gate (compiles + runs exit-0 on the shipped compiler) and a full audit trail: 4,204 rejected candidates recorded with reason codes (compile_fail, run_nonzero, duplicate_of, env_dependent, ffi_dependent, secret). The corpus regenerates from a script; hand-editing is banned so the manifest, dataset, and exclusion log can never diverge.
30
+
31
+ **Rule:** When curating a training/eval corpus: (1) gate admission on real execution against the shipped toolchain, not on inspection; (2) log every exclusion with a machine-readable reason code — the reject histogram is itself a quality signal; (3) make regeneration scripted and idempotent; never hand-edit corpus files, so manifest and content cannot diverge.
32
+
33
+ **Applies in:** Training-data curation, golden corpora, conformance suites, fixture harvesting.