@dsh-enhanced/assistant-work-items 0.0.0-stage → 0.1.66

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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +685 -2
  3. package/cordis.patch.yml +11 -0
  4. package/lib/acceptance-binding.d.ts +86 -0
  5. package/lib/acceptance-binding.d.ts.map +1 -0
  6. package/lib/acceptance-binding.js +250 -0
  7. package/lib/acceptance-binding.js.map +1 -0
  8. package/lib/admission.d.ts +95 -0
  9. package/lib/admission.d.ts.map +1 -0
  10. package/lib/admission.js +642 -0
  11. package/lib/admission.js.map +1 -0
  12. package/lib/authority.d.ts +92 -0
  13. package/lib/authority.d.ts.map +1 -0
  14. package/lib/authority.js +205 -0
  15. package/lib/authority.js.map +1 -0
  16. package/lib/config.d.ts +365 -0
  17. package/lib/config.d.ts.map +1 -0
  18. package/lib/config.js +672 -0
  19. package/lib/config.js.map +1 -0
  20. package/lib/continuation-contract.d.ts +126 -0
  21. package/lib/continuation-contract.d.ts.map +1 -0
  22. package/lib/continuation-contract.js +109 -0
  23. package/lib/continuation-contract.js.map +1 -0
  24. package/lib/continuation-record.d.ts +32 -0
  25. package/lib/continuation-record.d.ts.map +1 -0
  26. package/lib/continuation-record.js +57 -0
  27. package/lib/continuation-record.js.map +1 -0
  28. package/lib/continuation.d.ts +89 -0
  29. package/lib/continuation.d.ts.map +1 -0
  30. package/lib/continuation.js +607 -0
  31. package/lib/continuation.js.map +1 -0
  32. package/lib/diagnosis-contract.d.ts +95 -0
  33. package/lib/diagnosis-contract.d.ts.map +1 -0
  34. package/lib/diagnosis-contract.js +167 -0
  35. package/lib/diagnosis-contract.js.map +1 -0
  36. package/lib/diagnosis.d.ts +70 -0
  37. package/lib/diagnosis.d.ts.map +1 -0
  38. package/lib/diagnosis.js +466 -0
  39. package/lib/diagnosis.js.map +1 -0
  40. package/lib/dispatch.d.ts +100 -0
  41. package/lib/dispatch.d.ts.map +1 -0
  42. package/lib/dispatch.js +317 -0
  43. package/lib/dispatch.js.map +1 -0
  44. package/lib/engineering-context.d.ts +86 -0
  45. package/lib/engineering-context.d.ts.map +1 -0
  46. package/lib/engineering-context.js +263 -0
  47. package/lib/engineering-context.js.map +1 -0
  48. package/lib/evaluation.d.ts +125 -0
  49. package/lib/evaluation.d.ts.map +1 -0
  50. package/lib/evaluation.js +295 -0
  51. package/lib/evaluation.js.map +1 -0
  52. package/lib/event-follow.d.ts +93 -0
  53. package/lib/event-follow.d.ts.map +1 -0
  54. package/lib/event-follow.js +150 -0
  55. package/lib/event-follow.js.map +1 -0
  56. package/lib/feedback-targets.d.ts +91 -0
  57. package/lib/feedback-targets.d.ts.map +1 -0
  58. package/lib/feedback-targets.js +362 -0
  59. package/lib/feedback-targets.js.map +1 -0
  60. package/lib/index.d.ts +27 -0
  61. package/lib/index.d.ts.map +1 -0
  62. package/lib/index.js +25 -0
  63. package/lib/index.js.map +1 -0
  64. package/lib/intake-admission.d.ts +49 -0
  65. package/lib/intake-admission.d.ts.map +1 -0
  66. package/lib/intake-admission.js +100 -0
  67. package/lib/intake-admission.js.map +1 -0
  68. package/lib/intake-evaluation-runtime.d.ts +74 -0
  69. package/lib/intake-evaluation-runtime.d.ts.map +1 -0
  70. package/lib/intake-evaluation-runtime.js +343 -0
  71. package/lib/intake-evaluation-runtime.js.map +1 -0
  72. package/lib/intake-evaluation.d.ts +180 -0
  73. package/lib/intake-evaluation.d.ts.map +1 -0
  74. package/lib/intake-evaluation.js +440 -0
  75. package/lib/intake-evaluation.js.map +1 -0
  76. package/lib/intake.d.ts +118 -0
  77. package/lib/intake.d.ts.map +1 -0
  78. package/lib/intake.js +137 -0
  79. package/lib/intake.js.map +1 -0
  80. package/lib/ledger.d.ts +86 -0
  81. package/lib/ledger.d.ts.map +1 -0
  82. package/lib/ledger.js +145 -0
  83. package/lib/ledger.js.map +1 -0
  84. package/lib/mandate.d.ts +45 -0
  85. package/lib/mandate.d.ts.map +1 -0
  86. package/lib/mandate.js +168 -0
  87. package/lib/mandate.js.map +1 -0
  88. package/lib/outcome.d.ts +137 -0
  89. package/lib/outcome.d.ts.map +1 -0
  90. package/lib/outcome.js +303 -0
  91. package/lib/outcome.js.map +1 -0
  92. package/lib/owner-access.d.ts +35 -0
  93. package/lib/owner-access.d.ts.map +1 -0
  94. package/lib/owner-access.js +152 -0
  95. package/lib/owner-access.js.map +1 -0
  96. package/lib/owner-continuation.d.ts +27 -0
  97. package/lib/owner-continuation.d.ts.map +1 -0
  98. package/lib/owner-continuation.js +131 -0
  99. package/lib/owner-continuation.js.map +1 -0
  100. package/lib/owner-recall.d.ts +85 -0
  101. package/lib/owner-recall.d.ts.map +1 -0
  102. package/lib/owner-recall.js +134 -0
  103. package/lib/owner-recall.js.map +1 -0
  104. package/lib/owner-replies.d.ts +44 -0
  105. package/lib/owner-replies.d.ts.map +1 -0
  106. package/lib/owner-replies.js +232 -0
  107. package/lib/owner-replies.js.map +1 -0
  108. package/lib/peers.d.ts +622 -0
  109. package/lib/peers.d.ts.map +1 -0
  110. package/lib/peers.js +10 -0
  111. package/lib/peers.js.map +1 -0
  112. package/lib/policy-notice.d.ts +31 -0
  113. package/lib/policy-notice.d.ts.map +1 -0
  114. package/lib/policy-notice.js +137 -0
  115. package/lib/policy-notice.js.map +1 -0
  116. package/lib/reply-contract.d.ts +67 -0
  117. package/lib/reply-contract.d.ts.map +1 -0
  118. package/lib/reply-contract.js +58 -0
  119. package/lib/reply-contract.js.map +1 -0
  120. package/lib/service.d.ts +625 -0
  121. package/lib/service.d.ts.map +1 -0
  122. package/lib/service.js +2388 -0
  123. package/lib/service.js.map +1 -0
  124. package/lib/settlement.d.ts +74 -0
  125. package/lib/settlement.d.ts.map +1 -0
  126. package/lib/settlement.js +233 -0
  127. package/lib/settlement.js.map +1 -0
  128. package/lib/signals.d.ts +176 -0
  129. package/lib/signals.d.ts.map +1 -0
  130. package/lib/signals.js +497 -0
  131. package/lib/signals.js.map +1 -0
  132. package/lib/store.d.ts +789 -0
  133. package/lib/store.d.ts.map +1 -0
  134. package/lib/store.js +3266 -0
  135. package/lib/store.js.map +1 -0
  136. package/lib/tools.d.ts +7 -0
  137. package/lib/tools.d.ts.map +1 -0
  138. package/lib/tools.js +443 -0
  139. package/lib/tools.js.map +1 -0
  140. package/lib/types.d.ts +831 -0
  141. package/lib/types.d.ts.map +1 -0
  142. package/lib/types.js +29 -0
  143. package/lib/types.js.map +1 -0
  144. package/lib/version.d.ts +2 -0
  145. package/lib/version.d.ts.map +1 -0
  146. package/lib/version.js +2 -0
  147. package/lib/version.js.map +1 -0
  148. package/lib/workspace.d.ts +43 -0
  149. package/lib/workspace.d.ts.map +1 -0
  150. package/lib/workspace.js +137 -0
  151. package/lib/workspace.js.map +1 -0
  152. package/package.json +101 -3
package/lib/mandate.js ADDED
@@ -0,0 +1,168 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { ACCEPTANCE_CONTRACT_ID, acceptanceBindingIsUsable } from "./acceptance-binding.js";
3
+ import { WorkItemError } from "./types.js";
4
+ const DECISION_PROTOCOL = 'work-items/execute-decision/v1';
5
+ const MANDATE_PROTOCOL = 'work-items/mandate/v1';
6
+ /** Printable, no spaces; `decision:` + id must stay inside the 256-byte externalId cap. */
7
+ const DECISION_ID = /^[\x21-\x7e]{1,200}$/;
8
+ const RULE_ID = /^[\x21-\x7e]{1,256}$/;
9
+ const DIGEST = /^[0-9a-f]{64}$/;
10
+ const MAX_BUDGET = 1_000_000_000;
11
+ function fail(message) {
12
+ throw new WorkItemError('invalid-input', message);
13
+ }
14
+ function exactKeys(value, allowed, field) {
15
+ for (const key of Object.keys(value)) {
16
+ if (!allowed.includes(key))
17
+ fail(`${field} contains unknown field ${key}`);
18
+ }
19
+ }
20
+ function plainObject(value, field) {
21
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
22
+ fail(`${field} must be an object`);
23
+ return value;
24
+ }
25
+ /**
26
+ * Structural validation of one execute decision. Pure and deterministic.
27
+ *
28
+ * Only the shape is checked here; kind/title/brief/binding normalization stays
29
+ * with `WorkItemAdmission` so the two admission paths cannot drift.
30
+ */
31
+ export function normalizeExecuteDecision(value) {
32
+ const decision = plainObject(value, 'decision');
33
+ exactKeys(decision, ['protocol', 'decisionId', 'verdict', 'origin', 'mode', 'policyRuleId', 'budgetRemaining', 'mandate', 'acceptance'], 'decision');
34
+ if (decision['protocol'] !== DECISION_PROTOCOL)
35
+ fail('decision.protocol is not supported');
36
+ if (decision['verdict'] !== 'execute')
37
+ fail('decision.verdict must be execute');
38
+ const decisionId = decision['decisionId'];
39
+ if (typeof decisionId !== 'string' || !DECISION_ID.test(decisionId))
40
+ fail('decision.decisionId has an invalid shape');
41
+ const origin = decision['origin'];
42
+ if (origin !== 'explicit' && origin !== 'inferred')
43
+ fail('decision.origin must be explicit or inferred');
44
+ const mode = decision['mode'];
45
+ if (mode !== 'observe' && mode !== 'auto')
46
+ fail('decision.mode must be observe or auto');
47
+ const rule = decision['policyRuleId'];
48
+ if (rule !== undefined && (typeof rule !== 'string' || !RULE_ID.test(rule)))
49
+ fail('decision.policyRuleId has an invalid shape');
50
+ const budget = decision['budgetRemaining'];
51
+ if (typeof budget !== 'number' || !Number.isSafeInteger(budget) || budget < 0 || budget > MAX_BUDGET) {
52
+ fail('decision.budgetRemaining must be a non-negative integer');
53
+ }
54
+ const mandate = plainObject(decision['mandate'], 'decision.mandate');
55
+ exactKeys(mandate, ['kind', 'title', 'brief', 'originBindingId', 'acceptanceRef'], 'decision.mandate');
56
+ for (const key of ['kind', 'title', 'brief', 'originBindingId', 'acceptanceRef']) {
57
+ if (typeof mandate[key] !== 'string')
58
+ fail(`decision.mandate.${key} must be a string`);
59
+ }
60
+ let acceptance;
61
+ if (decision['acceptance'] !== undefined) {
62
+ const handle = plainObject(decision['acceptance'], 'decision.acceptance');
63
+ exactKeys(handle, ['contractId', 'contractDigest'], 'decision.acceptance');
64
+ const contractId = handle['contractId'];
65
+ if (typeof contractId !== 'string' || !ACCEPTANCE_CONTRACT_ID.test(contractId))
66
+ fail('decision.acceptance.contractId has an invalid shape');
67
+ const contractDigest = handle['contractDigest'];
68
+ if (typeof contractDigest !== 'string' || !DIGEST.test(contractDigest))
69
+ fail('decision.acceptance.contractDigest must be a sha256 hex digest');
70
+ acceptance = Object.freeze({ contractId, contractDigest });
71
+ }
72
+ return Object.freeze({
73
+ decisionId,
74
+ origin,
75
+ mode,
76
+ policyRuleId: rule,
77
+ budgetRemaining: budget,
78
+ acceptance,
79
+ input: Object.freeze({
80
+ kind: mandate['kind'],
81
+ externalId: decisionExternalId(decisionId),
82
+ title: mandate['title'],
83
+ brief: mandate['brief'],
84
+ originBindingId: mandate['originBindingId'],
85
+ acceptanceRef: mandate['acceptanceRef'],
86
+ }),
87
+ });
88
+ }
89
+ /** Stable external identity: the decision id alone decides the dedup key. */
90
+ export function decisionExternalId(decisionId) {
91
+ return `decision:${decisionId}`;
92
+ }
93
+ /**
94
+ * The inferred-execution gate. All three conditions must hold at once; an
95
+ * explicit decision is not gated here (Policy and ordinary admission gates
96
+ * still apply to it).
97
+ */
98
+ export function decisionRefusal(decision) {
99
+ if (decision.origin !== 'inferred')
100
+ return undefined;
101
+ if (decision.mode !== 'auto')
102
+ return 'inferred-requires-auto';
103
+ if (decision.policyRuleId === undefined)
104
+ return 'inferred-requires-rule';
105
+ if (decision.budgetRemaining < 1)
106
+ return 'budget-exhausted';
107
+ return undefined;
108
+ }
109
+ /**
110
+ * Digest over the decision identity after admission normalized the mandate.
111
+ *
112
+ * Mode and remaining budget are admission-time facts, not identity: a replay
113
+ * of the same decision after the budget moved must resolve to the same item,
114
+ * while a different scope under the same id must not.
115
+ */
116
+ export function mandateDigest(decision, normalized) {
117
+ const canonical = JSON.stringify([
118
+ MANDATE_PROTOCOL,
119
+ decision.decisionId,
120
+ decision.origin,
121
+ decision.policyRuleId ?? null,
122
+ normalized.kind,
123
+ normalized.title,
124
+ normalized.brief,
125
+ normalized.originBindingId,
126
+ normalized.acceptanceRef,
127
+ // Appended only when bound, so every digest admitted before slice 4 is unchanged.
128
+ ...(decision.acceptance === undefined ? [] : [['acceptance', decision.acceptance.contractId, decision.acceptance.contractDigest]]),
129
+ ]);
130
+ return createHash('sha256').update(canonical, 'utf8').digest('hex');
131
+ }
132
+ export function buildMandateBasis(decision, digest, acceptance) {
133
+ return Object.freeze({
134
+ protocol: MANDATE_PROTOCOL,
135
+ decisionId: decision.decisionId,
136
+ origin: decision.origin,
137
+ mode: decision.mode,
138
+ ...(decision.policyRuleId === undefined ? {} : { ruleId: decision.policyRuleId }),
139
+ budgetRemaining: decision.budgetRemaining,
140
+ digest,
141
+ ...(acceptance === undefined ? {} : { acceptance }),
142
+ });
143
+ }
144
+ /** Structural check of a stored mandate; anything else is a malformed basis. */
145
+ export function mandateIsUsable(value) {
146
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
147
+ return false;
148
+ const mandate = value;
149
+ for (const key of Object.keys(mandate)) {
150
+ if (!['protocol', 'decisionId', 'origin', 'mode', 'ruleId', 'budgetRemaining', 'digest', 'acceptance'].includes(key))
151
+ return false;
152
+ }
153
+ const budget = mandate['budgetRemaining'];
154
+ const rule = mandate['ruleId'];
155
+ const usable = mandate['protocol'] === MANDATE_PROTOCOL
156
+ && typeof mandate['decisionId'] === 'string' && DECISION_ID.test(mandate['decisionId'])
157
+ && (mandate['origin'] === 'explicit' || mandate['origin'] === 'inferred')
158
+ && (mandate['mode'] === 'observe' || mandate['mode'] === 'auto')
159
+ && (rule === undefined || typeof rule === 'string' && RULE_ID.test(rule))
160
+ && typeof budget === 'number' && Number.isSafeInteger(budget) && budget >= 0 && budget <= MAX_BUDGET
161
+ && typeof mandate['digest'] === 'string' && DIGEST.test(mandate['digest'])
162
+ && (mandate['acceptance'] === undefined || acceptanceBindingIsUsable(mandate['acceptance']));
163
+ if (!usable)
164
+ return false;
165
+ // An inferred mandate that could never have passed the gate is corrupt.
166
+ return mandate['origin'] !== 'inferred' || mandate['mode'] === 'auto' && rule !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AAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACzB,wEAAwE;IACxE,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM,IAAI,IAAI,KAAK,SAAS,IAAK,MAAiB,IAAI,CAAC,CAAA;AACxH,CAAC"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Outcome derivation: the pure, deterministic rules that turn a durable
3
+ * lifecycle transition or an independently observed receipt into one
4
+ * append-only outcome revision.
5
+ *
6
+ * The central rule of this module is that a worker self-report is never proof.
7
+ * A `ready` report only *opens* a bounded window in which the delivery channel
8
+ * may still produce an authenticated execution receipt; until that receipt is
9
+ * observed, the objective stays `unknown`. No automatic path in this plugin can
10
+ * ever derive `achieved` or `partial`.
11
+ */
12
+ import type { PeerOwnerForegroundTaskSource } from './peers.ts';
13
+ import type { WorkItemExecutionStatus, WorkItemObjectiveStatus, WorkItemOutcomeEvidence, WorkItemOutcomeEvidenceReason, WorkItemOutcomeEvidenceState, WorkItemOutcomeRecord, WorkItemOutcomeSettledBy, WorkItemOutcomeTrust, WorkItemProvenance, WorkItemRecord, WorkItemReportStatus } from './types.ts';
14
+ /** Source version whose receipts are authenticated execution evidence. */
15
+ export declare const OUTCOME_EVIDENCE_SOURCE = "assistant-delivery/owner-foreground-source/v1";
16
+ /**
17
+ * Signal source ids whose admitted items are tied to a guarded execution that
18
+ * `assistant-delivery` can later describe. Everything else has no independent
19
+ * channel and therefore settles as `not-applicable` immediately.
20
+ */
21
+ export declare const SETTLEABLE_SOURCE_IDS: readonly string[];
22
+ /** Hard cap on the canonical evidence payload; oversized evidence is dropped, never truncated. */
23
+ export declare const MAX_OUTCOME_EVIDENCE_BYTES = 2048;
24
+ /** Outcome fields a caller supplies; the store owns identity, revision and timestamps. */
25
+ export interface WorkItemOutcomeDraft {
26
+ readonly settledBy: WorkItemOutcomeSettledBy;
27
+ readonly executionStatus: WorkItemExecutionStatus;
28
+ readonly objectiveStatus: WorkItemObjectiveStatus;
29
+ readonly trust: WorkItemOutcomeTrust;
30
+ readonly evidenceState: WorkItemOutcomeEvidenceState;
31
+ readonly evidenceReason: WorkItemOutcomeEvidenceReason | null;
32
+ readonly evidence: WorkItemOutcomeEvidence | null;
33
+ readonly baselineSequence: number | null;
34
+ readonly inboxId: string | null;
35
+ /**
36
+ * Authority hash of the receipt that *admitted* this execution.
37
+ *
38
+ * Persisted so a later receipt can be fenced against the admitted owner
39
+ * route rather than against a same-pass value, which would be tautological.
40
+ */
41
+ readonly authorityHash: string | null;
42
+ readonly deadlineAt: number | null;
43
+ readonly settledAt: number;
44
+ }
45
+ /** The admitted execution an outcome is fenced above. */
46
+ export interface SettlementBaseline {
47
+ readonly inboxId: string;
48
+ readonly completionSequence: number;
49
+ /** Missing/invalid admitted hash still opens the window but can never match. */
50
+ readonly authorityHash: string | null;
51
+ }
52
+ /**
53
+ * Extract the execution baseline from an admission's provenance evidence.
54
+ *
55
+ * Only a settleable source carries one; a malformed or incomplete evidence
56
+ * object yields `null` rather than a guessed baseline, so the item settles as
57
+ * `not-applicable` instead of opening an unverifiable window.
58
+ */
59
+ export declare function settlementBaseline(provenance: WorkItemProvenance | null): SettlementBaseline | null;
60
+ /**
61
+ * Derive the outcome revision for a terminal report.
62
+ *
63
+ * `progress` and `waiting` are not terminal and produce nothing. `ready` is the
64
+ * only status that opens a settlement window, and only when the admitted signal
65
+ * has an independently observable execution.
66
+ */
67
+ export declare function deriveReportOutcome(input: {
68
+ readonly status: WorkItemReportStatus;
69
+ readonly provenance: WorkItemProvenance | null;
70
+ readonly now: number;
71
+ readonly windowMs: number;
72
+ }): WorkItemOutcomeDraft | null;
73
+ /** Terminal report statuses whose settlement a followed thread can defer. */
74
+ export type WorkItemDeferredReportStatus = Extract<WorkItemReportStatus, 'ready' | 'blocked' | 'failed'>;
75
+ /**
76
+ * Derive the outcome revision for a terminal report that was deferred until its
77
+ * followed threads closed.
78
+ *
79
+ * The report's own honest mapping is reused (a `ready` report stays
80
+ * `objectiveStatus: unknown`, a `blocked`/`failed` report stays
81
+ * `not-achieved`), but the revision is marked as thread-settled: closure is not
82
+ * delivery evidence, so the revision is `unverified` with `closed-by-thread`
83
+ * and never opens another window. This path can never derive `achieved` or
84
+ * `partial`.
85
+ */
86
+ export declare function threadClosureOutcome(input: {
87
+ readonly status: WorkItemDeferredReportStatus;
88
+ readonly provenance: WorkItemProvenance | null;
89
+ readonly now: number;
90
+ }): WorkItemOutcomeDraft;
91
+ /** Derive the outcome for a dropped (withdrawn) item. */
92
+ export declare function deriveWithdrawalOutcome(now: number): WorkItemOutcomeDraft;
93
+ /** Derive the outcome for an item whose attempt budget was exhausted. */
94
+ export declare function deriveRetryExhaustedOutcome(now: number): WorkItemOutcomeDraft;
95
+ /**
96
+ * Whether one delivery receipt is evidence for one pending outcome.
97
+ *
98
+ * Every clause is an authenticated identity check: same protocol, same inbox,
99
+ * same owner scope, same principal, same authority hash as the *admission* that
100
+ * opened the window, and a completion strictly newer than the admitted
101
+ * execution's sequence. A receipt for the *original* failed execution
102
+ * (sequence ≤ baseline) therefore never counts as evidence that the repair
103
+ * succeeded, and a receipt minted under a different owner route cannot settle
104
+ * an item admitted under this one.
105
+ */
106
+ export declare function matchesOutcomeEvidence(input: {
107
+ readonly item: WorkItemRecord;
108
+ readonly outcome: WorkItemOutcomeRecord;
109
+ readonly source: PeerOwnerForegroundTaskSource;
110
+ readonly authorityHash: string;
111
+ }): boolean;
112
+ /**
113
+ * Build the allowlisted evidence payload for one matched receipt.
114
+ *
115
+ * The payload is canonical JSON (fixed key order) and is either stored whole or
116
+ * dropped whole: oversized evidence becomes `null` with
117
+ * `evidence-too-large`, because a truncated receipt would be a fabricated one.
118
+ */
119
+ export declare function outcomeEvidenceFor(source: PeerOwnerForegroundTaskSource): {
120
+ readonly evidence: WorkItemOutcomeEvidence | null;
121
+ readonly reason: WorkItemOutcomeEvidenceReason | null;
122
+ };
123
+ /**
124
+ * Revision N+1 for a pending outcome whose window is still open but produced no
125
+ * matching receipt yet: the window expired with no evidence.
126
+ */
127
+ export declare function expiredOutcome(outcome: WorkItemOutcomeRecord, now: number, degraded: boolean): WorkItemOutcomeDraft;
128
+ /**
129
+ * Revision N+1 for a pending outcome that now has a matching receipt.
130
+ *
131
+ * Trust moves to `external-receipt` because an authenticated execution was
132
+ * observed, but the objective status is inherited unchanged: observed success
133
+ * of the guarded execution is still not proof that the owner's objective was
134
+ * achieved.
135
+ */
136
+ export declare function observedOutcome(outcome: WorkItemOutcomeRecord, evidence: WorkItemOutcomeEvidence | null, reason: WorkItemOutcomeEvidenceReason | null, now: number): WorkItemOutcomeDraft;
137
+ //# sourceMappingURL=outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAEnB,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,kDAAkD,CAAA;AAEtF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAiD,CAAA;AAEpG,kGAAkG;AAClG,eAAO,MAAM,0BAA0B,OAAO,CAAA;AAE9C,0FAA0F;AAC1F,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAA;IAC5C,QAAQ,CAAC,eAAe,EAAE,uBAAuB,CAAA;IACjD,QAAQ,CAAC,eAAe,EAAE,uBAAuB,CAAA;IACjD,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAA;IACpC,QAAQ,CAA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istant-delivery/owner-foreground-source/v1';
3
+ /**
4
+ * Signal source ids whose admitted items are tied to a guarded execution that
5
+ * `assistant-delivery` can later describe. Everything else has no independent
6
+ * channel and therefore settles as `not-applicable` immediately.
7
+ */
8
+ export const SETTLEABLE_SOURCE_IDS = Object.freeze(['owner-foreground-failures']);
9
+ /** Hard cap on the canonical evidence payload; oversized evidence is dropped, never truncated. */
10
+ export const MAX_OUTCOME_EVIDENCE_BYTES = 2048;
11
+ function nonEmptyString(value) {
12
+ return typeof value === 'string' && value !== '' ? value : null;
13
+ }
14
+ function positiveInteger(value) {
15
+ return typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? value : null;
16
+ }
17
+ /**
18
+ * Extract the execution baseline from an admission's provenance evidence.
19
+ *
20
+ * Only a settleable source carries one; a malformed or incomplete evidence
21
+ * object yields `null` rather than a guessed baseline, so the item settles as
22
+ * `not-applicable` instead of opening an unverifiable window.
23
+ */
24
+ export function settlementBaseline(provenance) {
25
+ if (provenance === null)
26
+ return null;
27
+ if (!SETTLEABLE_SOURCE_IDS.includes(provenance.source))
28
+ return null;
29
+ const evidence = provenance.evidence;
30
+ if (evidence === undefined)
31
+ return null;
32
+ const inboxId = nonEmptyString(evidence['inboxId']);
33
+ const completionSequence = positiveInteger(evidence['completionSequence']);
34
+ if (inboxId === null || completionSequence === null)
35
+ return null;
36
+ const authorityHash = nonEmptyString(evidence['authorityHash']);
37
+ return Object.freeze({ inboxId, completionSequence, authorityHash });
38
+ }
39
+ /**
40
+ * Derive the outcome revision for a terminal report.
41
+ *
42
+ * `progress` and `waiting` are not terminal and produce nothing. `ready` is the
43
+ * only status that opens a settlement window, and only when the admitted signal
44
+ * has an independently observable execution.
45
+ */
46
+ export function deriveReportOutcome(input) {
47
+ const baseline = settlementBaseline(input.provenance);
48
+ switch (input.status) {
49
+ case 'ready':
50
+ return baseline === null
51
+ ? Object.freeze({
52
+ settledBy: 'report-ready',
53
+ executionStatus: 'succeeded',
54
+ objectiveStatus: 'unknown',
55
+ trust: 'agent-self-report',
56
+ evidenceState: 'not-applicable',
57
+ evidenceReason: 'no-independent-source',
58
+ evidence: null,
59
+ baselineSequence: null,
60
+ inboxId: null,
61
+ authorityHash: null,
62
+ deadlineAt: null,
63
+ settledAt: input.now,
64
+ })
65
+ : Object.freeze({
66
+ settledBy: 'report-ready',
67
+ executionStatus: 'succeeded',
68
+ objectiveStatus: 'unknown',
69
+ trust: 'agent-self-report',
70
+ evidenceState: 'pending',
71
+ evidenceReason: null,
72
+ evidence: null,
73
+ baselineSequence: baseline.completionSequence,
74
+ inboxId: baseline.inboxId,
75
+ authorityHash: baseline.authorityHash,
76
+ deadlineAt: input.now + input.windowMs,
77
+ settledAt: input.now,
78
+ });
79
+ case 'blocked':
80
+ return Object.freeze({
81
+ settledBy: 'report-blocked',
82
+ executionStatus: 'succeeded',
83
+ objectiveStatus: 'not-achieved',
84
+ trust: 'agent-self-report',
85
+ evidenceState: 'not-applicable',
86
+ evidenceReason: null,
87
+ evidence: null,
88
+ baselineSequence: null,
89
+ inboxId: null,
90
+ authorityHash: null,
91
+ deadlineAt: null,
92
+ settledAt: input.now,
93
+ });
94
+ case 'failed':
95
+ return Object.freeze({
96
+ settledBy: 'report-failed',
97
+ executionStatus: 'failed',
98
+ objectiveStatus: 'not-achieved',
99
+ trust: 'agent-self-report',
100
+ evidenceState: 'not-applicable',
101
+ evidenceReason: null,
102
+ evidence: null,
103
+ baselineSequence: null,
104
+ inboxId: null,
105
+ authorityHash: null,
106
+ deadlineAt: null,
107
+ settledAt: input.now,
108
+ });
109
+ case 'progress':
110
+ case 'waiting':
111
+ return null;
112
+ }
113
+ }
114
+ /**
115
+ * Derive the outcome revision for a terminal report that was deferred until its
116
+ * followed threads closed.
117
+ *
118
+ * The report's own honest mapping is reused (a `ready` report stays
119
+ * `objectiveStatus: unknown`, a `blocked`/`failed` report stays
120
+ * `not-achieved`), but the revision is marked as thread-settled: closure is not
121
+ * delivery evidence, so the revision is `unverified` with `closed-by-thread`
122
+ * and never opens another window. This path can never derive `achieved` or
123
+ * `partial`.
124
+ */
125
+ export function threadClosureOutcome(input) {
126
+ const base = deriveReportOutcome({ ...input, windowMs: 0 });
127
+ if (base === null)
128
+ throw new Error('a terminal report status always derives an outcome');
129
+ return Object.freeze({
130
+ ...base,
131
+ settledBy: 'closed-by-thread',
132
+ evidenceState: 'unverified',
133
+ evidenceReason: 'closed-by-thread',
134
+ evidence: null,
135
+ deadlineAt: null,
136
+ settledAt: input.now,
137
+ });
138
+ }
139
+ /** Derive the outcome for a dropped (withdrawn) item. */
140
+ export function deriveWithdrawalOutcome(now) {
141
+ return Object.freeze({
142
+ settledBy: 'withdrawn',
143
+ executionStatus: 'cancelled',
144
+ objectiveStatus: 'unknown',
145
+ trust: 'external-receipt',
146
+ evidenceState: 'not-applicable',
147
+ evidenceReason: null,
148
+ evidence: null,
149
+ baselineSequence: null,
150
+ inboxId: null,
151
+ authorityHash: null,
152
+ deadlineAt: null,
153
+ settledAt: now,
154
+ });
155
+ }
156
+ /** Derive the outcome for an item whose attempt budget was exhausted. */
157
+ export function deriveRetryExhaustedOutcome(now) {
158
+ return Object.freeze({
159
+ settledBy: 'retry-exhausted',
160
+ executionStatus: 'unknown',
161
+ objectiveStatus: 'not-achieved',
162
+ trust: 'agent-self-report',
163
+ evidenceState: 'not-applicable',
164
+ evidenceReason: null,
165
+ evidence: null,
166
+ baselineSequence: null,
167
+ inboxId: null,
168
+ authorityHash: null,
169
+ deadlineAt: null,
170
+ settledAt: now,
171
+ });
172
+ }
173
+ /**
174
+ * Whether one delivery receipt is evidence for one pending outcome.
175
+ *
176
+ * Every clause is an authenticated identity check: same protocol, same inbox,
177
+ * same owner scope, same principal, same authority hash as the *admission* that
178
+ * opened the window, and a completion strictly newer than the admitted
179
+ * execution's sequence. A receipt for the *original* failed execution
180
+ * (sequence ≤ baseline) therefore never counts as evidence that the repair
181
+ * succeeded, and a receipt minted under a different owner route cannot settle
182
+ * an item admitted under this one.
183
+ */
184
+ export function matchesOutcomeEvidence(input) {
185
+ const { item, outcome, source, authorityHash } = input;
186
+ if (source.protocol !== OUTCOME_EVIDENCE_SOURCE)
187
+ return false;
188
+ if (outcome.inboxId === null || outcome.baselineSequence === null)
189
+ return false;
190
+ // The fence is the *admitted* hash persisted on the outcome, not whatever the
191
+ // current receipt happens to claim.
192
+ if (outcome.authorityHash === null || source.authorityHash !== outcome.authorityHash)
193
+ return false;
194
+ if (source.inboxId !== outcome.inboxId)
195
+ return false;
196
+ if (source.completionSequence <= outcome.baselineSequence)
197
+ return false;
198
+ if (source.execution.status !== 'succeeded')
199
+ return false;
200
+ if (source.execution.quiescent !== true)
201
+ return false;
202
+ if (source.scope.workspace !== item.scope.workspace)
203
+ return false;
204
+ if (source.scope.preset !== item.scope.preset)
205
+ return false;
206
+ if (source.principalId !== item.scope.principalId)
207
+ return false;
208
+ if (source.authorityHash !== authorityHash)
209
+ return false;
210
+ return true;
211
+ }
212
+ /** Evidence keys in canonical serialization order; nothing else may reach the ledger. */
213
+ const EVIDENCE_ORDER = [
214
+ 'inboxId',
215
+ 'completionSequence',
216
+ 'completedAt',
217
+ 'executionStatus',
218
+ 'sourceDigest',
219
+ 'bindingVersion',
220
+ 'bindingGeneration',
221
+ 'scope',
222
+ ];
223
+ function scopeLabel(source) {
224
+ return `${source.scope.workspace}/${source.scope.preset}`;
225
+ }
226
+ /**
227
+ * Build the allowlisted evidence payload for one matched receipt.
228
+ *
229
+ * The payload is canonical JSON (fixed key order) and is either stored whole or
230
+ * dropped whole: oversized evidence becomes `null` with
231
+ * `evidence-too-large`, because a truncated receipt would be a fabricated one.
232
+ */
233
+ export function outcomeEvidenceFor(source) {
234
+ const payload = {
235
+ inboxId: source.inboxId,
236
+ completionSequence: source.completionSequence,
237
+ completedAt: source.execution.completedAt,
238
+ executionStatus: source.execution.status,
239
+ sourceDigest: source.sourceDigest,
240
+ bindingVersion: source.binding.version,
241
+ bindingGeneration: source.binding.generation,
242
+ scope: scopeLabel(source),
243
+ };
244
+ // Re-serialize through the ordered key list so the stored JSON is canonical
245
+ // regardless of how the caller built the object.
246
+ const ordered = {};
247
+ for (const key of EVIDENCE_ORDER) {
248
+ const value = payload[key];
249
+ if (value !== undefined)
250
+ ordered[key] = value;
251
+ }
252
+ const evidence = Object.freeze(ordered);
253
+ const bytes = Buffer.byteLength(JSON.stringify(evidence), 'utf8');
254
+ if (bytes > MAX_OUTCOME_EVIDENCE_BYTES) {
255
+ return Object.freeze({ evidence: null, reason: 'evidence-too-large' });
256
+ }
257
+ return Object.freeze({ evidence, reason: null });
258
+ }
259
+ /**
260
+ * Revision N+1 for a pending outcome whose window is still open but produced no
261
+ * matching receipt yet: the window expired with no evidence.
262
+ */
263
+ export function expiredOutcome(outcome, now, degraded) {
264
+ return Object.freeze({
265
+ settledBy: 'window-expired',
266
+ executionStatus: outcome.executionStatus,
267
+ objectiveStatus: outcome.objectiveStatus,
268
+ trust: outcome.trust,
269
+ evidenceState: 'unverified',
270
+ evidenceReason: (degraded ? 'channel-unavailable' : 'window-expired'),
271
+ evidence: null,
272
+ baselineSequence: outcome.baselineSequence,
273
+ inboxId: outcome.inboxId,
274
+ authorityHash: outcome.authorityHash,
275
+ deadlineAt: null,
276
+ settledAt: now,
277
+ });
278
+ }
279
+ /**
280
+ * Revision N+1 for a pending outcome that now has a matching receipt.
281
+ *
282
+ * Trust moves to `external-receipt` because an authenticated execution was
283
+ * observed, but the objective status is inherited unchanged: observed success
284
+ * of the guarded execution is still not proof that the owner's objective was
285
+ * achieved.
286
+ */
287
+ export function observedOutcome(outcome, evidence, reason, now) {
288
+ return Object.freeze({
289
+ settledBy: 'observed-evidence',
290
+ executionStatus: outcome.executionStatus,
291
+ objectiveStatus: outcome.objectiveStatus,
292
+ trust: 'external-receipt',
293
+ evidenceState: evidence === null ? 'unverified' : 'observed',
294
+ evidenceReason: evidence === null ? reason : null,
295
+ evidence,
296
+ baselineSequence: outcome.baselineSequence,
297
+ inboxId: outcome.inboxId,
298
+ authorityHash: outcome.authorityHash,
299
+ deadlineAt: null,
300
+ settledAt: now,
301
+ });
302
+ }
303
+ //# sourceMappingURL=outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcome.js","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AA0BA,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,+CAA+C,CAAA;AAEtF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAA;AAEpG,kGAAkG;AAClG,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAA;AAgC9C,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACjE,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AAC7F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC;IACtE,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IACpC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IACnE,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;IACpC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IACvC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;IACnD,MAAM,kBAAkB,GAAG,eAAe,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAA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