@event4u/agent-config 9.29.0 → 9.31.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.
Files changed (142) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +32 -214
  3. package/README.md +1 -0
  4. package/dist/agent-src/commands/analyze/inbox.md +22 -1
  5. package/dist/agent-src/commands/explain-run.md +31 -1
  6. package/dist/agent-src/commands/team/delegate.md +1 -0
  7. package/dist/agent-src/contexts/execution/orchestration-telemetry.md +4 -1
  8. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +17 -0
  9. package/dist/agent-src/contexts/execution/subagent-response-contract.md +11 -1
  10. package/dist/agent-src/rules/preservation-guard.md +9 -0
  11. package/dist/agent-src/scripts/roadmap_gates.ts +312 -0
  12. package/dist/agent-src/scripts/update_roadmap_progress.ts +72 -4
  13. package/dist/agent-src/skills/subagent-orchestration/SKILL.md +10 -0
  14. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  15. package/dist/cli/registry.js +2 -0
  16. package/dist/cli/registry.js.map +1 -1
  17. package/dist/cli-delegate/{chunk-RCIA67XN.js → chunk-2WCLVDWC.js} +45 -2
  18. package/dist/cli-delegate/{chunk-66OVWGB5.js → chunk-AG47LAGQ.js} +1 -1
  19. package/dist/cli-delegate/{chunk-MP3JT3IU.js → chunk-DS6BLDMG.js} +1 -1
  20. package/dist/cli-delegate/chunk-EJITJBJX.js +172 -0
  21. package/dist/cli-delegate/{chunk-NZ5N2XQL.js → chunk-ITIQSGOQ.js} +3 -3
  22. package/dist/cli-delegate/{chunk-LCFJIQ4J.js → chunk-JEJABGKB.js} +110 -6
  23. package/dist/cli-delegate/chunk-MMJL4TIX.js +18 -0
  24. package/dist/cli-delegate/{chunk-REKCMYOU.js → chunk-PFBV6XRT.js} +36 -20
  25. package/dist/cli-delegate/{chunk-OJM3MBJM.js → chunk-QEEB4LHO.js} +22 -35
  26. package/dist/cli-delegate/chunk-RVGBH4XK.js +142 -0
  27. package/dist/cli-delegate/{chunk-MMXA5GY7.js → chunk-UVKNIJH2.js} +14 -0
  28. package/dist/cli-delegate/cmd_analyze_session.js +1 -1
  29. package/dist/cli-delegate/cmd_brand_status.js +1 -1
  30. package/dist/cli-delegate/cmd_conformance.js +2861 -96
  31. package/dist/cli-delegate/cmd_doctor.js +3 -2
  32. package/dist/cli-delegate/cmd_explain.js +2 -2
  33. package/dist/cli-delegate/cmd_export.js +4 -4
  34. package/dist/cli-delegate/cmd_handoff.js +87 -7
  35. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  36. package/dist/cli-delegate/cmd_migrate.js +2 -2
  37. package/dist/cli-delegate/cmd_packs_active.js +2 -2
  38. package/dist/cli-delegate/cmd_prune.js +4 -4
  39. package/dist/cli-delegate/cmd_route_audit.js +3 -2
  40. package/dist/cli-delegate/cmd_route_explain.js +1 -1
  41. package/dist/cli-delegate/cmd_session_recycle.js +177 -0
  42. package/dist/cli-delegate/cmd_settings_get.js +3 -56
  43. package/dist/cli-delegate/cmd_settings_migrate.js +4 -4
  44. package/dist/cli-delegate/cmd_settings_set.js +2 -2
  45. package/dist/cli-delegate/cmd_sync.js +4 -4
  46. package/dist/cli-delegate/cmd_uninstall.js +4 -4
  47. package/dist/cli-delegate/cmd_update.js +1 -1
  48. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  49. package/dist/cli-delegate/cmd_validate.js +4 -4
  50. package/dist/cli-delegate/cmd_versions.js +1 -1
  51. package/dist/discovery/deprecation-report.md +1 -1
  52. package/dist/discovery/discovery-manifest.json +7 -7
  53. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  54. package/dist/discovery/discovery-manifest.summary.md +1 -1
  55. package/dist/discovery/orphan-report.md +1 -1
  56. package/dist/discovery/packs.json +2 -2
  57. package/dist/discovery/trust-report.md +1 -1
  58. package/dist/discovery/workspaces.json +2 -2
  59. package/dist/hooks/dispatch.js +2143 -641
  60. package/dist/install/install.mjs +133 -14
  61. package/dist/mcp/registry-manifest.json +2 -2
  62. package/dist/mcp/server.json +2 -2
  63. package/dist/mcp/server.mjs +3967 -761
  64. package/dist/scripts/_lib/agent_settings.js +111 -2
  65. package/dist/scripts/_lib/agent_settings.js.map +1 -1
  66. package/dist/server/schemas/settings.js +6 -0
  67. package/dist/server/schemas/settings.js.map +1 -1
  68. package/dist/ui/assets/index-B5qGYOJo.js +26 -0
  69. package/dist/ui/assets/index-B5qGYOJo.js.map +1 -0
  70. package/dist/ui/index.html +1 -1
  71. package/docs/contracts/settings-classes.md +21 -5
  72. package/package.json +1 -1
  73. package/src/agent-src/scripts/roadmap_gates.ts +312 -0
  74. package/src/agent-src/scripts/update_roadmap_progress.ts +72 -4
  75. package/src/config/agent-settings.template.yml +36 -0
  76. package/src/config/dispatch-economy-metrics.json +61 -0
  77. package/src/config/evaluator-budgets.json +4 -4
  78. package/src/config/hook-token-budget.json +91 -0
  79. package/src/config/pack-size-budget.json +3 -2
  80. package/src/config/recycle-threshold-budget.json +12 -0
  81. package/src/config/rule-enforcement-baseline.json +86 -0
  82. package/src/scripts/_cli/cmd_conformance.ts +17 -2
  83. package/src/scripts/_cli/cmd_session_recycle.ts +226 -0
  84. package/src/scripts/_cli/explain_last/inputs.ts +13 -0
  85. package/src/scripts/_dispatch.bash +23 -0
  86. package/src/scripts/_lib/agent_settings.ts +119 -2
  87. package/src/scripts/_lib/carrier_divergence.ts +47 -0
  88. package/src/scripts/_lib/judgment_ladder.ts +254 -2
  89. package/src/scripts/_lib/orchestration_record.ts +41 -10
  90. package/src/scripts/_lib/recycle_envelope_paths.ts +35 -0
  91. package/src/scripts/_lib/self_repair.ts +194 -0
  92. package/src/scripts/_lib/session_eol.ts +230 -0
  93. package/src/scripts/_lib/session_role.ts +42 -0
  94. package/src/scripts/_lib/subagent_capsule.ts +159 -0
  95. package/src/scripts/_lib/subagent_response.ts +75 -0
  96. package/src/scripts/ai_council/clients.ts +50 -1
  97. package/src/scripts/ask_transport.ts +221 -0
  98. package/src/scripts/bench_hook_injection.ts +234 -0
  99. package/src/scripts/check_adr_frontmatter.ts +84 -40
  100. package/src/scripts/check_branch_freshness.ts +1 -0
  101. package/src/scripts/check_corpus_staleness.ts +18 -4
  102. package/src/scripts/check_detector_corpus.ts +17 -0
  103. package/src/scripts/check_gitignore_freshness.ts +42 -8
  104. package/src/scripts/check_hook_bundle_freshness.ts +20 -0
  105. package/src/scripts/check_kernel_prefix_stability.ts +1 -0
  106. package/src/scripts/check_standing_rule_delivery.ts +73 -32
  107. package/src/scripts/check_static_layer_stability.ts +154 -0
  108. package/src/scripts/check_suppression_hygiene.ts +48 -0
  109. package/src/scripts/dispatch_economy_report.ts +448 -0
  110. package/src/scripts/dispatch_r2_reviewer.ts +15 -2
  111. package/src/scripts/explain_run.ts +206 -4
  112. package/src/scripts/generate_settings_reference.ts +1 -0
  113. package/src/scripts/handoff_context_hook.ts +112 -4
  114. package/src/scripts/hook_manifest.yaml +117 -10
  115. package/src/scripts/hooks/concern_registry.ts +8 -0
  116. package/src/scripts/hooks/delegation_nudge_hook.ts +40 -3
  117. package/src/scripts/hooks/dispatch_hook.ts +39 -2
  118. package/src/scripts/hooks/edit_shape_hook.ts +303 -0
  119. package/src/scripts/hooks/orchestration_record_hook.ts +19 -1
  120. package/src/scripts/hooks/reread_guard_hook.ts +314 -0
  121. package/src/scripts/hooks/rtk_wrap_hook.ts +133 -14
  122. package/src/scripts/hooks/session_eol_hook.ts +268 -0
  123. package/src/scripts/hooks/turn_end_gate_hook.ts +715 -0
  124. package/src/scripts/install-hooks.sh +1 -1
  125. package/src/scripts/language_mirror_hook.ts +143 -1
  126. package/src/scripts/lint_decision_impact.ts +14 -1
  127. package/src/scripts/lint_hook_manifest.ts +82 -0
  128. package/src/scripts/lint_readme_serial_comma.ts +1 -0
  129. package/src/scripts/lint_rule_enforcement_declaration.ts +347 -0
  130. package/src/scripts/measure_turn_end_gate.ts +272 -0
  131. package/src/scripts/orchestration_record.ts +4 -1
  132. package/src/scripts/rebuild_hook_bundle.ts +1 -0
  133. package/src/scripts/report_carrier_divergence.ts +72 -24
  134. package/src/scripts/report_conformance_funnel.ts +291 -0
  135. package/src/scripts/report_imperative_density.ts +1 -0
  136. package/src/scripts/routing_doctor.ts +97 -0
  137. package/src/scripts/self_repair_cli.ts +51 -3
  138. package/src/scripts/session_eol_report.ts +261 -0
  139. package/src/server/schemas/settings.ts +14 -0
  140. package/src/templates/compact-instructions.md +40 -0
  141. package/dist/ui/assets/index-JDAF00bC.js +0 -26
  142. package/dist/ui/assets/index-JDAF00bC.js.map +0 -1
@@ -0,0 +1,91 @@
1
+ {
2
+ "_comment": "Pre-registered hook-INJECTION byte budget (road-to-token-economy-cache Phase 3) — the latency file's twin: same discipline, different unit. Committed BEFORE any trimming lands; the budget is the acceptance bar, not a post-hoc fit. Bytes, not tokens, as the deterministic CI unit (no tokenizer dependency — roadmap non-goal 7.6); token-exact numbers appear only in ledger-based telemetry. Consumed by scripts/bench_hook_injection and its CI gate: a concern whose measured emission (reason + additional_context + context bytes) exceeds its row fails the build, and an EMITTING concern with no row fails the build — a new injector cannot ship without a budget row.",
3
+ "schema_version": 1,
4
+ "registered_at": "2026-08-10",
5
+ "owner": "maintainer",
6
+ "review_by": "2026-11-10",
7
+ "unit": "bytes of concern stdout payload fields (reason + additional_context + context) per fire",
8
+ "default_cap_bytes": 1024,
9
+ "per_concern_caps_bytes": {
10
+ "_comment": "Named exceptions above the default, each with its reason. Absent concern = default_cap_bytes.",
11
+ "hot-context": 4096,
12
+ "hot-context_reason": "400-word working-memory restore, session_start only — one-shot, not per-turn",
13
+ "handoff-context": 8192,
14
+ "handoff-context_reason": "consume-once handoff injection, deleted after delivery — the one legitimately large one-shot",
15
+ "session-canary": 2048,
16
+ "session-canary_reason": "full canary contract once at session_start; the per-turn beat is one line",
17
+ "language-mirror": 2048,
18
+ "language-mirror_reason": "the measured 626-wrong-turn failure class justifies a full-paragraph pin per turn",
19
+ "council-availability": 1536,
20
+ "council-availability_reason": "session_start availability block incl. resolved path + member list",
21
+ "session-register": 2048,
22
+ "session-register_reason": "collision listing scales with live sessions; capped, not unbounded",
23
+ "chat-history": 4096,
24
+ "chat-history_reason": "session_start restore block",
25
+ "edit-shape": 1024,
26
+ "edit-shape_reason": "one advisory line naming the cheaper edit primitive (roadmap 5.2: budget row from day one - the economy nudge must not itself become an economy problem)",
27
+ "reread-guard": 1024,
28
+ "reread-guard_reason": "one advisory line naming the earlier read / ranged alternative (roadmap 6.1)",
29
+ "session-eol": 1024,
30
+ "session-eol_reason": "one recycle-advisory line, once per session past the committed threshold (road-to-token-economy-recycling 3.2); recording itself emits nothing"
31
+ },
32
+ "per_slot_sum_caps_bytes": {
33
+ "_comment": "Cross-concern per-fire sum per slot (roadmap 3.1). session_start is one-time and may carry the restore payloads; per-turn slots stay tight.",
34
+ "session_start": 16384,
35
+ "user_prompt_submit": 4096,
36
+ "pre_tool_use": 2048,
37
+ "post_tool_use": 2048,
38
+ "stop": 2048,
39
+ "session_end": 1024,
40
+ "pre_compact": 2048,
41
+ "agent_error": 1024
42
+ },
43
+ "injection_load_metric": {
44
+ "definition": "Roadmap 3.4: total injected bytes per session and per turn, hook-carried. The census mode of bench_hook_injection (--record) appends counts-only lines to agents/runtime/state/injection-census.jsonl; the caps above are the thresholds; breach trend at review date decides tighten vs relax — by evidence, in a PR. The census is also the repeat-injection-census blocker's instrument (one instrumented week ranks the repeaters for the 3.3 idempotency gate).",
45
+ "privacy": "census lines carry {ts, slot, concern, bytes} — counts and ids only, never content"
46
+ },
47
+ "honest_null_consequence": "If real-session census data shows the caps are systematically wrong (either direction), the caps move by evidence in a PR at review date — never silently. A budget nobody benches is the fossilization failure this file's latency twin avoided via its CI harness; bench_hook_injection is wired into the same pipeline in the same phase.",
48
+ "advisory_adoption_metrics": {
49
+ "_comment": "Roadmap 5.3 + 6.4 registrations. These are BEHAVIOUR metrics (advisory adoption), not injection bytes - registered here because this file already carries the owner/review discipline for the same concerns.",
50
+ "owner": "maintainer",
51
+ "review_by": "2026-11-10",
52
+ "full_rewrite_small_diff_rate": {
53
+ "definition": "edit-shape fires / Write calls per session (the full-rewrite-with-small-diff rate). Kill criterion per the shipped nudge standard: a nudge whose verdicts are measurably ignored (adoption near zero over the review window, from conformance audits) gets its trigger tightened or the injected line removed.",
54
+ "instrument": "rule-trips.json warn counters (the dispatcher already counts every warn per concern) + conformance audits for adoption"
55
+ },
56
+ "duplicate_read_rate": {
57
+ "definition": "reread-guard fires / Read calls per session; re-read advisory adoption via conformance audits. Same kill standard.",
58
+ "instrument": "rule-trips.json warn counters per concern"
59
+ },
60
+ "unbounded_output_advisory_rate": {
61
+ "definition": "Roadmap 4.3 + 4.4 registration (advisory-degraded per the resolved pretooluse-rewrite-semantics blocker: no updatedInput in the v1 contract, so nothing caps and nothing can be bypassed - the demand signal is the fire count itself). rtk-wrap cap-advisory fires per session from the OUTPUT_CAP_TABLE branch; adoption (did the next run use a bounded form) via conformance audits. HONEST GAP: bytes-into-context from tool RESULTS is not instrumented anywhere (the census covers hook payloads only) - the pre/post bytes half of roadmap 4.4 is registered as unmeasurable until a tool-result byte counter exists.",
62
+ "instrument": "rule-trips.json warn counters for the rtk-wrap concern + conformance audits",
63
+ "threshold": "none committed before data - baseline first, threshold at review date"
64
+ },
65
+ "turns_per_task": {
66
+ "definition": "user_prompt_submit count keyed to the task envelope - the invisible multiplier (every turn re-pays the accumulated context at read rates).",
67
+ "instrument": "session-register / chat-history turn counters; HONEST GAP: no task-envelope key exists yet in those counters - the number is per-SESSION until a task key ships; registered with that stated limitation rather than silently redefined",
68
+ "threshold": "none committed before data - baseline first, threshold at review date"
69
+ },
70
+ "recycle_advisory_adoption": {
71
+ "definition": "road-to-token-economy-recycling 3.4: of the sessions where the session-eol recycle advisory fired, the share that actually recycled (a recycle-envelope.consumed.json produced by a successor session start). Kill standard as for the sibling nudges: adoption near zero over the review window means the advisory line is dead weight - tighten the trigger or remove the line.",
72
+ "instrument": "rule-trips.json warn counters for the session-eol concern (fires) + presence/turnover of agents/runtime/state/recycle-envelope.consumed.json and session-eol per-session state (recycles); conformance audits for the denominator detail",
73
+ "threshold": "none committed before data - baseline first, threshold at review date (2026-11-10)"
74
+ },
75
+ "auto_compact_incidence": {
76
+ "definition": "road-to-token-economy-recycling 3.4: sessions with >=1 auto compact_boundary event / all sessions, from the session-eol per-session counters (baseline: 11.2%, 23/205 sessions - agents/evidence/analysis/token-economy-recycling-phase1.md). TARGET DIRECTION: trends toward zero as recycle adoption rises; a flat or rising incidence with rising adoption falsifies the mechanism.",
77
+ "instrument": "session-eol state files (compactions[] counters) aggregated by session_eol_report; the marker-drift alarm in the same report guards the detector against silent host shape changes",
78
+ "threshold": "baseline 11.2%; direction-only target (down) until the review date"
79
+ },
80
+ "envelope_resume_success": {
81
+ "definition": "road-to-token-economy-recycling 3.4: successor sessions that completed the recycled task WITHOUT re-asking for state the envelope should have carried - i.e. the 2.1 not_carried_forward list staying honest (everything else was carried; the successor re-derived only what the list named).",
82
+ "instrument": "conformance audits over successor-session transcripts (the consumed envelope names the task; the audit checks the successor's first turns for state re-asks); HONEST GAP: no deterministic counter exists for 'had to re-ask' - this is audit-carried and registered as such",
83
+ "threshold": "none committed before data - baseline first, threshold at review date"
84
+ },
85
+ "post_recycle_verify_fail_vs_baseline": {
86
+ "definition": "road-to-token-economy-recycling 3.4, the falsifiable core: verify-fail rate of recycled successor sessions vs the long-session baseline. PUBLISH-IF-WORSE COMMITMENT, pre-registered before data exists: if recycled sessions verify WORSE, the result is published and the threshold (recycle-threshold-budget.json) or the envelope schema revises in a PR citing the numbers - the claim never survives on vibes.",
87
+ "instrument": "session-eol per-session state (recycled or not) joined with verify outcomes from conformance audits / review_skipped telemetry; HONEST GAP: transcripts carry no verify-outcome field, so the join is audit-carried until a verify-outcome counter ships",
88
+ "threshold": "comparison metric - no absolute threshold; verdict recorded at review date whichever way it went"
89
+ }
90
+ }
91
+ }
@@ -7,9 +7,10 @@
7
7
  "measurement_conditions": "npm pack --dry-run --json --ignore-scripts, run at the repo root on a clean checkout. `--ignore-scripts` means NO build runs, so dist/cli, dist/ui, dist/mcp and dist/hooks are absent and the figure covers only the TRACKED payload (src/scripts/, dist/agent-src/, dist/install/, docs/guidelines/, templates). That is deliberate: this gate is always-on for every PR, and the tracked content tree is exactly the surface that grows by accretion. The built artifact is ~5.4 MB larger and is gated separately, at release time, by evaluator-budgets.unpacked_size_mb.",
8
8
  "budgets": {
9
9
  "packed_size_mb": {
10
- "max": 6.9,
11
- "last_measured": 6.398,
10
+ "max": 7.8,
11
+ "last_measured": 7.238,
12
12
  "method": "npm pack --dry-run --json --ignore-scripts → dist.size / 1e6 (the compressed tarball a consumer actually downloads)",
13
+ "baseline_note_2026_08_10": "6.9 → 7.8 re-baselined 2026-08-10. WHICH OF THE TWO THIS IS, stated because the guard asks: a RATCHET RESET, not the config bent around a failing check — and the discriminator is that the payload is real and needed rather than that the check was inconvenient. The 44 KB is two source files a shipped instruction depends on, the cheaper alternative was examined and rejected on that ground (below), the new cap carries ~8% headroom over the higher of two disagreeing measurements rather than clearing by a hair, and the raise was put to the maintainer as a decision instead of applied to make a red go away. A reader who disagrees has everything needed to reverse it: the measurement, its method, the trip cause, and the rejected option. Maintainer-decided in the PR that tripped it, surfaced rather than smuggled — the same standing this file's `owner: maintainer` requires. MEASURED TWICE, and the two do not agree: CI reported 6.907 on this exact commit, a local run under the documented conditions reports 7.238. The 331 KB gap is UNEXPLAINED — the tree matches the pushed commit and only this file differs — so the cap is set over the HIGHER figure rather than the convenient one, and the discrepancy is recorded here as an open question instead of resolved by assumption. A third party reproducing this should expect either number and should not treat the lower one as authoritative. Separately, and this part IS understood: `npm pack --dry-run --ignore-scripts` in a worktree that has been BUILT reads 8.45, because the flag assumes dist/cli, dist/ui, dist/mcp and dist/hooks are absent and a built tree has them. That figure is not comparable to this budget and must never be written here — recorded because it is a trap the documented method invites. Trip cause: road-to-conformance-round5 Phase 3 added src/scripts/hooks/turn_end_gate_hook.ts (32 KB) and src/scripts/measure_turn_end_gate.ts (12 KB) in packed paths plus schema/template/contract growth, landing 7 KB over a 6.9 cap. Max set to 7.8 (~8% headroom over 7.238, and ~13% over CI's 6.907) for the reason the 2026-08-05 note already gives: a cap pinned just above the measurement reds on the next commit and teaches the reader to raise it again. ALTERNATIVE EXAMINED AND REJECTED, so it is not re-proposed: dropping measure_turn_end_gate.ts from the pack would have cleared the cap with room, but the settings description added in the same change instructs CONSUMERS to run that script against their own transcript store before arming the gate — excluding it would break a shipped instruction.",
13
14
  "baseline_note": "5.903 → 6.398 re-baselined 2026-08-05. This is a RE-BASELINE, not a carve-out for the change that tripped it: measured on the tracked tree, `origin/main` alone was already at 6.372 of a 6.4 cap, so 28 KB of headroom remained after months of accretion and the next legitimate addition of any size was going to cross it. The addition here is 26 KB — docs/contracts/settings-classes.md (the A/B/C fence, read at RUNTIME by the settings writer, so it must ship) plus src/server/io/yamlIO.ts (imported by that writer to preserve the user's comments). CI measures ~4 KB above the local figure because it regenerates dist/agent-src first. Max set to 6.9 rather than to a number that merely clears: a cap pinned 2 KB above the measurement reds on the next commit and teaches the reader to raise it again, which is how a budget becomes a formality. That restores the ~8% headroom the 5.903/6.4 pair originally carried. The `owner: maintainer` on this file stands — this raise is surfaced in the PR for that decision, not smuggled."
14
15
  }
15
16
  },
@@ -0,0 +1,12 @@
1
+ {
2
+ "_comment": "Committed recycle threshold (road-to-token-economy-recycling Phase 3.1). ONE threshold, ONE constant: statically imported into the session-eol Stop-slot concern (esbuild folds it into the hook bundle, so consumers carry the same value — no runtime file resolution). Changing it is a PR citing evidence, never a drive-by edit; AGENT_RECYCLE_THRESHOLD_TOKENS overrides per-process (tests + emergency off via 0).",
3
+ "schema_version": 1,
4
+ "registered_at": "2026-08-10",
5
+ "owner": "maintainer",
6
+ "review_by": "2026-11-10",
7
+ "unit": "parsed transcript tokens — billable input (input + cache_read + cache_creation) of the last main-chain assistant record, per cc_transcript.ts",
8
+ "recycle_threshold_tokens": 800000,
9
+ "derivation": "agents/evidence/analysis/token-economy-recycling-phase1.md — ~p90 of 201 measured session-final sizes (807,937), 54% above the median healthy session (519,349), 15% below the minimum observed auto-compact trigger (941,636). Every one of the 23 sessions that auto-compacted in the baseline would have been advised first.",
10
+ "known_limitation": "All observed auto-compactions were 1M-window sessions (190 of 201 sessions run on the 1M window on this store). A <=200k-window session auto-compacts near ~160-206k and is never served by this threshold — revisit at review_by; a window-aware threshold needs a window signal the transcript does not carry explicitly.",
11
+ "honest_null_consequence": "If adoption stays near zero or recycled sessions verify WORSE than the long-session baseline (the registered post_recycle_verify_fail_vs_baseline metric), the result is published and this threshold or the envelope schema revises by evidence in a PR — the claim never survives on vibes."
12
+ }
@@ -0,0 +1,86 @@
1
+ [
2
+ "active-remediation.md",
3
+ "agent-authority.md",
4
+ "analysis-skill-routing.md",
5
+ "architecture.md",
6
+ "artifact-drafting-protocol.md",
7
+ "artifact-engagement-recording.md",
8
+ "ask-when-uncertain.md",
9
+ "augment-edit-discipline.md",
10
+ "autonomous-execution.md",
11
+ "brand-consistency.md",
12
+ "brand-source-of-truth.md",
13
+ "broken-access-control.md",
14
+ "cli-output-handling.md",
15
+ "code-comment-discipline.md",
16
+ "command-suggestion-policy.md",
17
+ "commit-conventions.md",
18
+ "commit-policy.md",
19
+ "communication-through-line.md",
20
+ "content-quoting-floor.md",
21
+ "copilot-routing.md",
22
+ "cross-source-consistency.md",
23
+ "decision-revisit-gate.md",
24
+ "delegation-policy.md",
25
+ "design-fidelity.md",
26
+ "devcontainer-routing.md",
27
+ "direct-answers.md",
28
+ "doc-screenshot-hygiene.md",
29
+ "docker-commands.md",
30
+ "domain-adoption-policy.md",
31
+ "domain-safety-disclaimer.md",
32
+ "domain-safety-pii.md",
33
+ "domain-safety-retention.md",
34
+ "downstream-changes.md",
35
+ "engineering-safety-floor.md",
36
+ "external-code-graph-interop.md",
37
+ "external-reference-deep-dive.md",
38
+ "fast-path-marker-visibility.md",
39
+ "finance-safety-floor.md",
40
+ "guidelines.md",
41
+ "history-discipline.md",
42
+ "icon-consistency.md",
43
+ "image-likeness-and-rights.md",
44
+ "improve-before-implement.md",
45
+ "invite-challenge.md",
46
+ "laravel-routing.md",
47
+ "laravel-translations.md",
48
+ "legal-safety-floor.md",
49
+ "linked-projects-onboarding-gate.md",
50
+ "low-impact-corpus-privacy-floor.md",
51
+ "markdown-safe-codeblocks.md",
52
+ "media-sync-ground-truth.md",
53
+ "missing-tool-handling.md",
54
+ "model-recommendation.md",
55
+ "no-attribution-footers.md",
56
+ "no-cheap-questions.md",
57
+ "no-decorative-emojis-in-git-surfaces.md",
58
+ "no-pr-progress-comments.md",
59
+ "notes-first-reasoning.md",
60
+ "package-ci-checks.md",
61
+ "php-coding.md",
62
+ "prefer-enums-over-literals.md",
63
+ "provider-lifecycle-discipline.md",
64
+ "question-not-instruction.md",
65
+ "reviewer-awareness.md",
66
+ "roadmap-ci-steps-policy.md",
67
+ "role-mode-adherence.md",
68
+ "rule-type-governance.md",
69
+ "runtime-safety.md",
70
+ "scale-discipline.md",
71
+ "scope-control.md",
72
+ "senior-engineering-discipline.md",
73
+ "size-enforcement.md",
74
+ "skill-improvement-trigger.md",
75
+ "slash-command-routing-policy.md",
76
+ "source-discovery-gate.md",
77
+ "spreadsheet-source-quality.md",
78
+ "strategy-safety-floor.md",
79
+ "symfony-routing.md",
80
+ "think-before-action.md",
81
+ "token-budget-discipline.md",
82
+ "token-efficiency.md",
83
+ "upstream-proposal.md",
84
+ "user-interaction.md",
85
+ "user-interrupt-priority.md"
86
+ ]
@@ -41,6 +41,7 @@ import { readRecentEntries } from '../../install/txlog.js';
41
41
  import { detectToolPresence } from '../../install/detect.js';
42
42
  import { resolvePackageRoot } from '../_lib/package_root.js';
43
43
  import { routeTargetPathsPosix } from '../router_target_paths.mjs';
44
+ import { buildFunnel, render as renderFunnel } from '../report_conformance_funnel.js';
44
45
  import {
45
46
  _classify,
46
47
  _collect_manifest_entries,
@@ -532,16 +533,17 @@ export function appendConformanceReport(
532
533
 
533
534
  const USAGE =
534
535
  'usage: agent-config conformance [-h] [--project PROJECT] [--json]\n' +
535
- ' [--skip-dispatcher]\n';
536
+ ' [--skip-dispatcher] [--funnel]\n';
536
537
 
537
538
  interface Options {
538
539
  project: string | null;
539
540
  json: boolean;
540
541
  skip_dispatcher: boolean;
542
+ funnel: boolean;
541
543
  }
542
544
 
543
545
  function _parse(argv: string[]): Options {
544
- const opts: Options = { project: null, json: false, skip_dispatcher: false };
546
+ const opts: Options = { project: null, json: false, skip_dispatcher: false, funnel: false };
545
547
  let i = 0;
546
548
  while (i < argv.length) {
547
549
  const a = argv[i] as string;
@@ -551,6 +553,8 @@ function _parse(argv: string[]): Options {
551
553
  }
552
554
  if (a === '--json') {
553
555
  opts.json = true;
556
+ } else if (a === '--funnel') {
557
+ opts.funnel = true;
554
558
  } else if (a === '--skip-dispatcher') {
555
559
  opts.skip_dispatcher = true;
556
560
  } else if (a === '--project' || a.startsWith('--project=')) {
@@ -578,6 +582,17 @@ function _parse(argv: string[]): Options {
578
582
  function main(argv: string[] | null = null): number {
579
583
  const opts = _parse(argv !== null ? Array.from(argv) : process.argv.slice(2));
580
584
 
585
+ // `--funnel` — the delivery → activation → compliance report join
586
+ // (road-to-feedback-9-29 Phase 4.2). A REPORT, not a gate: it hangs off
587
+ // this verb so no new top-level verb enters the dispatcher registry, it
588
+ // skips the doctor/conformance legs entirely, and it always exits 0. It
589
+ // must never be wired into CI without a measured false-positive rate
590
+ // first — see the header of `report_conformance_funnel.ts`.
591
+ if (opts.funnel) {
592
+ print(renderFunnel(buildFunnel()));
593
+ return 0;
594
+ }
595
+
581
596
  let project_root: string;
582
597
  try {
583
598
  [project_root] = _resolve_project_root(opts.project);
@@ -0,0 +1,226 @@
1
+ /**
2
+ * `agent-config session:recycle` — write the main-session recycle envelope
3
+ * (road-to-token-economy-recycling Phase 2.2).
4
+ *
5
+ * The producer half of the deliberate session recycle: the model composes
6
+ * the envelope content it already knows (state, never a transcript
7
+ * summary), this command VALIDATES it against the main_session CHECKPOINT
8
+ * variant (`_lib/subagent_capsule.validateRecycleEnvelope`) and writes it
9
+ * atomically to `agents/runtime/state/recycle-envelope.json`, then prints
10
+ * the exact resume instruction. Deterministic — no model step in the write
11
+ * path; the only values this command fills are provenance it can resolve
12
+ * itself (`written_at` = now, `workspace` = project root,
13
+ * `capsule_version`/`variant` = the constants).
14
+ *
15
+ * Hooks cannot inject `/clear` (host limitation, roadmap Context) — the
16
+ * clear is the USER's action; the successor session's `handoff_context_hook`
17
+ * consumes the envelope at session_start (moved, not copied).
18
+ *
19
+ * Usage:
20
+ * agent-config session:recycle --file <envelope.json> # read from file
21
+ * agent-config session:recycle < envelope.json # read from stdin
22
+ * agent-config session:recycle --template # print a skeleton
23
+ *
24
+ * Exit codes: 0 written (or template printed) · 1 invalid / refused · 2 usage.
25
+ */
26
+
27
+ import * as fs from 'node:fs';
28
+ import * as path from 'node:path';
29
+ import process from 'node:process';
30
+ import { fileURLToPath, pathToFileURL } from 'node:url';
31
+
32
+ import { resolve_project_root } from '../_lib/agent_settings.js';
33
+ import {
34
+ RECYCLE_ENVELOPE_MAX_BYTES,
35
+ RECYCLE_ENVELOPE_REL,
36
+ } from '../_lib/recycle_envelope_paths.js';
37
+ import {
38
+ CAPSULE_SCHEMA_VERSION,
39
+ validateRecycleEnvelope,
40
+ } from '../_lib/subagent_capsule.js';
41
+ import { atomic_write_json } from '../hooks/state_io.js';
42
+
43
+ export interface RecycleResult {
44
+ code: 0 | 1 | 2;
45
+ out: string[];
46
+ err: string[];
47
+ }
48
+
49
+ /** Skeleton the model fills — every list ships empty, nothing is invented. */
50
+ export function templateEnvelope(): Record<string, unknown> {
51
+ return {
52
+ capsule_version: CAPSULE_SCHEMA_VERSION,
53
+ variant: 'main_session',
54
+ summary: '<one- or two-sentence outcome so far>',
55
+ task: '<the active task, one line>',
56
+ acceptance_criteria: ['<what done means, one line each>'],
57
+ remaining: ['<open work, one line each>'],
58
+ not_carried_forward: ['<what the successor must re-derive from source>'],
59
+ decisions: ['<decision — one-line rationale>'],
60
+ constraints: ['<binding constraint>'],
61
+ open_worker_envelopes: [],
62
+ artifact_paths: ['<path to a deliverable / note / evidence file>'],
63
+ assumptions: [],
64
+ };
65
+ }
66
+
67
+ interface ParsedArgv {
68
+ ok: boolean;
69
+ message?: string;
70
+ file?: string;
71
+ template?: boolean;
72
+ }
73
+
74
+ export function parseArgv(argv: readonly string[]): ParsedArgv {
75
+ const parsed: ParsedArgv = { ok: true };
76
+ for (let i = 0; i < argv.length; i += 1) {
77
+ const a = argv[i] as string;
78
+ if (a === '--template') {
79
+ parsed.template = true;
80
+ } else if (a === '--file') {
81
+ const value = argv[i + 1];
82
+ if (!value) return { ok: false, message: '--file requires a path' };
83
+ parsed.file = value;
84
+ i += 1;
85
+ } else if (a === '-h' || a === '--help') {
86
+ return { ok: false, message: 'usage' };
87
+ } else {
88
+ return { ok: false, message: `unknown argument: ${a}` };
89
+ }
90
+ }
91
+ return parsed;
92
+ }
93
+
94
+ /**
95
+ * Validate + write. `input` is the raw JSON text the model composed;
96
+ * provenance fields this command can resolve itself are filled when absent,
97
+ * then the STRICT validator decides.
98
+ */
99
+ export function runSessionRecycle(
100
+ input: string,
101
+ opts: { cwd: string; now?: Date },
102
+ ): RecycleResult {
103
+ const out: string[] = [];
104
+ const err: string[] = [];
105
+ const [projectRoot] = resolve_project_root(null, { cwd: opts.cwd });
106
+
107
+ let parsed: unknown;
108
+ try {
109
+ parsed = JSON.parse(input);
110
+ } catch (exc) {
111
+ return { code: 1, out, err: [`envelope is not valid JSON: ${String(exc)}`] };
112
+ }
113
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
114
+ return { code: 1, out, err: ['envelope must be a JSON object'] };
115
+ }
116
+ const envelope = parsed as Record<string, unknown>;
117
+
118
+ // Deterministic provenance — filled only when the composer left them out.
119
+ if (envelope['capsule_version'] === undefined) envelope['capsule_version'] = CAPSULE_SCHEMA_VERSION;
120
+ if (envelope['variant'] === undefined) envelope['variant'] = 'main_session';
121
+ if (envelope['written_at'] === undefined) {
122
+ envelope['written_at'] = (opts.now ?? new Date()).toISOString();
123
+ }
124
+ if (envelope['workspace'] === undefined) envelope['workspace'] = projectRoot;
125
+
126
+ const violations = validateRecycleEnvelope(envelope);
127
+ if (violations.length > 0) {
128
+ return {
129
+ code: 1,
130
+ out,
131
+ err: ['recycle envelope refused — schema violations:', ...violations.map((v) => ` - ${v}`)],
132
+ };
133
+ }
134
+
135
+ const serialized = JSON.stringify(envelope, null, 2);
136
+ const bytes = Buffer.byteLength(serialized, 'utf-8');
137
+ if (bytes > RECYCLE_ENVELOPE_MAX_BYTES) {
138
+ return {
139
+ code: 1,
140
+ out,
141
+ err: [
142
+ `recycle envelope refused — ${bytes} bytes > ${RECYCLE_ENVELOPE_MAX_BYTES} byte cap.`,
143
+ 'An envelope is selection and pointers, not a dump: move detail into artifact',
144
+ 'files and reference them via artifact_paths.',
145
+ ],
146
+ };
147
+ }
148
+
149
+ const target = path.join(projectRoot, RECYCLE_ENVELOPE_REL);
150
+ try {
151
+ atomic_write_json(target, envelope);
152
+ } catch (exc) {
153
+ return { code: 1, out, err: [`could not write ${target}: ${String(exc)}`] };
154
+ }
155
+
156
+ out.push(`recycle envelope written — ${RECYCLE_ENVELOPE_REL} (${bytes} bytes)`);
157
+ out.push('');
158
+ out.push('Resume instruction:');
159
+ out.push(' 1. End this session now: run /clear (or start a fresh session in this workspace).');
160
+ out.push(' 2. The successor session receives the envelope automatically at session_start');
161
+ out.push(' (injected once as DATA, then consumed — moved, not copied).');
162
+ out.push(' 3. The successor re-derives everything on the not_carried_forward list from');
163
+ out.push(' source before trusting it.');
164
+ return { code: 0, out, err };
165
+ }
166
+
167
+ export function main(argv: string[] = process.argv.slice(2)): number {
168
+ const parsed = parseArgv(argv);
169
+ if (!parsed.ok) {
170
+ const usage = [
171
+ 'usage: agent-config session:recycle [--file <envelope.json>] [--template]',
172
+ ' --file <path> read the envelope JSON from a file (default: stdin)',
173
+ ' --template print a skeleton envelope and exit',
174
+ ].join('\n');
175
+ if (parsed.message === 'usage') {
176
+ process.stdout.write(`${usage}\n`);
177
+ return 0;
178
+ }
179
+ process.stderr.write(`${parsed.message}\n${usage}\n`);
180
+ return 2;
181
+ }
182
+
183
+ if (parsed.template) {
184
+ process.stdout.write(`${JSON.stringify(templateEnvelope(), null, 2)}\n`);
185
+ return 0;
186
+ }
187
+
188
+ let input: string;
189
+ try {
190
+ if (parsed.file) {
191
+ input = fs.readFileSync(parsed.file, 'utf-8');
192
+ } else if (process.stdin.isTTY) {
193
+ process.stderr.write('no envelope on stdin and no --file given (see --help)\n');
194
+ return 2;
195
+ } else {
196
+ input = fs.readFileSync(0, 'utf-8');
197
+ }
198
+ } catch (exc) {
199
+ process.stderr.write(`could not read envelope input: ${String(exc)}\n`);
200
+ return 2;
201
+ }
202
+
203
+ const result = runSessionRecycle(input, { cwd: process.cwd() });
204
+ for (const line of result.out) process.stdout.write(`${line}\n`);
205
+ for (const line of result.err) process.stderr.write(`${line}\n`);
206
+ return result.code;
207
+ }
208
+
209
+ // Bundle-safety: never auto-run when inlined into an esbuild bundle.
210
+ declare const __AGENT_CONFIG_BUNDLE__: boolean | undefined;
211
+ function _isCliEntry(): boolean {
212
+ if (typeof __AGENT_CONFIG_BUNDLE__ !== 'undefined' && __AGENT_CONFIG_BUNDLE__) return false;
213
+ if (process.argv[1] === undefined) return false;
214
+ if (import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) return true;
215
+ try {
216
+ return (
217
+ fs.realpathSync(fileURLToPath(import.meta.url)) === fs.realpathSync(path.resolve(process.argv[1]))
218
+ );
219
+ } catch {
220
+ return false;
221
+ }
222
+ }
223
+
224
+ if (_isCliEntry()) {
225
+ process.exit(main());
226
+ }
@@ -132,6 +132,19 @@ export function build(project_root: string): Record<string, unknown> | null {
132
132
  rule_loading_tier = null;
133
133
  }
134
134
  let rule_loading_tier_source = _pyTruthy(rule_loading_tier) ? 'user' : 'default';
135
+ // The one read-site divergence from the template that is NOT a
136
+ // `settingsCarveOut` row, so it is explained here instead
137
+ // (`road-to-scripts-settings-defaults` Phase 1, § 2 of the Evidence Report).
138
+ // The template ships `rule_loading_tier: __RULE_LOADING_TIER__` — an
139
+ // installer placeholder, not a value — so the template-defaults layer in
140
+ // `load_agent_settings` deliberately does not inject it and an absent key
141
+ // arrives here as `undefined`. `balanced` is therefore this reader's own
142
+ // default, matching what the installer substitutes.
143
+ // The second arm is the deliberate part: a settings file that still
144
+ // literally contains the placeholder is a BROKEN install, and this reports
145
+ // it as `source: default` — i.e. the trace looks healthy. Surfacing it
146
+ // instead would be a reporting change beyond this roadmap's scope; it is
147
+ // recorded rather than silently kept.
135
148
  if (!_pyTruthy(rule_loading_tier) || rule_loading_tier === '__RULE_LOADING_TIER__') {
136
149
  rule_loading_tier = _DEFAULT_RULE_LOADING_TIER;
137
150
  rule_loading_tier_source = 'default';
@@ -197,10 +197,17 @@ Tier 2 — maintenance / internal (hooks, MCP, memory, telemetry):
197
197
  session register). Flags: --json
198
198
  sessions:claim Claim a roadmap for this session so other sessions skip
199
199
  it; --release clears the claim
200
+ session:recycle Validate + write the main-session recycle envelope
201
+ (deliberate recycle instead of auto-compact). Flags:
202
+ --file <json> | --template; default reads stdin
200
203
  roadmap:progress Regenerate agents/roadmaps-progress.md from open roadmaps
201
204
  roadmap:progress-check Fail if agents/roadmaps-progress.md is stale (for CI)
202
205
  roadmap:archive Archive completed roadmaps (branch-touched by default;
203
206
  --all for every complete one; --dry-run to preview)
207
+ gates Open decisions that need you, rendered as actions —
208
+ roadmap blockers filtered by owner, most-unblocking
209
+ first. Flags: --all (include maintainer/external),
210
+ --json
204
211
  capabilities:index Regenerate CAPABILITIES.yaml — the package coverage index
205
212
  (capability area → coverage → backing skills/commands → gaps).
206
213
  Pass --check to fail if stale (for CI). Reads src/ (package repo).
@@ -614,6 +621,14 @@ cmd_sessions_claim() {
614
621
  exec_ts "$PACKAGE_ROOT/src/scripts/sessions_cli.ts" claim "$@"
615
622
  }
616
623
 
624
+ # Main-session recycle envelope producer (road-to-token-economy-recycling
625
+ # Phase 2.2). PACKAGE_ROOT: imports src/scripts/_lib/ (capsule schema) and
626
+ # src/scripts/hooks/state_io.ts, which are never projected into
627
+ # dist/agent-src/scripts/.
628
+ cmd_session_recycle() {
629
+ exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_session_recycle.ts" "$@"
630
+ }
631
+
617
632
  # Capability probes (road-to-capability-answerability). All three resolve from
618
633
  # PACKAGE_ROOT rather than the consumer projection: each imports package-internal
619
634
  # libraries under src/scripts/_lib/ or src/shared/, which are never projected into
@@ -654,6 +669,12 @@ cmd_roadmap_archive() {
654
669
  exec_ts "$script" "$@"
655
670
  }
656
671
 
672
+ cmd_gates() {
673
+ local script
674
+ script="$(resolve_script "dist/agent-src/scripts/roadmap_gates.ts" ".augment/scripts/roadmap_gates.ts")"
675
+ exec_ts "$script" "$@"
676
+ }
677
+
657
678
  cmd_capabilities_index() {
658
679
  local script
659
680
  script="$(resolve_script "src/scripts/generate_capabilities_index.ts")"
@@ -1320,6 +1341,7 @@ main() {
1320
1341
  conformance:behavior) cmd_conformance_behavior "$@" ;;
1321
1342
  sessions:list) cmd_sessions_list "$@" ;;
1322
1343
  sessions:claim) cmd_sessions_claim "$@" ;;
1344
+ session:recycle) cmd_session_recycle "$@" ;;
1323
1345
  packs:active) cmd_packs_active "$@" ;;
1324
1346
  settings:get) cmd_settings_get "$@" ;;
1325
1347
  mcp:available) cmd_mcp_available "$@" ;;
@@ -1327,6 +1349,7 @@ main() {
1327
1349
  roadmap:progress) cmd_roadmap_progress "$@" ;;
1328
1350
  roadmap:progress-check) cmd_roadmap_progress_check "$@" ;;
1329
1351
  roadmap:archive) cmd_roadmap_archive "$@" ;;
1352
+ gates) cmd_gates "$@" ;;
1330
1353
  capabilities:index) cmd_capabilities_index "$@" ;;
1331
1354
  hooks:install) cmd_hooks_install "$@" ;;
1332
1355
  keys:install-anthropic) cmd_keys_install_anthropic "$@" ;;