@dzhechkov/harness-core 0.8.10 → 0.8.20

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 (251) hide show
  1. package/.dz-manifest.json +490 -170
  2. package/LICENSE +13 -0
  3. package/README.md +420 -6
  4. package/dist/agents-policy.d.ts +15 -1
  5. package/dist/agents-policy.d.ts.map +1 -1
  6. package/dist/agents-policy.js +27 -1
  7. package/dist/agents-policy.js.map +1 -1
  8. package/dist/amendment-trace.d.ts +72 -0
  9. package/dist/amendment-trace.d.ts.map +1 -1
  10. package/dist/amendment-trace.js +385 -17
  11. package/dist/amendment-trace.js.map +1 -1
  12. package/dist/backlog-public.d.ts +153 -0
  13. package/dist/backlog-public.d.ts.map +1 -0
  14. package/dist/backlog-public.js +415 -0
  15. package/dist/backlog-public.js.map +1 -0
  16. package/dist/backlog-transitions.d.ts +48 -0
  17. package/dist/backlog-transitions.d.ts.map +1 -0
  18. package/dist/backlog-transitions.js +64 -0
  19. package/dist/backlog-transitions.js.map +1 -0
  20. package/dist/backlog.d.ts.map +1 -1
  21. package/dist/backlog.js +13 -0
  22. package/dist/backlog.js.map +1 -1
  23. package/dist/claim-check.d.ts.map +1 -1
  24. package/dist/claim-check.js +24 -2
  25. package/dist/claim-check.js.map +1 -1
  26. package/dist/claude-hooks-assets.d.ts +93 -0
  27. package/dist/claude-hooks-assets.d.ts.map +1 -0
  28. package/dist/claude-hooks-assets.js +208 -0
  29. package/dist/claude-hooks-assets.js.map +1 -0
  30. package/dist/clean-room-smoke.d.ts +83 -0
  31. package/dist/clean-room-smoke.d.ts.map +1 -0
  32. package/dist/clean-room-smoke.js +138 -0
  33. package/dist/clean-room-smoke.js.map +1 -0
  34. package/dist/cmd-usage.d.ts.map +1 -1
  35. package/dist/cmd-usage.js +36 -6
  36. package/dist/cmd-usage.js.map +1 -1
  37. package/dist/codex-hooks-assets.d.ts +25 -7
  38. package/dist/codex-hooks-assets.d.ts.map +1 -1
  39. package/dist/codex-hooks-assets.js +138 -30
  40. package/dist/codex-hooks-assets.js.map +1 -1
  41. package/dist/codex-hooks.d.ts +21 -1
  42. package/dist/codex-hooks.d.ts.map +1 -1
  43. package/dist/codex-hooks.js +21 -1
  44. package/dist/codex-hooks.js.map +1 -1
  45. package/dist/codex-invoke.d.ts +73 -0
  46. package/dist/codex-invoke.d.ts.map +1 -0
  47. package/dist/codex-invoke.js +80 -0
  48. package/dist/codex-invoke.js.map +1 -0
  49. package/dist/course-staleness.d.ts +19 -0
  50. package/dist/course-staleness.d.ts.map +1 -0
  51. package/dist/course-staleness.js +95 -0
  52. package/dist/course-staleness.js.map +1 -0
  53. package/dist/destructive-guard-hook.d.ts +40 -0
  54. package/dist/destructive-guard-hook.d.ts.map +1 -0
  55. package/dist/destructive-guard-hook.js +109 -0
  56. package/dist/destructive-guard-hook.js.map +1 -0
  57. package/dist/destructive-guard.d.ts +27 -0
  58. package/dist/destructive-guard.d.ts.map +1 -0
  59. package/dist/destructive-guard.js +2808 -0
  60. package/dist/destructive-guard.js.map +1 -0
  61. package/dist/discrimination-gate.d.ts +88 -3
  62. package/dist/discrimination-gate.d.ts.map +1 -1
  63. package/dist/discrimination-gate.js +173 -16
  64. package/dist/discrimination-gate.js.map +1 -1
  65. package/dist/event-chain.d.ts +30 -0
  66. package/dist/event-chain.d.ts.map +1 -1
  67. package/dist/event-chain.js +24 -0
  68. package/dist/event-chain.js.map +1 -1
  69. package/dist/feature-adr-routing.d.ts +95 -1
  70. package/dist/feature-adr-routing.d.ts.map +1 -1
  71. package/dist/feature-adr-routing.js +193 -27
  72. package/dist/feature-adr-routing.js.map +1 -1
  73. package/dist/guard.d.ts +98 -0
  74. package/dist/guard.d.ts.map +1 -1
  75. package/dist/guard.js +308 -0
  76. package/dist/guard.js.map +1 -1
  77. package/dist/harness-core-location.d.ts +18 -0
  78. package/dist/harness-core-location.d.ts.map +1 -0
  79. package/dist/harness-core-location.js +42 -0
  80. package/dist/harness-core-location.js.map +1 -0
  81. package/dist/index.d.ts +32 -11
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +32 -7
  84. package/dist/index.js.map +1 -1
  85. package/dist/lead-shift-gate.d.ts +95 -0
  86. package/dist/lead-shift-gate.d.ts.map +1 -0
  87. package/dist/lead-shift-gate.js +100 -0
  88. package/dist/lead-shift-gate.js.map +1 -0
  89. package/dist/ledger-backfill.d.ts +11 -1
  90. package/dist/ledger-backfill.d.ts.map +1 -1
  91. package/dist/ledger-backfill.js +19 -0
  92. package/dist/ledger-backfill.js.map +1 -1
  93. package/dist/loop-blobs.generated.d.ts +1 -1
  94. package/dist/loop-blobs.generated.d.ts.map +1 -1
  95. package/dist/loop-blobs.generated.js +12 -3
  96. package/dist/loop-blobs.generated.js.map +1 -1
  97. package/dist/loop-lint.d.ts.map +1 -1
  98. package/dist/loop-lint.js +56 -7
  99. package/dist/loop-lint.js.map +1 -1
  100. package/dist/loop-plan-graph.d.ts +1 -3
  101. package/dist/loop-plan-graph.d.ts.map +1 -1
  102. package/dist/loop-plan-graph.js +70 -1
  103. package/dist/loop-plan-graph.js.map +1 -1
  104. package/dist/loop-trace.d.ts.map +1 -1
  105. package/dist/loop-trace.js +16 -2
  106. package/dist/loop-trace.js.map +1 -1
  107. package/dist/managed-hooks.d.ts +5 -6
  108. package/dist/managed-hooks.d.ts.map +1 -1
  109. package/dist/managed-hooks.js +2 -2
  110. package/dist/managed-hooks.js.map +1 -1
  111. package/dist/model-recommender.d.ts.map +1 -1
  112. package/dist/model-recommender.js +14 -3
  113. package/dist/model-recommender.js.map +1 -1
  114. package/dist/mutation-gate.d.ts +39 -36
  115. package/dist/mutation-gate.d.ts.map +1 -1
  116. package/dist/mutation-gate.js +111 -5
  117. package/dist/mutation-gate.js.map +1 -1
  118. package/dist/operations.d.ts.map +1 -1
  119. package/dist/operations.js +90 -5
  120. package/dist/operations.js.map +1 -1
  121. package/dist/patterns.d.ts +23 -0
  122. package/dist/patterns.d.ts.map +1 -1
  123. package/dist/patterns.js +10 -0
  124. package/dist/patterns.js.map +1 -1
  125. package/dist/plugin.d.ts.map +1 -1
  126. package/dist/plugin.js +27 -5
  127. package/dist/plugin.js.map +1 -1
  128. package/dist/publish.d.ts +11 -0
  129. package/dist/publish.d.ts.map +1 -1
  130. package/dist/publish.js +16 -2
  131. package/dist/publish.js.map +1 -1
  132. package/dist/recommend.d.ts +4 -5
  133. package/dist/recommend.d.ts.map +1 -1
  134. package/dist/recommend.js +110 -45
  135. package/dist/recommend.js.map +1 -1
  136. package/dist/registry.d.ts +32 -1
  137. package/dist/registry.d.ts.map +1 -1
  138. package/dist/registry.js +168 -11
  139. package/dist/registry.js.map +1 -1
  140. package/dist/run-records.d.ts +3 -0
  141. package/dist/run-records.d.ts.map +1 -1
  142. package/dist/run-records.js +18 -0
  143. package/dist/run-records.js.map +1 -1
  144. package/dist/score.d.ts +95 -0
  145. package/dist/score.d.ts.map +1 -1
  146. package/dist/score.js +289 -6
  147. package/dist/score.js.map +1 -1
  148. package/dist/session-retro.d.ts +121 -2
  149. package/dist/session-retro.d.ts.map +1 -1
  150. package/dist/session-retro.js +454 -11
  151. package/dist/session-retro.js.map +1 -1
  152. package/dist/setup.d.ts +28 -0
  153. package/dist/setup.d.ts.map +1 -1
  154. package/dist/setup.js +223 -6
  155. package/dist/setup.js.map +1 -1
  156. package/dist/sign.d.ts.map +1 -1
  157. package/dist/sign.js +18 -1
  158. package/dist/sign.js.map +1 -1
  159. package/dist/skill-selection.d.ts +72 -0
  160. package/dist/skill-selection.d.ts.map +1 -0
  161. package/dist/skill-selection.js +76 -0
  162. package/dist/skill-selection.js.map +1 -0
  163. package/dist/skills-verify.d.ts +34 -1
  164. package/dist/skills-verify.d.ts.map +1 -1
  165. package/dist/skills-verify.js +82 -0
  166. package/dist/skills-verify.js.map +1 -1
  167. package/dist/stage-line.d.ts +68 -0
  168. package/dist/stage-line.d.ts.map +1 -0
  169. package/dist/stage-line.js +129 -0
  170. package/dist/stage-line.js.map +1 -0
  171. package/dist/statusline.d.ts +99 -0
  172. package/dist/statusline.d.ts.map +1 -1
  173. package/dist/statusline.js +310 -44
  174. package/dist/statusline.js.map +1 -1
  175. package/dist/stem.d.ts +12 -0
  176. package/dist/stem.d.ts.map +1 -0
  177. package/dist/stem.js +89 -0
  178. package/dist/stem.js.map +1 -0
  179. package/dist/store-counts.d.ts +26 -0
  180. package/dist/store-counts.d.ts.map +1 -0
  181. package/dist/store-counts.js +125 -0
  182. package/dist/store-counts.js.map +1 -0
  183. package/dist/store-guard.d.ts +106 -0
  184. package/dist/store-guard.d.ts.map +1 -0
  185. package/dist/store-guard.js +294 -0
  186. package/dist/store-guard.js.map +1 -0
  187. package/dist/swarm-brief.d.ts +95 -0
  188. package/dist/swarm-brief.d.ts.map +1 -0
  189. package/dist/swarm-brief.js +660 -0
  190. package/dist/swarm-brief.js.map +1 -0
  191. package/dist/telemetry-vocabulary.d.ts +7 -0
  192. package/dist/telemetry-vocabulary.d.ts.map +1 -1
  193. package/dist/telemetry-vocabulary.js +29 -0
  194. package/dist/telemetry-vocabulary.js.map +1 -1
  195. package/dist/trace-bundle.d.ts +8 -0
  196. package/dist/trace-bundle.d.ts.map +1 -1
  197. package/dist/trace-bundle.js +11 -0
  198. package/dist/trace-bundle.js.map +1 -1
  199. package/package.json +10 -9
  200. package/sbom.json +1033 -233
  201. package/src/agents-policy.ts +46 -2
  202. package/src/amendment-trace.ts +441 -19
  203. package/src/backlog-public.ts +503 -0
  204. package/src/backlog-transitions.ts +77 -0
  205. package/src/backlog.ts +12 -0
  206. package/src/claim-check.ts +25 -2
  207. package/src/claude-hooks-assets.ts +227 -0
  208. package/src/clean-room-smoke.ts +195 -0
  209. package/src/cmd-usage.ts +29 -5
  210. package/src/codex-hooks-assets.ts +140 -30
  211. package/src/codex-hooks.ts +21 -1
  212. package/src/codex-invoke.ts +138 -0
  213. package/src/course-staleness.ts +125 -0
  214. package/src/destructive-guard-hook.ts +151 -0
  215. package/src/destructive-guard.ts +3027 -0
  216. package/src/discrimination-gate.ts +262 -19
  217. package/src/event-chain.ts +41 -0
  218. package/src/feature-adr-routing.ts +220 -22
  219. package/src/guard.ts +358 -0
  220. package/src/harness-core-location.ts +44 -0
  221. package/src/index.ts +121 -7
  222. package/src/lead-shift-gate.ts +145 -0
  223. package/src/ledger-backfill.ts +20 -1
  224. package/src/loop-blobs.generated.ts +12 -3
  225. package/src/loop-lint.ts +52 -7
  226. package/src/loop-plan-graph.ts +66 -1
  227. package/src/loop-trace.ts +13 -1
  228. package/src/managed-hooks.ts +5 -6
  229. package/src/model-recommender.ts +14 -3
  230. package/src/mutation-gate.ts +165 -5
  231. package/src/operations.ts +83 -5
  232. package/src/patterns.ts +33 -0
  233. package/src/plugin.ts +27 -5
  234. package/src/publish.ts +27 -2
  235. package/src/recommend.ts +116 -46
  236. package/src/registry.ts +147 -13
  237. package/src/run-records.ts +23 -0
  238. package/src/score.ts +377 -7
  239. package/src/session-retro.ts +466 -11
  240. package/src/setup.ts +246 -9
  241. package/src/sign.ts +18 -1
  242. package/src/skill-selection.ts +111 -0
  243. package/src/skills-verify.ts +99 -1
  244. package/src/stage-line.ts +151 -0
  245. package/src/statusline.ts +396 -47
  246. package/src/stem.ts +87 -0
  247. package/src/store-counts.ts +154 -0
  248. package/src/store-guard.ts +388 -0
  249. package/src/swarm-brief.ts +661 -0
  250. package/src/telemetry-vocabulary.ts +36 -0
  251. package/src/trace-bundle.ts +10 -0
@@ -0,0 +1,151 @@
1
+ /**
2
+ * stage-line-before-dispatch — the two-phase stage announcement renderer used by feature-adr
3
+ * dispatch points (historical feature name `stage-line-before-dispatch`, ADR-001). The workflow's
4
+ * sole dispatch seam prints an intent line before the runtime call and a distinct final outcome
5
+ * line after the same attempt settles.
6
+ *
7
+ * WHY this file is standalone and import-free: the workflow script runs in a sandbox with no
8
+ * imports, so this module is projected into `.claude/workflows/feature-adr.js` VERBATIM by
9
+ * `scripts/gen-loop-blobs.mjs` (blob `stage-line`) and byte-checked there by
10
+ * `loop-blobs-regen.test.ts`. The generator FAILS CLOSED on any cross-file import, so the decision
11
+ * shape below is declared STRUCTURALLY here rather than imported from `feature-adr-routing.ts`.
12
+ *
13
+ * The line is PURE TEXT ASSEMBLY: every field comes from the decision the resolver returned or from
14
+ * the constant label table below. No model ever writes a word of it (AC-6), it reads nothing, and it
15
+ * prints nothing — the caller does the printing (AC-3).
16
+ *
17
+ * DESIGN CONSTRAINT (shared with feature-adr-routing.ts): the Workflow parser is stricter than
18
+ * `node --check` — string `+` concatenation only, explicit `if`/`return`, object-literal tables.
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+
23
+ /** Blob version stamp read by scripts/gen-loop-blobs.mjs; bump on any semantic change here. */
24
+ export const STAGE_LINE_BLOB_VERSION = '2.0.0';
25
+
26
+ /**
27
+ * The decision shape `renderStageLine` consumes — structurally identical to
28
+ * `StageDecision` from `feature-adr-routing.ts`, declared locally because a cross-file import
29
+ * would make this file unprojectable into the sandboxed workflow (see the file header).
30
+ */
31
+ export interface StageLineDecision {
32
+ readonly opts: { readonly agentType?: string; readonly model?: string };
33
+ readonly spec: string | null;
34
+ readonly reason: string;
35
+ }
36
+
37
+ export type StageLineOutcomeState = 'dispatched' | 'probe-failed' | 'refused-before-dispatch';
38
+
39
+ /** Final state of this exact rung. Selection reasons never travel through this shape. */
40
+ export interface StageLineOutcome {
41
+ readonly state: StageLineOutcomeState;
42
+ readonly reason: string | null;
43
+ }
44
+
45
+ /**
46
+ * Human signature per resolver branch — a CLOSED table over `StageDecisionReason`. A reason with no
47
+ * entry is a hole, and `stage-line.test.ts` proves the table has none: a newcomer reading `· ` and
48
+ * then a raw enum token learns nothing, which is the whole failure this feature exists to prevent.
49
+ */
50
+ export const STAGE_LINE_REASON_LABELS: Record<string, string> = {
51
+ 'usage-override': 'usage override (Claude limit pressure)',
52
+ 'explicit-models': 'explicit args.models',
53
+ 'routing-not-requested': 'routing not requested',
54
+ 'coder-knob-codex': 'coder knob = codex',
55
+ 'planner-knob-codex': 'planner knob = codex',
56
+ 'qe-cross-family': 'cross-family QE (the coder never self-reviews)',
57
+ 'budget-table-cell': 'budget table cell',
58
+ 'default-models': 'default models table',
59
+ 'codex-id-substituted': 'unknown codex id — substituted',
60
+ 'spec-unrecognised': 'unrecognised spec — session-inherited',
61
+ // dispatch-level (11-20): what the runtime or current fallback selection did.
62
+ 'coder-fallback': 'coder fallback ladder',
63
+ 'codex-unsupported-at-dispatch': 'codex unsupported at this dispatch — Claude',
64
+ 'fallback-after-no-deliverable': 'fallback — the previous rung delivered nothing',
65
+ 'precision-second-pass': 'independent precision second pass',
66
+ 'auto-cost': 'learned-cost routing',
67
+ 'qe-same-family-degraded': 'same-family QE — cross-family review NOT obtained',
68
+ 'challenge-panel': 'adversarial plan-gate panel',
69
+ 'codex-probe-failed': 'codex probe found no usable id — Claude',
70
+ 'codex-refused-before-dispatch': 'codex refused before dispatching — nothing ran',
71
+ 'fallback-rung': 'fallback rung (prior outcome reported separately)',
72
+ };
73
+
74
+ /** Stages that write an artifact FILE out of band when they resolve to Codex, and therefore wait on
75
+ * the Codex-landed barrier before their consumer runs. Naming it in the line tells the reader why
76
+ * the run is about to sit still.
77
+ *
78
+ * The four DESIGN stages belong here too (R4-F5, cross-family review round 3): `designStage` runs an
79
+ * out-of-band artifact probe for any codex-resolved design stage, exactly as code and plan do, so a
80
+ * roster of only {code, plan} left the line silent about a barrier that was actually engaged. QE is
81
+ * deliberately absent — its codex path is a synchronous `codex exec`, not the wrapper — and so is
82
+ * delivery, whose planes never run on codex at all. */
83
+ export const STAGE_LINE_BARRIER_STAGES: Record<string, number> = {
84
+ code: 1,
85
+ plan: 1,
86
+ requirements: 1,
87
+ adr: 1,
88
+ ideation: 1,
89
+ architecture: 1,
90
+ };
91
+
92
+ /**
93
+ * One deterministic line: `▸ <stage> · <model or "session"> · <branch signature>`, plus
94
+ * ` · landed barrier` when this stage resolved to Codex AND uses the barrier.
95
+ *
96
+ * PURE: reads nothing, prints nothing, and depends on no state beyond its two arguments (AC-3).
97
+ */
98
+ function renderStagePrefix(stage: string, decision: StageLineDecision): string {
99
+ let model = 'session';
100
+ if (decision && decision.spec) model = decision.spec;
101
+ return '▸ ' + stage + ' · ' + model;
102
+ }
103
+
104
+ /** Timely statement of what the workflow is about to try. It is explicitly not proof of dispatch. */
105
+ export function renderStageIntentLine(stage: string, decision: StageLineDecision): string {
106
+ let signature = '';
107
+ if (decision) {
108
+ const labelled = STAGE_LINE_REASON_LABELS[decision.reason];
109
+ if (labelled) signature = labelled;
110
+ }
111
+ // An unlabelled reason must be VISIBLE, never silently blank: print the raw token so the hole is
112
+ // reportable from a real run instead of reading as "no reason at all".
113
+ if (!signature) {
114
+ signature = 'unlabelled branch';
115
+ if (decision && decision.reason) signature = 'unlabelled branch: ' + decision.reason;
116
+ }
117
+ let line = renderStagePrefix(stage, decision) + ' · ' + signature;
118
+ if (STAGE_LINE_BARRIER_STAGES[stage] && decision && decision.opts && decision.opts.agentType === 'codex:codex-rescue') {
119
+ line = line + ' · landed barrier';
120
+ }
121
+ return line + ' · intent';
122
+ }
123
+
124
+ /**
125
+ * Final fact for one rung. It deliberately ignores the selection reason: the outcome owns only
126
+ * this rung's state and refusal detail, so another rung's reason cannot leak into it.
127
+ */
128
+ export function renderStageOutcomeLine(
129
+ stage: string,
130
+ decision: StageLineDecision,
131
+ outcome: StageLineOutcome,
132
+ ): string {
133
+ let model = 'session';
134
+ if (decision && decision.spec) model = decision.spec;
135
+ let label = 'dispatched';
136
+ if (outcome && outcome.state === 'probe-failed') label = 'probe found no usable model';
137
+ else if (outcome && outcome.state === 'refused-before-dispatch') label = 'refused before dispatch';
138
+ let line = '◆ ' + stage + ' · ' + model + ' · outcome: ' + label;
139
+ if (outcome && outcome.state === 'refused-before-dispatch' && outcome.reason === 'codex-unsupported-at-dispatch') {
140
+ line = line + ' · codex agent type unsupported';
141
+ } else if (outcome && outcome.state === 'refused-before-dispatch' && outcome.reason) {
142
+ line = line + ' · reason: ' + outcome.reason;
143
+ }
144
+ return line;
145
+ }
146
+
147
+ /** One-release compatibility alias: the historical renderer is now explicitly the intent half. */
148
+ export function renderStageLine(stage: string, decision: StageLineDecision): string {
149
+ const intent = renderStageIntentLine(stage, decision);
150
+ return intent.slice(0, intent.length - ' · intent'.length);
151
+ }