@mjasnikovs/pi-task 0.40.50 → 0.42.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 (125) hide show
  1. package/README.md +7 -4
  2. package/dist/config/config.d.ts +61 -18
  3. package/dist/config/config.js +50 -6
  4. package/dist/config/register.js +18 -5
  5. package/dist/shared/content-tokens.d.ts +16 -0
  6. package/dist/shared/content-tokens.js +137 -0
  7. package/dist/task/accept-debt.d.ts +31 -1
  8. package/dist/task/accept-debt.js +49 -3
  9. package/dist/task/artifact-closure.js +7 -1
  10. package/dist/task/auto-io.d.ts +66 -7
  11. package/dist/task/auto-io.js +152 -47
  12. package/dist/task/auto-orchestrator.d.ts +22 -19
  13. package/dist/task/auto-orchestrator.js +184 -112
  14. package/dist/task/child-runner.d.ts +18 -0
  15. package/dist/task/child-runner.js +7 -8
  16. package/dist/task/command-run.d.ts +4 -0
  17. package/dist/task/command-run.js +4 -2
  18. package/dist/task/constraint-policy.d.ts +52 -0
  19. package/dist/task/constraint-policy.js +66 -0
  20. package/dist/task/context-silence.d.ts +5 -4
  21. package/dist/task/context-silence.js +13 -5
  22. package/dist/task/coverage-loop.d.ts +7 -4
  23. package/dist/task/coverage-loop.js +16 -138
  24. package/dist/task/debug-log.d.ts +25 -2
  25. package/dist/task/debug-log.js +64 -10
  26. package/dist/task/decompose-fidelity.d.ts +17 -4
  27. package/dist/task/decompose-fidelity.js +95 -55
  28. package/dist/task/decompose-granularity.d.ts +7 -7
  29. package/dist/task/decompose-granularity.js +8 -8
  30. package/dist/task/env-notes.d.ts +65 -19
  31. package/dist/task/env-notes.js +152 -50
  32. package/dist/task/external-context.js +25 -5
  33. package/dist/task/fix-context.d.ts +39 -0
  34. package/dist/task/fix-context.js +58 -0
  35. package/dist/task/gate-deps.d.ts +49 -0
  36. package/dist/task/gate-deps.js +201 -39
  37. package/dist/task/gate-evidence.d.ts +51 -0
  38. package/dist/task/gate-evidence.js +90 -0
  39. package/dist/task/gate-resolution.d.ts +119 -0
  40. package/dist/task/gate-resolution.js +120 -0
  41. package/dist/task/git-state-guard.js +3 -26
  42. package/dist/task/handoff.d.ts +35 -0
  43. package/dist/task/handoff.js +100 -0
  44. package/dist/task/health-baseline.d.ts +87 -0
  45. package/dist/task/health-baseline.js +158 -0
  46. package/dist/task/health-repair.d.ts +68 -0
  47. package/dist/task/health-repair.js +124 -0
  48. package/dist/task/ledger.d.ts +10 -0
  49. package/dist/task/ledger.js +22 -11
  50. package/dist/task/lint-fix.d.ts +11 -0
  51. package/dist/task/lint-fix.js +14 -8
  52. package/dist/task/loop-detector.d.ts +52 -3
  53. package/dist/task/loop-detector.js +81 -5
  54. package/dist/task/mentions.d.ts +17 -0
  55. package/dist/task/mentions.js +86 -0
  56. package/dist/task/orchestrator.d.ts +53 -9
  57. package/dist/task/orchestrator.js +104 -28
  58. package/dist/task/orientation.d.ts +135 -29
  59. package/dist/task/orientation.js +259 -67
  60. package/dist/task/owned-freeze-reassign.d.ts +7 -3
  61. package/dist/task/owned-freeze-reassign.js +13 -5
  62. package/dist/task/parsers.d.ts +6 -1
  63. package/dist/task/parsers.js +21 -4
  64. package/dist/task/phases.d.ts +1 -1
  65. package/dist/task/phases.js +125 -153
  66. package/dist/task/plan-orchestrator.js +5 -6
  67. package/dist/task/plan-rounds.d.ts +1 -0
  68. package/dist/task/plan-rounds.js +8 -1
  69. package/dist/task/prohibition-probe.d.ts +6 -1
  70. package/dist/task/prohibition-probe.js +26 -6
  71. package/dist/task/prompts.js +13 -2
  72. package/dist/task/qa-transcript.d.ts +17 -0
  73. package/dist/task/qa-transcript.js +28 -0
  74. package/dist/task/question-source.d.ts +16 -2
  75. package/dist/task/question-source.js +21 -8
  76. package/dist/task/repo-health-check.d.ts +27 -0
  77. package/dist/task/repo-health-check.js +39 -5
  78. package/dist/task/requirements.d.ts +67 -13
  79. package/dist/task/requirements.js +129 -67
  80. package/dist/task/research-worker.d.ts +43 -2
  81. package/dist/task/research-worker.js +103 -8
  82. package/dist/task/run-bracket.d.ts +9 -4
  83. package/dist/task/run-bracket.js +9 -0
  84. package/dist/task/run-context.d.ts +152 -0
  85. package/dist/task/run-context.js +277 -0
  86. package/dist/task/spec-doc.d.ts +78 -0
  87. package/dist/task/spec-doc.js +205 -0
  88. package/dist/task/spec-model.d.ts +70 -0
  89. package/dist/task/spec-model.js +139 -0
  90. package/dist/task/stall-detector.d.ts +1 -1
  91. package/dist/task/stall-detector.js +9 -5
  92. package/dist/task/state-dir.d.ts +29 -0
  93. package/dist/task/state-dir.js +80 -0
  94. package/dist/task/suppression-probe.d.ts +67 -0
  95. package/dist/task/suppression-probe.js +78 -0
  96. package/dist/task/task-gates.d.ts +52 -58
  97. package/dist/task/task-gates.js +161 -199
  98. package/dist/task/task-io.d.ts +10 -0
  99. package/dist/task/task-io.js +69 -18
  100. package/dist/task/task-parsers.js +6 -6
  101. package/dist/task/task-types.d.ts +7 -0
  102. package/dist/task/timings.d.ts +11 -0
  103. package/dist/task/timings.js +21 -0
  104. package/dist/task/tree-hash.d.ts +8 -0
  105. package/dist/task/tree-hash.js +55 -0
  106. package/dist/task/verify-reconcile.d.ts +4 -3
  107. package/dist/task/verify-reconcile.js +7 -8
  108. package/dist/task/verify-resolution.d.ts +32 -6
  109. package/dist/task/verify-resolution.js +78 -15
  110. package/dist/task/verify-work.d.ts +105 -35
  111. package/dist/task/verify-work.js +232 -60
  112. package/dist/task/yolo.d.ts +0 -13
  113. package/dist/task/yolo.js +9 -21
  114. package/dist/workers/pi-worker-core.d.ts +20 -0
  115. package/dist/workers/pi-worker-core.js +16 -11
  116. package/dist/workers/pi-worker-docs.d.ts +6 -5
  117. package/dist/workers/pi-worker-docs.js +8 -7
  118. package/dist/workers/pi-worker-fetch.d.ts +3 -2
  119. package/dist/workers/pi-worker-fetch.js +5 -4
  120. package/dist/workers/pi-worker-search.js +5 -4
  121. package/dist/workers/research-cache.d.ts +23 -1
  122. package/dist/workers/research-cache.js +63 -3
  123. package/dist/workers/shared.d.ts +18 -0
  124. package/dist/workers/shared.js +38 -22
  125. package/package.json +1 -1
@@ -1,4 +1,8 @@
1
+ import { type EmittedNote } from './env-notes.js';
1
2
  import { type CrossTaskDeletion } from './task-provenance.js';
3
+ import { type HealthBaseline, type HealthSignal } from './health-baseline.js';
4
+ import { type Spec } from './spec-model.js';
5
+ import { type SuppressionHit } from './suppression-probe.js';
2
6
  /**
3
7
  * The verification child gets exactly two tools: `read` and `bash`.
4
8
  *
@@ -14,19 +18,44 @@ import { type CrossTaskDeletion } from './task-provenance.js';
14
18
  * mutated tree. The enforce pass, whose job IS editing, runs `read,edit`.
15
19
  */
16
20
  declare const VERIFY_TOOLS = "read,bash";
17
- export interface VerifyOutcome {
18
- /** true the work verified (or verification disabled / nothing to verify).
19
- * false → the child reported the work does NOT satisfy its spec, or the pass
20
- * could not run / produced no verdict. */
21
- ok: boolean;
22
- /** Short, human-readable reason. Always set when ok === false; on the pass
23
- * path set to the no-op cause ('disabled', 'no spec to verify'). */
21
+ /**
22
+ * The work verified, or there was nothing to verify.
23
+ *
24
+ * The FAIL-only fields are declared `?: undefined` rather than omitted: a pass may
25
+ * not carry them (`{ok: true, failClass: …}` is still a compile error), but a
26
+ * caller holding the bare union can still READ them without narrowing first, which
27
+ * is how every consumer asks "was this unobserved?" in one expression.
28
+ */
29
+ export interface VerifyPass {
30
+ ok: true;
31
+ /** The NO-OP cause ('disabled', 'no spec to verify'). Absent on a genuine
32
+ * pass, which is the only signal the enforce pass may edit against. */
24
33
  reason?: string;
25
- /** True when the FAIL is specifically an UNOBSERVED outcome (rule 5c): a
26
- * spec-required behavioral check could not run because its tooling is absent.
27
- * The gate routes this straight to the human picker instead of an unattended
28
- * AUTOFIX re-run, which cannot provision a missing tool. Only meaningful when
29
- * ok === false. */
34
+ failClass?: undefined;
35
+ unobserved?: undefined;
36
+ crossTaskDeletions?: undefined;
37
+ inheritedHealth?: string;
38
+ health?: undefined;
39
+ probes?: ProbeFindings;
40
+ }
41
+ /**
42
+ * The work did NOT satisfy its spec, or the pass could not run.
43
+ *
44
+ * `failClass` is REQUIRED. Optional, it travelled as the prefix of `reason` and
45
+ * every downstream classifier recovered it by re-typing that literal, so a reword
46
+ * of the mint disarmed them with no compile error — and one site (the
47
+ * mutation-guard FAIL) simply never set it, which left the decision table with no
48
+ * class to route on. `VERIFY_FAIL_PREFIX` owns the display strings so mint and
49
+ * match cannot drift.
50
+ */
51
+ export interface VerifyFail {
52
+ ok: false;
53
+ failClass: VerifyFailClass;
54
+ /** Short, human-readable reason, minted under the class's prefix. */
55
+ reason: string;
56
+ /** Rule 5c: a spec-required behavioral check could not run because its tooling
57
+ * is absent. Sets the AUTOFIX budget to zero on any class — an unattended
58
+ * re-run cannot provision a missing tool. */
30
59
  unobserved?: boolean;
31
60
  /** The deterministic cross-task deletion findings (see task-provenance.ts) that
32
61
  * were live when this verdict was produced: sibling tasks' committed
@@ -34,17 +63,25 @@ export interface VerifyOutcome {
34
63
  * can record each as a durable debt if the user ACCEPTs anyway — the deletion
35
64
  * then ships in the next commit and the final gate must re-check it. */
36
65
  crossTaskDeletions?: CrossTaskDeletion[];
37
- /**
38
- * WHICH KIND of FAIL this is, as data. Only meaningful when ok === false.
39
- *
40
- * Without it the class travels only as the PREFIX of `reason`, and every
41
- * downstream classifier has to recover it by re-typing that literal — a
42
- * reword of the mint would then disarm them with no compile error.
43
- * `VERIFY_FAIL_PREFIX` owns the strings so mint and match cannot drift, and
44
- * `verifyFailClass` prefers this field over the prefix.
45
- */
46
- failClass?: VerifyFailClass;
66
+ inheritedHealth?: string;
67
+ /** The health result behind a `repo-health` FAIL: which command, and what its
68
+ * output named. What an ACCEPT of this FAIL hands to the repair channel. */
69
+ health?: HealthSignal & {
70
+ output?: string;
71
+ };
72
+ /** What the deterministic probes found for THIS verdict, carried out so an
73
+ * AUTOFIX re-run is told what the gate already knows (see fix-context.ts)
74
+ * instead of re-deriving it from the one-line reason. */
75
+ probes?: ProbeFindings;
47
76
  }
77
+ /**
78
+ * `inheritedHealth` is declared on BOTH halves: the repo's own static checks that
79
+ * were already failing the same way before this task ran (health-baseline.ts).
80
+ * A task can verify perfectly in a repo that arrived red, so a PASS carries it
81
+ * too — dropping it on the pass path is where a sibling's defect disappears until
82
+ * the run-end gate rediscovers it with nobody's name on it.
83
+ */
84
+ export type VerifyOutcome = VerifyPass | VerifyFail;
48
85
  /**
49
86
  * The kinds of verify FAIL. `VERIFY_FAIL_PREFIX` below is a
50
87
  * `Record<VerifyFailClass, string>`, so a new member here is a compile error
@@ -72,18 +109,18 @@ export declare const VERIFY_FAIL_PREFIX: Record<VerifyFailClass, string>;
72
109
  * mints its `static checks:` line through a different path entirely. This is the
73
110
  * only place in src/ that tests a reason against a prefix.
74
111
  */
75
- export declare function verifyFailClass(o: Pick<VerifyOutcome, 'failClass' | 'reason'>): VerifyFailClass | undefined;
112
+ export declare function verifyFailClass(o: {
113
+ failClass?: VerifyFailClass;
114
+ reason?: string;
115
+ }): VerifyFailClass | undefined;
76
116
  /** The class a recorded reason STRING belongs to, by its minted prefix. */
77
117
  export declare function failClassOfReason(reason: string): VerifyFailClass | undefined;
78
118
  /** Does this class name a deterministic whole-repo static check, at either altitude? */
79
119
  export declare function isStaticClass(cls: VerifyFailClass | undefined): boolean;
80
120
  /**
81
- * Slice the delivered spec (GOAL / CONSTRAINTS / ACCEPTANCE / VERIFY) out of a
82
- * task file body. The compose and critique phases write the section named `spec`,
83
- * so the composed spec lives under `## spec` and runs to the next line matching
84
- * `## ` plus non-space (`## phase timings`); a `### ` subheading stays inside.
85
- * Returns null when there is no spec section or it is blank (a task that never
86
- * reached compose), which the caller treats as a pass — nothing to verify against.
121
+ * The delivered spec's TEXT, for the children that must read its prose verbatim.
122
+ * The slicing itself lives in spec-model.ts beside the parser, so "the spec
123
+ * section" is one definition rather than one per consumer.
87
124
  */
88
125
  export declare function extractSpecForVerification(taskBody: string): string | null;
89
126
  /**
@@ -115,6 +152,7 @@ export declare function extractSpecForVerification(taskBody: string): string | n
115
152
  * 'VerifyProbes'").
116
153
  */
117
154
  export interface ProbeRaw {
155
+ evidence: string[];
118
156
  substitution: string[];
119
157
  prohibition: string[];
120
158
  crossTaskDeletion: CrossTaskDeletion[];
@@ -124,15 +162,19 @@ export interface ProbeRaw {
124
162
  scriptEscape: string[];
125
163
  runnerGlob: string[];
126
164
  testAssembly: string[];
165
+ repoHealth: string[];
166
+ suppressionWidening: SuppressionHit[];
127
167
  }
128
168
  /** Stable identity of one probe channel: table row ↔ findings-bag key. */
129
169
  export type ProbeKey = keyof ProbeRaw;
130
170
  /**
131
- * The channels a CALLER binds every key but `skipEscape`, which is pure text
132
- * analysis of `deps.spec` and is sourced inside its own table row, so it is never
133
- * absent and never bound from outside.
171
+ * The channels a CALLER binds. Two keys are not among them: `skipEscape`, which is
172
+ * pure text analysis of `deps.spec` and is sourced inside its own table row, and
173
+ * `repoHealth`, whose findings are the classified DELTA of a check
174
+ * `runWorkVerification` has already run — only that function holds both the
175
+ * baseline and the result, so only it can source the row.
134
176
  */
135
- export type BoundProbeKey = Exclude<ProbeKey, 'skipEscape'>;
177
+ export type BoundProbeKey = Exclude<ProbeKey, 'skipEscape' | 'repoHealth'>;
136
178
  /**
137
179
  * The bound probes: one optional thunk per channel, typed to that channel's raw
138
180
  * shape. Built in ONE place (gate-deps' `buildVerifyProbes`); an absent key means
@@ -150,6 +192,12 @@ export type ProbeFindings = Partial<Record<ProbeKey, string[]>>;
150
192
  * checked against the table rather than against a hand-kept list.
151
193
  */
152
194
  export declare const BOUND_PROBE_KEYS: readonly BoundProbeKey[];
195
+ /**
196
+ * The spec as a VALUE, with each constraint's `[from:]` tag resolved against the
197
+ * task's own Q&A record. Shared by the verify prompt and the resolution judge, so
198
+ * one constraint cannot carry two weights.
199
+ */
200
+ export declare function specValue(spec: string, qaRecord?: string): Spec;
153
201
  /**
154
202
  * Build the verification child's prompt. Kept pure so the wording is unit-tested
155
203
  * without spawning pi. The contract: run the spec's own verification in the real
@@ -162,8 +210,14 @@ export declare const BOUND_PROBE_KEYS: readonly BoundProbeKey[];
162
210
  export declare function buildVerifyPrompt(spec: string, findings?: ProbeFindings, context?: {
163
211
  /** Environment facts earlier gate children discovered — see env-notes.ts. */
164
212
  envNotes?: string;
213
+ /** This run's id: the notes it recorded lead, older runs' follow. */
214
+ envRunId?: string;
165
215
  /** Cross-slice interface facts the design pins — see contracts.ts. */
166
216
  contracts?: string;
217
+ /** The task file's rendered Q&A, which is what resolves a constraint's
218
+ * `[from: Q<n>]` tag to the kind of answer that produced it. Absent ⇒
219
+ * every tagged constraint reads as `derived`, which is advisory. */
220
+ qaRecord?: string;
167
221
  }): string;
168
222
  /**
169
223
  * Parse the child's verdict out of the LAST `WORK-VERIFIED: PASS|FAIL|UNOBSERVED`
@@ -206,7 +260,16 @@ export interface VerificationDeps {
206
260
  repoHealth?: () => Promise<{
207
261
  ok: boolean;
208
262
  reason: string;
209
- }>;
263
+ output?: string;
264
+ } & HealthSignal>;
265
+ /**
266
+ * What those same checks said BEFORE this task ran (see health-baseline.ts).
267
+ * Consulted only when `repoHealth` comes back red, and it is what decides
268
+ * whose defect that is: a check failing the same way before is `pre-existing`
269
+ * and becomes a probe row, not a FAIL. ABSENT, or null, → every red check is
270
+ * this task's, which is the behavior that shipped before the baseline existed.
271
+ */
272
+ healthBaseline?: () => Promise<HealthBaseline | null>;
210
273
  /**
211
274
  * Progress hook for the DETERMINISTIC stage — the repo-health run plus the
212
275
  * `probes` below, all of which run BEFORE the child (and therefore before the
@@ -245,7 +308,10 @@ export interface VerificationDeps {
245
308
  */
246
309
  envNotes?: {
247
310
  read: () => Promise<string>;
248
- append: (notes: string[]) => Promise<void>;
311
+ append: (notes: readonly EmittedNote[]) => Promise<void>;
312
+ /** The run these notes belong to, so the child's prompt can lead with the
313
+ * facts measured against the tree it is standing in. */
314
+ runId?: string;
249
315
  };
250
316
  /**
251
317
  * Per-run cross-slice contract registry (see contracts.ts): `read` supplies the
@@ -255,6 +321,10 @@ export interface VerificationDeps {
255
321
  * `/task` runs, or a design pinning no shared boundary).
256
322
  */
257
323
  contracts?: () => Promise<string>;
324
+ /** The task file's `## grill Q&A` text, which resolves each constraint's
325
+ * provenance tag (see `specValue`). ABSENT ⇒ every tagged constraint is
326
+ * advisory, which is the safe reading of a provenance nobody can confirm. */
327
+ qaRecord?: string;
258
328
  }
259
329
  /**
260
330
  * Run the verification pass for one task. `repoHealth` runs first and can FAIL on