@telora/daemon 0.22.137 → 0.22.144

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 (72) hide show
  1. package/build-info.json +13 -3
  2. package/dist/audit/audit-phase.d.ts.map +1 -1
  3. package/dist/audit/audit-phase.js +15 -0
  4. package/dist/audit/audit-phase.js.map +1 -1
  5. package/dist/audit/audit-prompt.d.ts +174 -0
  6. package/dist/audit/audit-prompt.d.ts.map +1 -1
  7. package/dist/audit/audit-prompt.js +365 -2
  8. package/dist/audit/audit-prompt.js.map +1 -1
  9. package/dist/completion/review-coverage-shas.d.ts +49 -0
  10. package/dist/completion/review-coverage-shas.d.ts.map +1 -0
  11. package/dist/completion/review-coverage-shas.js +128 -0
  12. package/dist/completion/review-coverage-shas.js.map +1 -0
  13. package/dist/completion/review-exit-deps.d.ts +15 -2
  14. package/dist/completion/review-exit-deps.d.ts.map +1 -1
  15. package/dist/completion/review-exit-deps.js +9 -3
  16. package/dist/completion/review-exit-deps.js.map +1 -1
  17. package/dist/delivery/delivery-review-coverage.d.ts +200 -0
  18. package/dist/delivery/delivery-review-coverage.d.ts.map +1 -0
  19. package/dist/delivery/delivery-review-coverage.js +192 -0
  20. package/dist/delivery/delivery-review-coverage.js.map +1 -0
  21. package/dist/queries/focus-branch-work-evidence.d.ts +55 -0
  22. package/dist/queries/focus-branch-work-evidence.d.ts.map +1 -0
  23. package/dist/queries/focus-branch-work-evidence.js +65 -0
  24. package/dist/queries/focus-branch-work-evidence.js.map +1 -0
  25. package/dist/queries/focus-criteria-standing.d.ts +138 -0
  26. package/dist/queries/focus-criteria-standing.d.ts.map +1 -0
  27. package/dist/queries/focus-criteria-standing.js +98 -0
  28. package/dist/queries/focus-criteria-standing.js.map +1 -0
  29. package/dist/queries/focus-review-watermark.d.ts +35 -0
  30. package/dist/queries/focus-review-watermark.d.ts.map +1 -0
  31. package/dist/queries/focus-review-watermark.js +47 -0
  32. package/dist/queries/focus-review-watermark.js.map +1 -0
  33. package/dist/queries/focuses.d.ts +0 -9
  34. package/dist/queries/focuses.d.ts.map +1 -1
  35. package/dist/queries/focuses.js +0 -14
  36. package/dist/queries/focuses.js.map +1 -1
  37. package/dist/queries/shared.js +1 -1
  38. package/dist/queries/verification.d.ts +23 -25
  39. package/dist/queries/verification.d.ts.map +1 -1
  40. package/dist/queries/verification.js +66 -45
  41. package/dist/queries/verification.js.map +1 -1
  42. package/dist/resolvers/assembly-engine.d.ts.map +1 -1
  43. package/dist/resolvers/assembly-engine.js +2 -0
  44. package/dist/resolvers/assembly-engine.js.map +1 -1
  45. package/dist/resolvers/focus-criteria-standing.d.ts +24 -0
  46. package/dist/resolvers/focus-criteria-standing.d.ts.map +1 -0
  47. package/dist/resolvers/focus-criteria-standing.js +234 -0
  48. package/dist/resolvers/focus-criteria-standing.js.map +1 -0
  49. package/dist/resolvers/focus-review-coverage.d.ts +189 -0
  50. package/dist/resolvers/focus-review-coverage.d.ts.map +1 -0
  51. package/dist/resolvers/focus-review-coverage.js +487 -0
  52. package/dist/resolvers/focus-review-coverage.js.map +1 -0
  53. package/dist/resolvers/git-diff-against-base.d.ts.map +1 -1
  54. package/dist/resolvers/git-diff-against-base.js +11 -0
  55. package/dist/resolvers/git-diff-against-base.js.map +1 -1
  56. package/dist/resolvers/index.d.ts.map +1 -1
  57. package/dist/resolvers/index.js +7 -1
  58. package/dist/resolvers/index.js.map +1 -1
  59. package/dist/resolvers/reality-tree-snapshot.d.ts +9 -4
  60. package/dist/resolvers/reality-tree-snapshot.d.ts.map +1 -1
  61. package/dist/resolvers/reality-tree-snapshot.js +64 -17
  62. package/dist/resolvers/reality-tree-snapshot.js.map +1 -1
  63. package/dist/resolvers/shared/branch-fact-provenance.d.ts +258 -0
  64. package/dist/resolvers/shared/branch-fact-provenance.d.ts.map +1 -0
  65. package/dist/resolvers/shared/branch-fact-provenance.js +571 -0
  66. package/dist/resolvers/shared/branch-fact-provenance.js.map +1 -0
  67. package/dist/resolvers/shared/reality-tree-arrival.d.ts +71 -0
  68. package/dist/resolvers/shared/reality-tree-arrival.d.ts.map +1 -0
  69. package/dist/resolvers/shared/reality-tree-arrival.js +129 -0
  70. package/dist/resolvers/shared/reality-tree-arrival.js.map +1 -0
  71. package/dist/testing/fixtures/index.js +1 -1
  72. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
- // Pinned by: packages/daemon/src/integration/failed-verdict-review-exit-respawn-regression.test.ts
2
+ // Pinned by: packages/daemon/src/completion/review-coverage-seam.test.ts,
3
+ // packages/daemon/src/integration/failed-verdict-review-exit-respawn-regression.test.ts
3
4
  // PINNED-BY-END
4
5
  /**
5
6
  * Dependency contract + default wiring for the review-exit phase.
@@ -19,13 +20,14 @@ import { blameLineCommits, listReviewWindowCommits } from '../resolvers/shared/r
19
20
  import { getActiveFocuses } from '../queries/focus-discovery.js';
20
21
  import { clearPendingReviewDirective, hasPendingSpawnDirective } from '../directive/directive-queue.js';
21
22
  import { emitLoopTrigger } from '../loops/index.js';
22
- import { getFocusDeliveries, getFocusIssues, clearReviewRequestedAt, setReviewedThroughSha, setReviewCycleCount, setReviewHandoffCount, getFocusReviewReportForSession, getFocusReviewFiledIssueIds, } from '../queries/focuses.js';
23
+ import { getFocusDeliveries, getFocusIssues, clearReviewRequestedAt, setReviewCycleCount, setReviewHandoffCount, getFocusReviewReportForSession, getFocusReviewFiledIssueIds, } from '../queries/focuses.js';
23
24
  import { resolveReviewCycleCap, resolveReviewHandoffCap } from '../verify/stall-detector-config.js';
24
25
  import { getDeliveryIssues, rehomeIssueToDelivery } from '../queries/issues.js';
25
26
  import { createEscalation, hasOpenFocusEscalation, hasOpenEscalationForDelivery, resolveOpenFocusEscalationsOfKind, resolveConvergedFocusEscalations } from '../queries/escalations.js';
26
27
  import { findOpenOperatorHoldForDelivery } from '../queries/holds.js';
27
28
  import { listOpenShortfallProposalIds } from '../queries/reality-tree.js';
28
29
  import { commitGateSeams } from '../verify/commit-gate-configured.js';
30
+ import { stampReviewCoverage } from './review-coverage-shas.js';
29
31
  import { writeReviewAutoApproval } from './review-auto-approval-record.js';
30
32
  import { writeReviewCensus } from './review-census-record.js';
31
33
  import { fileReworkForFailedVerdict } from '../verify/verification-rework-issue.js';
@@ -42,7 +44,11 @@ export const defaultReviewExitDeps = {
42
44
  clearReviewRequestedAt,
43
45
  fileReworkForFailedVerdict: (focusId, verdict) => fileReworkForFailedVerdict(focusId, verdict),
44
46
  clearPendingReviewDirective,
45
- setReviewedThroughSha,
47
+ // The watermark write goes through the coverage stamp, so the range the
48
+ // watermark stands for is recorded with it (Bug TEL-10): the edge create
49
+ // gate has no repository and would otherwise hold every delivery that
50
+ // merged before the reviewed tip, with no event able to release it.
51
+ setReviewedThroughSha: stampReviewCoverage,
46
52
  setReviewCycleCount,
47
53
  resolveReviewCycleCap,
48
54
  setReviewHandoffCount,
@@ -1 +1 @@
1
- {"version":3,"file":"review-exit-deps.js","sourceRoot":"","sources":["../../src/completion/review-exit-deps.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,mGAAmG;AACnG,gBAAgB;AAEhB;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAChI,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAA2B,MAAM,8CAA8C,CAAC;AAClI,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,cAAc,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AK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1F,CAAC;IACD,sBAAsB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,MAAM,kBAAkB,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,IAAI;IACvG,gBAAgB;IAChB,4BAA4B;IAC5B,wBAAwB;IACxB,eAAe;IACf,8BAA8B;IAC9B,2BAA2B;IAC3B,gBAAgB;CACjB,CAAC"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Per-delivery review-coverage classifier -- the NODE MIRROR of the canonical
3
+ * Deno module `supabase/functions/_shared/delivery-review-coverage.ts`.
4
+ *
5
+ * WHY A MIRROR AND NOT AN IMPORT. The canonical lives in the Deno edge tree so
6
+ * the product-api create gate can refuse a delivery presumed to be residue of
7
+ * unreviewed work. The daemon is Node: it cannot import that file at runtime
8
+ * (the build emits from `src/` with NodeNext resolution, so a `.ts` specifier
9
+ * outside rootDir does not survive `tsc`), and the file cannot move into a
10
+ * workspace package because Deno cannot import one. The repo's generated-mirror
11
+ * machinery (`scripts/shared-mirror-manifest.json`) would be the right home if
12
+ * the canonical sat in `src/lib` -- it generates INTO this package already (see
13
+ * `drift/artifact-ref-shape.ts`) -- but its contract is one hand-edited
14
+ * canonical in `src/lib` with every other copy generated, and this algorithm
15
+ * landed hand-edited in the Deno tree. So the two copies are held in agreement
16
+ * BEHAVIOURALLY instead, by `delivery-review-coverage-parity.test.ts`, which
17
+ * runs both implementations over a case matrix covering every reason branch and
18
+ * fails on the first disagreement. Change one, change both, or that test goes
19
+ * red.
20
+ *
21
+ * WHAT IT ANSWERS. Has the delivery that produced a fact on the focus branch
22
+ * been through focus review? There is no per-delivery review linkage in the
23
+ * schema (`focus_reviews` is focus-altitude; `reviewed_through_sha` is a branch
24
+ * position; no delivery column names a review), so coverage is RECONSTRUCTED: a
25
+ * delivery's merge commit differenced against the reviewed range, with a
26
+ * timestamp fallback for rows carrying no merge sha.
27
+ *
28
+ * FAILS CLOSED. Every undecidable input classifies 'unreviewed', never
29
+ * 'reviewed'. A false 'unreviewed' costs a hold the caller can clear in one
30
+ * attributed step; a false 'reviewed' silently re-opens the hole.
31
+ *
32
+ * ONLY MONOTONE FACTS CROSS THE RUNTIME SEAM. The covered-sha set and the
33
+ * branch committed-work reading are both resolved by the daemon and read by a
34
+ * gate with no repository. A written-down fact is worth only what it is still
35
+ * worth when it is read, so the module accepts one whose truth can only GROW
36
+ * (a reviewed range widens; a commit that exists keeps existing) and refuses
37
+ * one that can lapse. "No commits for this delivery" is the lapsing kind: when
38
+ * the daemon cannot write, every stored input is frozen at its pre-residue
39
+ * value, so a rule over stored state answers as it did before the residue
40
+ * existed. Enforced in `resolveBranchWorkEvidence`.
41
+ *
42
+ * NO GIT AND NO I/O. Pure and dependency-free: the caller owns the repo and
43
+ * supplies the covered-sha set.
44
+ *
45
+ * @module delivery/delivery-review-coverage
46
+ */
47
+ /**
48
+ * Where a delivery's work stands relative to focus review.
49
+ *
50
+ * 'reviewed' -- covered by a COMPLETED focus review (covered, not
51
+ * approved: a gaps_found review covers the range it read).
52
+ * 'unreviewed' -- on the branch (or possibly so) with no completed review
53
+ * over it. Also the resting place of every undecidable input.
54
+ * 'no_work_yet' -- nothing exists that could BE residue.
55
+ */
56
+ export type DeliveryReviewCoverage = 'reviewed' | 'unreviewed' | 'no_work_yet';
57
+ /**
58
+ * WHY a delivery landed in its bucket. Carried so a refusal (or a rendered
59
+ * context section) can explain itself without re-deriving the decision, and so
60
+ * tests pin the BRANCH taken rather than only the verdict.
61
+ */
62
+ export type DeliveryReviewCoverageReason =
63
+ /** No merge commit, no coding history, and a pre-work status: nothing exists. */
64
+ 'no_work_produced'
65
+ /** The focus has never completed a review, so nothing on it can be covered. */
66
+ | 'focus_never_reviewed'
67
+ /** Merge commit present and inside the caller-supplied covered range. */
68
+ | 'merge_sha_covered'
69
+ /** Merge commit present and NOT in the covered range (landed after the review). */
70
+ | 'merge_sha_not_covered'
71
+ /** No merge sha, but the delivery was terminal before the review completed. */
72
+ | 'terminal_before_review'
73
+ /** No merge sha and the delivery moved after the review completed. */
74
+ | 'settled_after_review'
75
+ /** No merge sha and the delivery is not terminal, so the review cannot have finished judging it. */
76
+ | 'not_terminal'
77
+ /** A timestamp needed to decide was absent or unparseable -- fail closed. */
78
+ | 'undecidable_timestamp';
79
+ export interface DeliveryReviewCoverageResult {
80
+ coverage: DeliveryReviewCoverage;
81
+ reason: DeliveryReviewCoverageReason;
82
+ }
83
+ /** A delivery reference shaped for a refusal or a rendered listing. */
84
+ export interface DeliveryReviewRef {
85
+ id: string;
86
+ name: string;
87
+ }
88
+ /**
89
+ * One delivery row (`org_nodes` where `type = 'delivery'`), projected to the
90
+ * fields that bear on review coverage.
91
+ */
92
+ export interface DeliveryReviewInput extends DeliveryReviewRef {
93
+ /** org_nodes.execution_status. May be null on a malformed row. */
94
+ executionStatus: string | null | undefined;
95
+ /** org_nodes.merge_commit_sha -- present => the sha path decides. */
96
+ mergeCommitSha: string | null | undefined;
97
+ /**
98
+ * org_nodes.auto_approved_at. DELIBERATELY NEVER CONSULTED. Auto-approval is
99
+ * the daemon closing a verify delivery whose review team left NO focus_reviews
100
+ * row -- precisely the population with no review behind it. Declared so a
101
+ * reader learns it was considered and rejected, not forgotten.
102
+ */
103
+ autoApprovedAt: string | null | undefined;
104
+ /**
105
+ * org_nodes.updated_at (ISO-8601). Only ever used to prove a delivery SETTLED
106
+ * BEFORE a review, never that it changed after one in a way that matters.
107
+ */
108
+ updatedAt: string | null | undefined;
109
+ /**
110
+ * org_nodes.iteration_count. Non-zero means the delivery has been round the
111
+ * coding cycle, so a re-queued `queued` status understates it.
112
+ */
113
+ iterationCount?: number | null;
114
+ /**
115
+ * Caller-supplied BRANCH EVIDENCE about the delivery's committed work
116
+ * (commits on the branch bearing its trailer). The row cannot carry it: a
117
+ * fast-forward merge-back leaves commits with no `merge_commit_sha`, so only
118
+ * a caller holding the repo can see them.
119
+ *
120
+ * POSITIVE ONLY. `true` makes the row work-bearing; `false` and `undefined`
121
+ * are the same to this module and neither releases anything. Presence of a
122
+ * commit is monotone and survives being written down; absence is a claim
123
+ * about an instant and does not. See `resolveBranchWorkEvidence` for why two
124
+ * earlier attempts to transport the absence claim (three-valuedness, then a
125
+ * dated reading) both failed on the same structural fact.
126
+ */
127
+ hasCommittedWork?: boolean | undefined;
128
+ }
129
+ /**
130
+ * Read a STORED branch-work reading (`product_focuses.branch_work_delivery_ids`)
131
+ * as `hasCommittedWork` for one delivery. Membership -> `true`; EVERYTHING
132
+ * else -> `undefined`. A stored reading can only ADD a hold, never release
133
+ * one, at any age.
134
+ *
135
+ * WHY NO RELEASING ANSWER SURVIVES. An empty reading used to release: "a
136
+ * repository was searched and this delivery has no commits". It was fenced
137
+ * first by three-valuedness (NULL is not `[]`), then by a stamp and a
138
+ * freshness window. Both broke on one fact: the daemon's retraction of a
139
+ * reading it has just disproved is itself a WRITE, so it is missing in exactly
140
+ * the failure that calls for it -- and when no write can land, every durable
141
+ * input here is frozen at its pre-residue value, so a rule over stored state
142
+ * returns what it returned before the work existed. Only a clock could
143
+ * separate the two, and a clock releases knowingly for a while, which is a
144
+ * delay, not a gate.
145
+ *
146
+ * So a cancelled, unmerged, never-re-iterated delivery is HELD until a
147
+ * completed review covers it (cancelled is terminal, so the timestamp fallback
148
+ * discharges it) or a caller declares a new root cause. Conservative, not a
149
+ * freeze. A caller that read the branch in the same act as its decision is not
150
+ * in this position and does not come through here.
151
+ */
152
+ export declare function resolveBranchWorkEvidence(deliveryIds: readonly string[] | null | undefined, deliveryId: string): true | undefined;
153
+ /** The focus-altitude review state, resolved by the caller. */
154
+ export interface FocusReviewCoverageInput {
155
+ /**
156
+ * product_focuses.reviewed_through_sha -- the focus-branch tip a COMPLETED
157
+ * review covered. Null/blank means no completed review has ever happened.
158
+ */
159
+ reviewedThroughSha: string | null | undefined;
160
+ /**
161
+ * completed_at of the most recent COMPLETED focus review (ISO-8601). An
162
+ * in-flight review must NOT be passed here: a review still running has
163
+ * judged nothing.
164
+ */
165
+ latestCompletedReviewAt: string | null | undefined;
166
+ /**
167
+ * The commit shas the completed review(s) covered, resolved by the caller
168
+ * because THIS MODULE DOES NO GIT AND NO I/O. The daemon resolves it live by
169
+ * ANCESTRY against the watermark; the edge, which has no repository, reads
170
+ * the set the daemon persisted (product_focuses.reviewed_through_shas). A
171
+ * delivery that merged inside the reviewed range was read by that review as
172
+ * surely as the tip commit. Absent or empty is not an error and not an
173
+ * invitation to guess -- every merge-sha-bearing delivery simply fails to
174
+ * match and classifies 'unreviewed'.
175
+ */
176
+ coveredShas?: ReadonlySet<string> | readonly string[];
177
+ }
178
+ /**
179
+ * Classify one delivery against its focus's review state.
180
+ *
181
+ * Decision order (each clause short-circuits):
182
+ * 1. produced nothing -> 'no_work_yet'. The only clause
183
+ * that concludes no residue can
184
+ * exist, and it reads the row's OWN
185
+ * columns -- never a third party's
186
+ * observation of a branch.
187
+ * 2. no completed review on the focus -> 'unreviewed' (the watermark rule).
188
+ * 3. merge sha present -> covered-set membership decides.
189
+ * 4. no merge sha -> the timestamp fallback decides.
190
+ *
191
+ * `autoApprovedAt` appears in NO clause; see its field doc.
192
+ */
193
+ export declare function classifyDeliveryReviewCoverage(delivery: DeliveryReviewInput, focus: FocusReviewCoverageInput): DeliveryReviewCoverageResult;
194
+ /**
195
+ * The deliveries on a focus whose work has NOT been through focus review,
196
+ * returned as `{id, name}` refs. Input order is preserved; only the two fields
197
+ * a message needs are returned.
198
+ */
199
+ export declare function unreviewedDeliveriesOnFocus(deliveries: readonly DeliveryReviewInput[], focus: FocusReviewCoverageInput): DeliveryReviewRef[];
200
+ //# sourceMappingURL=delivery-review-coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-review-coverage.d.ts","sourceRoot":"","sources":["../../src/delivery/delivery-review-coverage.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAQlB;AAED,+DAA+D;AAC/D,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C;;;;OAIG;IACH,uBAAuB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,CAAC;CACvD;AAuFD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,wBAAwB,GAC9B,4BAA4B,CAyC9B;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,KAAK,EAAE,wBAAwB,GAC9B,iBAAiB,EAAE,CAQrB"}
@@ -0,0 +1,192 @@
1
+ // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
+ // Pinned by: packages/daemon/src/delivery/delivery-review-coverage-parity.test.ts
3
+ // PINNED-BY-END
4
+ /** Trim an id for comparison; the column is text[] and may carry padding. */
5
+ function normalizeId(id) {
6
+ return typeof id === 'string' ? id.trim() : '';
7
+ }
8
+ /**
9
+ * Read a STORED branch-work reading (`product_focuses.branch_work_delivery_ids`)
10
+ * as `hasCommittedWork` for one delivery. Membership -> `true`; EVERYTHING
11
+ * else -> `undefined`. A stored reading can only ADD a hold, never release
12
+ * one, at any age.
13
+ *
14
+ * WHY NO RELEASING ANSWER SURVIVES. An empty reading used to release: "a
15
+ * repository was searched and this delivery has no commits". It was fenced
16
+ * first by three-valuedness (NULL is not `[]`), then by a stamp and a
17
+ * freshness window. Both broke on one fact: the daemon's retraction of a
18
+ * reading it has just disproved is itself a WRITE, so it is missing in exactly
19
+ * the failure that calls for it -- and when no write can land, every durable
20
+ * input here is frozen at its pre-residue value, so a rule over stored state
21
+ * returns what it returned before the work existed. Only a clock could
22
+ * separate the two, and a clock releases knowingly for a while, which is a
23
+ * delay, not a gate.
24
+ *
25
+ * So a cancelled, unmerged, never-re-iterated delivery is HELD until a
26
+ * completed review covers it (cancelled is terminal, so the timestamp fallback
27
+ * discharges it) or a caller declares a new root cause. Conservative, not a
28
+ * freeze. A caller that read the branch in the same act as its decision is not
29
+ * in this position and does not come through here.
30
+ */
31
+ export function resolveBranchWorkEvidence(deliveryIds, deliveryId) {
32
+ if (deliveryIds === null || deliveryIds === undefined)
33
+ return undefined;
34
+ const target = normalizeId(deliveryId);
35
+ if (target === '')
36
+ return undefined;
37
+ for (const id of deliveryIds) {
38
+ if (normalizeId(id) === target)
39
+ return true;
40
+ }
41
+ return undefined;
42
+ }
43
+ /**
44
+ * Statuses that PROVE a delivery has produced nothing yet. `queued` is proof
45
+ * only when `iterationCount` is absent or zero (the re-iteration back-path
46
+ * returns work-bearing deliveries to `queued`), which is why the two signals
47
+ * are read together in `isWorkBearing`.
48
+ */
49
+ const PRE_WORK_EXECUTION_STATUSES = new Set([
50
+ 'draft',
51
+ 'planning',
52
+ 'queued',
53
+ ]);
54
+ /**
55
+ * The statuses from which "the review finished judging this" can be inferred
56
+ * WITHOUT a merge sha: the delivery has STOPPED MOVING. `done` ends the main
57
+ * path; `cancelled` is the abandoned exit and accrues no further work.
58
+ *
59
+ * `cancelled` is load-bearing, and more so since the workless-cancellation
60
+ * carve-out was removed: EVERY cancelled delivery with no merge sha now
61
+ * reaches this fallback. Excluded, each would be `'not_terminal'` forever, and
62
+ * since it can never reach `done` that hold could never discharge -- a
63
+ * permanent hold is a freeze, not a gate. `verify` and `paused` stay excluded
64
+ * on purpose: nothing positions their work in the reviewed range and they can
65
+ * still accrue more.
66
+ */
67
+ const TERMINAL_EXECUTION_STATUSES = new Set(['done', 'cancelled']);
68
+ /** Trim to a comparable status token; a non-string status becomes ''. */
69
+ function normalizeStatus(status) {
70
+ return typeof status === 'string' ? status.trim() : '';
71
+ }
72
+ /**
73
+ * Trim and lower-case a sha, or null when there is nothing usable. Matching is
74
+ * EXACT after normalization -- prefix matching would turn a caller's formatting
75
+ * choice into a silent 'reviewed'.
76
+ */
77
+ function normalizeSha(sha) {
78
+ if (typeof sha !== 'string')
79
+ return null;
80
+ const trimmed = sha.trim().toLowerCase();
81
+ return trimmed.length > 0 ? trimmed : null;
82
+ }
83
+ /** Normalize the caller's covered-sha collection (Set or array) to a lookup set. */
84
+ function toShaSet(shas) {
85
+ if (shas === undefined)
86
+ return new Set();
87
+ const out = new Set();
88
+ for (const sha of shas) {
89
+ const normalized = normalizeSha(sha);
90
+ if (normalized !== null)
91
+ out.add(normalized);
92
+ }
93
+ return out;
94
+ }
95
+ /**
96
+ * Parse an ISO-8601 timestamp to epoch ms, or null when absent/unparseable.
97
+ * Null routes to the fail-closed branch: coercing to 0 would read as "settled
98
+ * long before the review".
99
+ */
100
+ function parseTimestamp(value) {
101
+ if (typeof value !== 'string')
102
+ return null;
103
+ const trimmed = value.trim();
104
+ if (trimmed.length === 0)
105
+ return null;
106
+ const ms = Date.parse(trimmed);
107
+ return Number.isNaN(ms) ? null : ms;
108
+ }
109
+ /**
110
+ * Has this delivery produced anything that could be residue? Evidence, in
111
+ * order: a merge commit, a caller assertion, a non-zero iteration count, its
112
+ * status. An UNRECOGNISED or absent status counts as work-bearing -- fail
113
+ * closed.
114
+ */
115
+ function isWorkBearing(delivery) {
116
+ if (normalizeSha(delivery.mergeCommitSha) !== null)
117
+ return true;
118
+ if (delivery.hasCommittedWork === true)
119
+ return true;
120
+ if (hasIterated(delivery))
121
+ return true;
122
+ return !PRE_WORK_EXECUTION_STATUSES.has(normalizeStatus(delivery.executionStatus));
123
+ }
124
+ /** Has the delivery been round the coding cycle at least once? */
125
+ function hasIterated(delivery) {
126
+ return typeof delivery.iterationCount === 'number' && delivery.iterationCount > 0;
127
+ }
128
+ /**
129
+ * Classify one delivery against its focus's review state.
130
+ *
131
+ * Decision order (each clause short-circuits):
132
+ * 1. produced nothing -> 'no_work_yet'. The only clause
133
+ * that concludes no residue can
134
+ * exist, and it reads the row's OWN
135
+ * columns -- never a third party's
136
+ * observation of a branch.
137
+ * 2. no completed review on the focus -> 'unreviewed' (the watermark rule).
138
+ * 3. merge sha present -> covered-set membership decides.
139
+ * 4. no merge sha -> the timestamp fallback decides.
140
+ *
141
+ * `autoApprovedAt` appears in NO clause; see its field doc.
142
+ */
143
+ export function classifyDeliveryReviewCoverage(delivery, focus) {
144
+ const status = normalizeStatus(delivery.executionStatus);
145
+ const mergeSha = normalizeSha(delivery.mergeCommitSha);
146
+ if (!isWorkBearing(delivery)) {
147
+ return { coverage: 'no_work_yet', reason: 'no_work_produced' };
148
+ }
149
+ // The watermark rule: `reviewed_through_sha` is null until a review COMPLETES,
150
+ // so a null here is proof no review has finished -- and proof beats every
151
+ // per-delivery signal below it.
152
+ if (normalizeSha(focus.reviewedThroughSha) === null) {
153
+ return { coverage: 'unreviewed', reason: 'focus_never_reviewed' };
154
+ }
155
+ if (mergeSha !== null) {
156
+ return toShaSet(focus.coveredShas).has(mergeSha)
157
+ ? { coverage: 'reviewed', reason: 'merge_sha_covered' }
158
+ : { coverage: 'unreviewed', reason: 'merge_sha_not_covered' };
159
+ }
160
+ // Timestamp fallback: strictly weaker than the sha path, so it concludes
161
+ // 'reviewed' only from the conjunction of a completed review, a terminal
162
+ // status, and a last write no later than that review.
163
+ const reviewCompletedAtMs = parseTimestamp(focus.latestCompletedReviewAt);
164
+ if (reviewCompletedAtMs === null) {
165
+ return { coverage: 'unreviewed', reason: 'undecidable_timestamp' };
166
+ }
167
+ if (!TERMINAL_EXECUTION_STATUSES.has(status)) {
168
+ return { coverage: 'unreviewed', reason: 'not_terminal' };
169
+ }
170
+ const updatedAtMs = parseTimestamp(delivery.updatedAt);
171
+ if (updatedAtMs === null) {
172
+ return { coverage: 'unreviewed', reason: 'undecidable_timestamp' };
173
+ }
174
+ return updatedAtMs <= reviewCompletedAtMs
175
+ ? { coverage: 'reviewed', reason: 'terminal_before_review' }
176
+ : { coverage: 'unreviewed', reason: 'settled_after_review' };
177
+ }
178
+ /**
179
+ * The deliveries on a focus whose work has NOT been through focus review,
180
+ * returned as `{id, name}` refs. Input order is preserved; only the two fields
181
+ * a message needs are returned.
182
+ */
183
+ export function unreviewedDeliveriesOnFocus(deliveries, focus) {
184
+ const unreviewed = [];
185
+ for (const delivery of deliveries) {
186
+ if (classifyDeliveryReviewCoverage(delivery, focus).coverage === 'unreviewed') {
187
+ unreviewed.push({ id: delivery.id, name: delivery.name });
188
+ }
189
+ }
190
+ return unreviewed;
191
+ }
192
+ //# sourceMappingURL=delivery-review-coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-review-coverage.js","sourceRoot":"","sources":["../../src/delivery/delivery-review-coverage.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,kFAAkF;AAClF,gBAAgB;AAwIhB,6EAA6E;AAC7E,SAAS,WAAW,CAAC,EAA6B;IAChD,OAAO,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAAiD,EACjD,UAAkB;IAElB,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxE,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACpC,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;QAC7B,IAAI,WAAW,CAAC,EAAE,CAAC,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AA4BD;;;;;GAKG;AACH,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC;IAC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,CAAC;IAC3C,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,IAAI,8BAA8B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC9E,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The branch committed-work evidence write.
3
+ *
4
+ * The delivery ROW cannot carry this fact. A fast-forward merge-back records
5
+ * no `merge_commit_sha`, and a cancelled delivery's commits sit on the focus
6
+ * branch with nothing on the row naming them -- so only a caller holding the
7
+ * repository can see that the work exists. The daemon is that caller; the
8
+ * product-api delivery-create residue gate, which must ENFORCE on the same
9
+ * fact, runs on an edge runtime with no repository at all.
10
+ *
11
+ * So the side that can see it writes it down, through the same
12
+ * `daemon_update_focus_status` seam the review-coverage watermark uses
13
+ * (`focus-review-watermark.ts`). Its own module for the same two reasons that
14
+ * one has: it is a distinct fact with a distinct fail-closed direction, and
15
+ * `queries/focuses.ts` sits at the file-size ceiling.
16
+ *
17
+ * ONE DIRECTION, AND THEREFORE ONE FUNCTION. This module used to have a pair:
18
+ * a write and a retraction, because a stored reading could RELEASE a hold and
19
+ * a reading that turned out to be wrong had to be taken back. The retraction
20
+ * is a WRITE, so it was missing in exactly the failure it existed for -- the
21
+ * write channel being down -- and dating the reading only bounded how long
22
+ * the wrong answer stood. The gate now reads a stored reading POSITIVELY only
23
+ * (`supabase/functions/_shared/delivery-review-coverage.ts` ->
24
+ * `resolveBranchWorkEvidence`): ids
25
+ * add holds, their absence grants nothing. With nothing to take back there is
26
+ * nothing to retract, so the retraction is gone rather than made reliable.
27
+ *
28
+ * @module queries/focus-branch-work-evidence
29
+ */
30
+ import { type CallApiDeps } from './shared.js';
31
+ /**
32
+ * Record WHICH of a focus's deliveries have commits on the focus branch
33
+ * (product_focuses.branch_work_delivery_ids), as proved by a
34
+ * `Telora-Delivery` trailer search in the focus's repository.
35
+ *
36
+ * NEVER MARKS ANYTHING REVIEWED, AND NEVER RELEASES ANYTHING. An id in this
37
+ * set makes a delivery work-bearing, and therefore holdable by the residue
38
+ * gate under the normal coverage rules. An id that is absent from it asserts
39
+ * nothing at all: the gate treats a stored reading as positive-only, because
40
+ * "the branch carries no commits for this delivery" is true of an INSTANT and
41
+ * this value is read minutes or hours later, by a runtime that cannot check.
42
+ *
43
+ * CALL ONLY WHEN THE BRANCH WAS ACTUALLY READ, and mean it -- the whole array
44
+ * replaces the stored one. An empty array is therefore a WITHDRAWAL of every
45
+ * hold the previous reading was carrying, which is the dangerous direction: a
46
+ * caller that could not look must call nothing at all, never this with `[]`.
47
+ * `resolvers/focus-review-coverage.ts` is the production caller and holds that
48
+ * precondition.
49
+ *
50
+ * `deps` is the product-api seam (queries/shared.ts CallApiDeps): production
51
+ * passes nothing, a test injects a fake client rather than mock.module-ing the
52
+ * ambient one.
53
+ */
54
+ export declare function setBranchWorkDeliveryIds(focusId: string, deliveryIds: readonly string[], deps?: CallApiDeps): Promise<void>;
55
+ //# sourceMappingURL=focus-branch-work-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-branch-work-evidence.d.ts","sourceRoot":"","sources":["../../src/queries/focus-branch-work-evidence.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,IAAI,CAAC,CAKf"}
@@ -0,0 +1,65 @@
1
+ // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
+ // Pinned by: packages/daemon/src/completion/review-coverage-seam.test.ts,
3
+ // packages/daemon/src/queries/focus-branch-work-evidence.test.ts,
4
+ // packages/daemon/src/resolvers/focus-review-coverage.test.ts
5
+ // PINNED-BY-END
6
+ /**
7
+ * The branch committed-work evidence write.
8
+ *
9
+ * The delivery ROW cannot carry this fact. A fast-forward merge-back records
10
+ * no `merge_commit_sha`, and a cancelled delivery's commits sit on the focus
11
+ * branch with nothing on the row naming them -- so only a caller holding the
12
+ * repository can see that the work exists. The daemon is that caller; the
13
+ * product-api delivery-create residue gate, which must ENFORCE on the same
14
+ * fact, runs on an edge runtime with no repository at all.
15
+ *
16
+ * So the side that can see it writes it down, through the same
17
+ * `daemon_update_focus_status` seam the review-coverage watermark uses
18
+ * (`focus-review-watermark.ts`). Its own module for the same two reasons that
19
+ * one has: it is a distinct fact with a distinct fail-closed direction, and
20
+ * `queries/focuses.ts` sits at the file-size ceiling.
21
+ *
22
+ * ONE DIRECTION, AND THEREFORE ONE FUNCTION. This module used to have a pair:
23
+ * a write and a retraction, because a stored reading could RELEASE a hold and
24
+ * a reading that turned out to be wrong had to be taken back. The retraction
25
+ * is a WRITE, so it was missing in exactly the failure it existed for -- the
26
+ * write channel being down -- and dating the reading only bounded how long
27
+ * the wrong answer stood. The gate now reads a stored reading POSITIVELY only
28
+ * (`supabase/functions/_shared/delivery-review-coverage.ts` ->
29
+ * `resolveBranchWorkEvidence`): ids
30
+ * add holds, their absence grants nothing. With nothing to take back there is
31
+ * nothing to retract, so the retraction is gone rather than made reliable.
32
+ *
33
+ * @module queries/focus-branch-work-evidence
34
+ */
35
+ import { callApi } from './shared.js';
36
+ /**
37
+ * Record WHICH of a focus's deliveries have commits on the focus branch
38
+ * (product_focuses.branch_work_delivery_ids), as proved by a
39
+ * `Telora-Delivery` trailer search in the focus's repository.
40
+ *
41
+ * NEVER MARKS ANYTHING REVIEWED, AND NEVER RELEASES ANYTHING. An id in this
42
+ * set makes a delivery work-bearing, and therefore holdable by the residue
43
+ * gate under the normal coverage rules. An id that is absent from it asserts
44
+ * nothing at all: the gate treats a stored reading as positive-only, because
45
+ * "the branch carries no commits for this delivery" is true of an INSTANT and
46
+ * this value is read minutes or hours later, by a runtime that cannot check.
47
+ *
48
+ * CALL ONLY WHEN THE BRANCH WAS ACTUALLY READ, and mean it -- the whole array
49
+ * replaces the stored one. An empty array is therefore a WITHDRAWAL of every
50
+ * hold the previous reading was carrying, which is the dangerous direction: a
51
+ * caller that could not look must call nothing at all, never this with `[]`.
52
+ * `resolvers/focus-review-coverage.ts` is the production caller and holds that
53
+ * precondition.
54
+ *
55
+ * `deps` is the product-api seam (queries/shared.ts CallApiDeps): production
56
+ * passes nothing, a test injects a fake client rather than mock.module-ing the
57
+ * ambient one.
58
+ */
59
+ export async function setBranchWorkDeliveryIds(focusId, deliveryIds, deps = {}) {
60
+ await (deps.callApi ?? callApi)('daemon_update_focus_status', {
61
+ focusId,
62
+ fields: { branchWorkDeliveryIds: [...deliveryIds] },
63
+ });
64
+ }
65
+ //# sourceMappingURL=focus-branch-work-evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-branch-work-evidence.js","sourceRoot":"","sources":["../../src/queries/focus-branch-work-evidence.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,0EAA0E;AAC1E,oEAAoE;AACpE,gEAAgE;AAChE,gBAAgB;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAe,EACf,WAA8B,EAC9B,OAAoB,EAAE;IAEtB,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,4BAA4B,EAAE;QAC5D,OAAO;QACP,MAAM,EAAE,EAAE,qBAAqB,EAAE,CAAC,GAAG,WAAW,CAAC,EAAE;KACpD,CAAC,CAAC;AACL,CAAC"}