@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.
- package/LICENSE +21 -0
- package/README.md +685 -2
- package/cordis.patch.yml +11 -0
- package/lib/acceptance-binding.d.ts +86 -0
- package/lib/acceptance-binding.d.ts.map +1 -0
- package/lib/acceptance-binding.js +250 -0
- package/lib/acceptance-binding.js.map +1 -0
- package/lib/admission.d.ts +95 -0
- package/lib/admission.d.ts.map +1 -0
- package/lib/admission.js +642 -0
- package/lib/admission.js.map +1 -0
- package/lib/authority.d.ts +92 -0
- package/lib/authority.d.ts.map +1 -0
- package/lib/authority.js +205 -0
- package/lib/authority.js.map +1 -0
- package/lib/config.d.ts +365 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +672 -0
- package/lib/config.js.map +1 -0
- package/lib/continuation-contract.d.ts +126 -0
- package/lib/continuation-contract.d.ts.map +1 -0
- package/lib/continuation-contract.js +109 -0
- package/lib/continuation-contract.js.map +1 -0
- package/lib/continuation-record.d.ts +32 -0
- package/lib/continuation-record.d.ts.map +1 -0
- package/lib/continuation-record.js +57 -0
- package/lib/continuation-record.js.map +1 -0
- package/lib/continuation.d.ts +89 -0
- package/lib/continuation.d.ts.map +1 -0
- package/lib/continuation.js +607 -0
- package/lib/continuation.js.map +1 -0
- package/lib/diagnosis-contract.d.ts +95 -0
- package/lib/diagnosis-contract.d.ts.map +1 -0
- package/lib/diagnosis-contract.js +167 -0
- package/lib/diagnosis-contract.js.map +1 -0
- package/lib/diagnosis.d.ts +70 -0
- package/lib/diagnosis.d.ts.map +1 -0
- package/lib/diagnosis.js +466 -0
- package/lib/diagnosis.js.map +1 -0
- package/lib/dispatch.d.ts +100 -0
- package/lib/dispatch.d.ts.map +1 -0
- package/lib/dispatch.js +317 -0
- package/lib/dispatch.js.map +1 -0
- package/lib/engineering-context.d.ts +86 -0
- package/lib/engineering-context.d.ts.map +1 -0
- package/lib/engineering-context.js +263 -0
- package/lib/engineering-context.js.map +1 -0
- package/lib/evaluation.d.ts +125 -0
- package/lib/evaluation.d.ts.map +1 -0
- package/lib/evaluation.js +295 -0
- package/lib/evaluation.js.map +1 -0
- package/lib/event-follow.d.ts +93 -0
- package/lib/event-follow.d.ts.map +1 -0
- package/lib/event-follow.js +150 -0
- package/lib/event-follow.js.map +1 -0
- package/lib/feedback-targets.d.ts +91 -0
- package/lib/feedback-targets.d.ts.map +1 -0
- package/lib/feedback-targets.js +362 -0
- package/lib/feedback-targets.js.map +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +25 -0
- package/lib/index.js.map +1 -0
- package/lib/intake-admission.d.ts +49 -0
- package/lib/intake-admission.d.ts.map +1 -0
- package/lib/intake-admission.js +100 -0
- package/lib/intake-admission.js.map +1 -0
- package/lib/intake-evaluation-runtime.d.ts +74 -0
- package/lib/intake-evaluation-runtime.d.ts.map +1 -0
- package/lib/intake-evaluation-runtime.js +343 -0
- package/lib/intake-evaluation-runtime.js.map +1 -0
- package/lib/intake-evaluation.d.ts +180 -0
- package/lib/intake-evaluation.d.ts.map +1 -0
- package/lib/intake-evaluation.js +440 -0
- package/lib/intake-evaluation.js.map +1 -0
- package/lib/intake.d.ts +118 -0
- package/lib/intake.d.ts.map +1 -0
- package/lib/intake.js +137 -0
- package/lib/intake.js.map +1 -0
- package/lib/ledger.d.ts +86 -0
- package/lib/ledger.d.ts.map +1 -0
- package/lib/ledger.js +145 -0
- package/lib/ledger.js.map +1 -0
- package/lib/mandate.d.ts +45 -0
- package/lib/mandate.d.ts.map +1 -0
- package/lib/mandate.js +168 -0
- package/lib/mandate.js.map +1 -0
- package/lib/outcome.d.ts +137 -0
- package/lib/outcome.d.ts.map +1 -0
- package/lib/outcome.js +303 -0
- package/lib/outcome.js.map +1 -0
- package/lib/owner-access.d.ts +35 -0
- package/lib/owner-access.d.ts.map +1 -0
- package/lib/owner-access.js +152 -0
- package/lib/owner-access.js.map +1 -0
- package/lib/owner-continuation.d.ts +27 -0
- package/lib/owner-continuation.d.ts.map +1 -0
- package/lib/owner-continuation.js +131 -0
- package/lib/owner-continuation.js.map +1 -0
- package/lib/owner-recall.d.ts +85 -0
- package/lib/owner-recall.d.ts.map +1 -0
- package/lib/owner-recall.js +134 -0
- package/lib/owner-recall.js.map +1 -0
- package/lib/owner-replies.d.ts +44 -0
- package/lib/owner-replies.d.ts.map +1 -0
- package/lib/owner-replies.js +232 -0
- package/lib/owner-replies.js.map +1 -0
- package/lib/peers.d.ts +622 -0
- package/lib/peers.d.ts.map +1 -0
- package/lib/peers.js +10 -0
- package/lib/peers.js.map +1 -0
- package/lib/policy-notice.d.ts +31 -0
- package/lib/policy-notice.d.ts.map +1 -0
- package/lib/policy-notice.js +137 -0
- package/lib/policy-notice.js.map +1 -0
- package/lib/reply-contract.d.ts +67 -0
- package/lib/reply-contract.d.ts.map +1 -0
- package/lib/reply-contract.js +58 -0
- package/lib/reply-contract.js.map +1 -0
- package/lib/service.d.ts +625 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +2388 -0
- package/lib/service.js.map +1 -0
- package/lib/settlement.d.ts +74 -0
- package/lib/settlement.d.ts.map +1 -0
- package/lib/settlement.js +233 -0
- package/lib/settlement.js.map +1 -0
- package/lib/signals.d.ts +176 -0
- package/lib/signals.d.ts.map +1 -0
- package/lib/signals.js +497 -0
- package/lib/signals.js.map +1 -0
- package/lib/store.d.ts +789 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +3266 -0
- package/lib/store.js.map +1 -0
- package/lib/tools.d.ts +7 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tools.js +443 -0
- package/lib/tools.js.map +1 -0
- package/lib/types.d.ts +831 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +29 -0
- package/lib/types.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +2 -0
- package/lib/version.js.map +1 -0
- package/lib/workspace.d.ts +43 -0
- package/lib/workspace.d.ts.map +1 -0
- package/lib/workspace.js +137 -0
- package/lib/workspace.js.map +1 -0
- package/package.json +101 -3
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { acceptanceCanonicalJson, acceptanceDigest } from '@dsh-enhanced/task-acceptance-contract';
|
|
2
|
+
import { CONTINUATION_OWNER, continuationItemBasis, parseContinuationActivation } from './continuation-contract.js';
|
|
3
|
+
import { continuationDigest } from './continuation-record.js';
|
|
4
|
+
import { DIAGNOSIS_OWNER, diagnosisPlanMatchesItem } from './diagnosis-contract.js';
|
|
5
|
+
import { isReplyContinuationPlan, parseStoredContinuationPlan } from './reply-contract.js';
|
|
6
|
+
import { OPEN_STATES, WorkItemError } from './types.js';
|
|
7
|
+
export const MAX_ENGINEERING_PARENT_LINKS = 32;
|
|
8
|
+
export const MAX_ENGINEERING_INPUT_BYTES = 16384;
|
|
9
|
+
export const MAX_ENGINEERING_REPORT_BYTES = 262144;
|
|
10
|
+
export const MAX_ENGINEERING_MATERIAL_BYTES = 524288;
|
|
11
|
+
const HEX = /^[a-f0-9]{64}$/u;
|
|
12
|
+
function reject(message) { throw new WorkItemError('source-rejected', `engineering context ${message}`); }
|
|
13
|
+
function positive(value) { return typeof value === 'number' && Number.isSafeInteger(value) && value > 0; }
|
|
14
|
+
function identity(value, maximum = 512) {
|
|
15
|
+
return typeof value === 'string' && value.length > 0 && Buffer.byteLength(value) <= maximum && value.trim() === value && !/\p{Cc}/u.test(value)
|
|
16
|
+
&& Buffer.from(value, 'utf8').toString('utf8') === value;
|
|
17
|
+
}
|
|
18
|
+
function exactText(text, maximum, nonblank = false) {
|
|
19
|
+
if (typeof text !== 'string' || Buffer.byteLength(text) > maximum || Buffer.from(text, 'utf8').toString('utf8') !== text
|
|
20
|
+
|| nonblank && text.trim().length === 0)
|
|
21
|
+
reject('raw UTF-8 text is unavailable or exceeds its bound');
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
function freeze(value) {
|
|
25
|
+
if (value && typeof value === 'object') {
|
|
26
|
+
for (const item of Object.values(value))
|
|
27
|
+
freeze(item);
|
|
28
|
+
Object.freeze(value);
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
function supplier(value) {
|
|
33
|
+
if (!identity(value.provider, 4096) || !identity(value.model, 4096)
|
|
34
|
+
|| Object.hasOwn(value, 'reasoningEffort') && !identity(value.reasoningEffort, 4096))
|
|
35
|
+
reject('supplier is malformed');
|
|
36
|
+
return { provider: value.provider, model: value.model, ...(Object.hasOwn(value, 'reasoningEffort') ? { reasoningEffort: value.reasoningEffort } : {}) };
|
|
37
|
+
}
|
|
38
|
+
function itemMatchesOwner(item, proof, owner) {
|
|
39
|
+
if (item.observed || OPEN_STATES.includes(item.state) || item.owner.workspace !== item.scope.workspace || item.owner.agentPreset !== item.scope.preset
|
|
40
|
+
|| item.sourceId !== proof.sourceId || item.scope.workspace !== proof.scope.workspace || item.scope.preset !== proof.scope.preset
|
|
41
|
+
|| item.scope.ownerRouteId !== proof.owner.ownerRouteId || item.scope.principalId !== proof.owner.principalId
|
|
42
|
+
|| item.owner.principalRecordId !== proof.owner.principalRecordId || item.owner.principalVersion !== proof.owner.principalVersion
|
|
43
|
+
|| !identity(item.id, 256) || !identity(item.originBindingId, 256) || !positive(item.owner.generation) || !positive(item.owner.bindingVersion)
|
|
44
|
+
|| !positive(owner.generation) || !positive(owner.bindingVersion) || item.owner.generation > owner.generation
|
|
45
|
+
|| item.owner.generation === owner.generation && item.owner.bindingVersion !== owner.bindingVersion)
|
|
46
|
+
reject('item owner or binding lineage differs');
|
|
47
|
+
}
|
|
48
|
+
function parentLineage(parent, child) {
|
|
49
|
+
if (parent.owner.generation > child.owner.generation
|
|
50
|
+
|| parent.owner.generation === child.owner.generation && (parent.owner.bindingVersion !== child.owner.bindingVersion || parent.originBindingId !== child.originBindingId)) {
|
|
51
|
+
reject('parent binding lineage regressed');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function reportSnapshot(store, itemId, revision) {
|
|
55
|
+
if (!positive(revision))
|
|
56
|
+
reject('report cutoff is invalid');
|
|
57
|
+
const report = store.feedbackReportByRevision(itemId, revision);
|
|
58
|
+
if (!report || report.itemId !== itemId || report.revision !== revision || !positive(report.recordedAt))
|
|
59
|
+
reject('sealed report cutoff is missing');
|
|
60
|
+
const text = exactText(report.summary, 65536), fullTextDigest = continuationDigest(text), fullBytes = Buffer.byteLength(text);
|
|
61
|
+
const immutable = { protocol: 'assistant-work-items/engineering-report/v1', itemId, revision, status: report.status, text,
|
|
62
|
+
truncated: report.truncated, artifactPaths: report.artifactPaths, idempotencyKey: report.idempotencyKey, deliveryKey: report.deliveryKey, recordedAt: report.recordedAt };
|
|
63
|
+
const digest = acceptanceDigest(immutable);
|
|
64
|
+
return { ref: { itemId, revision, digest, fullTextDigest, fullBytes, status: report.status, truncated: report.truncated },
|
|
65
|
+
body: { itemId, revision, text, fullTextDigest, fullBytes }, fingerprint: digest };
|
|
66
|
+
}
|
|
67
|
+
/** Pure local chain reader. Delivery alone resolves the root Inbox and each
|
|
68
|
+
* reply envelope; report text never substitutes for authenticated owner input. */
|
|
69
|
+
function readChain(store, proof, owner) {
|
|
70
|
+
const reverse = [], seen = new Set();
|
|
71
|
+
let itemId = proof.itemId, totalInputs = 0, totalReports = 0;
|
|
72
|
+
for (;;) {
|
|
73
|
+
if (seen.has(itemId) || reverse.length > MAX_ENGINEERING_PARENT_LINKS)
|
|
74
|
+
reject('parent chain is cyclic or exceeds 32 links');
|
|
75
|
+
seen.add(itemId);
|
|
76
|
+
const item = store.findItemById(itemId);
|
|
77
|
+
if (!item)
|
|
78
|
+
reject('ancestor is missing');
|
|
79
|
+
itemMatchesOwner(item, proof, owner);
|
|
80
|
+
const record = store.getContinuation(itemId);
|
|
81
|
+
if (!record) {
|
|
82
|
+
const plan = store.readDiagnosisPlan(itemId);
|
|
83
|
+
if (!plan || !diagnosisPlanMatchesItem(plan, item) || plan.worker.owner !== DIAGNOSIS_OWNER || plan.worker.automationId !== item.workerAutomationId
|
|
84
|
+
|| plan.source.owner.principalRecordId !== item.owner.principalRecordId || plan.source.owner.principalVersion !== item.owner.principalVersion
|
|
85
|
+
|| plan.source.binding.id !== item.originBindingId || plan.source.binding.version !== item.owner.bindingVersion || plan.source.binding.generation !== item.owner.generation
|
|
86
|
+
|| !identity(plan.source.inboxId, 256) || plan.source.executionRef !== plan.source.inboxId || !HEX.test(plan.source.sourceDigest)
|
|
87
|
+
|| !positive(plan.source.completionSequence) || !identity(plan.source.binding.sessionId, 512)
|
|
88
|
+
|| !HEX.test(plan.worker.definitionHash) || !positive(plan.worker.definitionVersion))
|
|
89
|
+
reject('root is not a sealed owner diagnosis');
|
|
90
|
+
const planDigest = continuationDigest(acceptanceCanonicalJson(plan)), node = { itemId, planProtocol: plan.protocol, planDigest,
|
|
91
|
+
input: { kind: 'foreground', inboxId: plan.source.inboxId, sourceDigest: plan.source.sourceDigest, executionRef: plan.source.executionRef,
|
|
92
|
+
completionSequence: plan.source.completionSequence, binding: { id: plan.source.binding.id, version: plan.source.binding.version, generation: plan.source.binding.generation } }, parent: null };
|
|
93
|
+
reverse.push({ item, node, planSupplier: supplier(plan.contract), producer: { owner: DIAGNOSIS_OWNER, automationId: item.workerAutomationId,
|
|
94
|
+
definitionHash: plan.worker.definitionHash, definitionVersion: plan.worker.definitionVersion }, fingerprint: acceptanceDigest({ item: plan.item, planDigest }) });
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
const plan = parseStoredContinuationPlan(record.planJson);
|
|
98
|
+
// v1's input hash did not retain a verifiable Inbox/attachment locator.
|
|
99
|
+
// The new engineering protocol abstains rather than guessing text-only.
|
|
100
|
+
if (!isReplyContinuationPlan(plan))
|
|
101
|
+
reject('v1 continuation has no complete text-only source proof');
|
|
102
|
+
if (acceptanceCanonicalJson(plan.item) !== acceptanceCanonicalJson(continuationItemBasis(item))
|
|
103
|
+
|| record.itemId !== item.id || record.parentItemId !== plan.parent.itemId || record.rootItemId !== plan.parent.rootItemId
|
|
104
|
+
|| record.parentReportRevision !== plan.parent.reportRevision || record.parentOutcomeRevision !== plan.parent.outcomeRevision
|
|
105
|
+
|| record.sourceDigest !== plan.source.digest || record.inputSha256 !== plan.source.inputSha256 || record.inputBytes !== plan.source.inputBytes
|
|
106
|
+
|| record.createdAt !== item.createdAt || !HEX.test(record.planDigest))
|
|
107
|
+
reject('continuation seal or cutoff differs');
|
|
108
|
+
const activation = parseContinuationActivation(plan.activation), reply = plan.source.origin.reply, replySupplier = plan.source.origin.supplier;
|
|
109
|
+
if (activation.stage !== 'established' || activation.ownerLineage.authorityId !== item.scope.ownerRouteId
|
|
110
|
+
|| activation.ownerLineage.principalId !== item.scope.principalId || activation.ownerLineage.principalRecordId !== item.owner.principalRecordId
|
|
111
|
+
|| activation.ownerLineage.principalVersion !== item.owner.principalVersion || activation.ownerLineage.workspace !== item.scope.workspace
|
|
112
|
+
|| activation.ownerLineage.agentPreset !== item.scope.preset || !identity(item.workerAutomationId, 256))
|
|
113
|
+
reject('continuation activation owner differs');
|
|
114
|
+
const sourceText = exactText(record.inputText, MAX_ENGINEERING_INPUT_BYTES, true), bytes = Buffer.byteLength(sourceText);
|
|
115
|
+
totalInputs += bytes;
|
|
116
|
+
if (totalInputs > MAX_ENGINEERING_INPUT_BYTES)
|
|
117
|
+
reject('continuation inputs exceed 16384 bytes');
|
|
118
|
+
if (reply.protocol !== 'assistant-delivery/work-item-reply/v1' || !identity(reply.id, 512) || reply.sourceDigest !== record.sourceDigest
|
|
119
|
+
|| reply.inputSha256 !== record.inputSha256 || reply.inputBytes !== record.inputBytes || reply.inputSha256 !== continuationDigest(sourceText)
|
|
120
|
+
|| reply.binding.id !== item.originBindingId || reply.binding.version !== item.owner.bindingVersion || reply.binding.generation !== item.owner.generation
|
|
121
|
+
|| reply.scope.workspace !== item.scope.workspace || reply.scope.preset !== item.scope.preset || reply.principalId !== item.scope.principalId
|
|
122
|
+
|| reply.owner.principalRecordId !== item.owner.principalRecordId || reply.owner.principalVersion !== item.owner.principalVersion
|
|
123
|
+
|| reply.target.streamId !== record.rootItemId || !identity(reply.target.itemId, 256) || !positive(reply.target.reportRevision) || !HEX.test(reply.target.reportDigest)
|
|
124
|
+
|| replySupplier.itemId !== record.parentItemId || acceptanceCanonicalJson(replySupplier.production) !== acceptanceCanonicalJson(plan.parent.production)
|
|
125
|
+
|| acceptanceCanonicalJson(supplier(plan.contract)) !== acceptanceCanonicalJson(plan.source.modelSelection))
|
|
126
|
+
reject('reply input or supplier seal differs');
|
|
127
|
+
const selected = record.parentReportRevision === null ? undefined : reportSnapshot(store, record.parentItemId, record.parentReportRevision);
|
|
128
|
+
if (selected) {
|
|
129
|
+
totalReports += selected.body.fullBytes;
|
|
130
|
+
if (totalReports > MAX_ENGINEERING_REPORT_BYTES)
|
|
131
|
+
reject('parent reports exceed 262144 bytes');
|
|
132
|
+
}
|
|
133
|
+
let outcomeFingerprint = null;
|
|
134
|
+
if (record.parentOutcomeRevision !== null) {
|
|
135
|
+
const outcome = store.continuationParentOutcomes(itemId, record.parentOutcomeRevision - 1, 1)[0];
|
|
136
|
+
if (!outcome || outcome.itemId !== record.parentItemId || outcome.revision !== record.parentOutcomeRevision)
|
|
137
|
+
reject('sealed outcome cutoff is missing');
|
|
138
|
+
outcomeFingerprint = acceptanceDigest(outcome);
|
|
139
|
+
}
|
|
140
|
+
const parentProduction = plan.parent.production;
|
|
141
|
+
const node = { itemId, planProtocol: plan.protocol, planDigest: record.planDigest,
|
|
142
|
+
input: { kind: 'continuation', sourceDigest: record.sourceDigest, inputSha256: record.inputSha256, inputBytes: record.inputBytes, replyId: reply.id },
|
|
143
|
+
parent: { itemId: record.parentItemId, rootItemId: record.rootItemId, report: selected?.ref ?? null, outcomeRevision: record.parentOutcomeRevision,
|
|
144
|
+
productionDigest: acceptanceDigest(parentProduction) } };
|
|
145
|
+
reverse.push({ item, node, planSupplier: supplier(plan.contract), producer: { owner: CONTINUATION_OWNER, automationId: item.workerAutomationId,
|
|
146
|
+
definitionHash: activation.definitionHash, definitionVersion: activation.definitionVersion }, parentProduction, replySupplier,
|
|
147
|
+
replyTargetItemId: reply.target.itemId, input: { itemId, text: sourceText, fullTextDigest: continuationDigest(sourceText), fullBytes: bytes }, ...(selected ? { selectedReport: selected } : {}),
|
|
148
|
+
fingerprint: acceptanceDigest({ item: plan.item, planDigest: record.planDigest, inputSha256: record.inputSha256,
|
|
149
|
+
parentReport: selected?.fingerprint ?? null, parentOutcome: outcomeFingerprint }) });
|
|
150
|
+
itemId = record.parentItemId;
|
|
151
|
+
}
|
|
152
|
+
const chain = reverse.reverse(), rootItemId = chain[0].item.id;
|
|
153
|
+
for (let index = 1; index < chain.length; index++) {
|
|
154
|
+
const entry = chain[index], parent = chain[index - 1], production = entry.parentProduction, link = entry.node.parent;
|
|
155
|
+
parentLineage(parent.item, entry.item);
|
|
156
|
+
if (link.itemId !== parent.item.id || link.rootItemId !== rootItemId || entry.replySupplier.planDigest !== parent.node.planDigest
|
|
157
|
+
|| entry.replySupplier.kind !== (parent.node.parent === null ? 'diagnosis-plan' : 'continuation-plan')
|
|
158
|
+
|| acceptanceCanonicalJson(entry.planSupplier) !== acceptanceCanonicalJson(parent.planSupplier)
|
|
159
|
+
|| !chain.slice(0, index).some(ancestor => ancestor.item.id === entry.replyTargetItemId)
|
|
160
|
+
|| production.protocol !== 'assistant-automations/production-occurrence/v1' || production.executionMode !== 'production'
|
|
161
|
+
|| !['succeeded', 'failed', 'cancelled', 'timed_out'].includes(production.status) || production.quiescent !== true
|
|
162
|
+
|| production.budgetSettlementState !== 'finalized' || !positive(production.completedAt)
|
|
163
|
+
|| !identity(production.runId, 512) || !identity(production.occurrenceId, 512) || !identity(production.taskId, 512) || !identity(production.attemptId, 512)
|
|
164
|
+
|| production.automationId !== parent.producer.automationId || production.immutableContext.state !== 'verified'
|
|
165
|
+
|| production.immutableContext.owner !== parent.producer.owner || production.immutableContext.definitionHash !== parent.producer.definitionHash
|
|
166
|
+
|| production.immutableContext.definitionVersion !== parent.producer.definitionVersion
|
|
167
|
+
|| production.immutableContext.scope.workspace !== proof.scope.workspace || production.immutableContext.scope.agentPreset !== proof.scope.preset)
|
|
168
|
+
reject('parent chain production or supplier differs');
|
|
169
|
+
if (link.report !== null && link.report.status !== 'progress') {
|
|
170
|
+
const binding = store.diagnosisReportOccurrence(parent.item.id, link.report.revision);
|
|
171
|
+
if (binding.occurrenceId !== production.occurrenceId || binding.status !== link.report.status)
|
|
172
|
+
reject('parent report production occurrence differs');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const leaf = chain.at(-1);
|
|
176
|
+
if (leaf.node.planDigest !== proof.planDigest || acceptanceCanonicalJson(leaf.planSupplier) !== acceptanceCanonicalJson(proof.supplier))
|
|
177
|
+
reject('leaf feedback proof differs');
|
|
178
|
+
const unsigned = { protocol: 'assistant-work-items/engineering-material/v1', itemId: proof.itemId, rootItemId, feedbackProofDigest: proof.proofDigest,
|
|
179
|
+
nodes: chain.map(entry => entry.node), continuationInputs: chain.flatMap(entry => entry.input ? [entry.input] : []),
|
|
180
|
+
parentReports: chain.flatMap(entry => entry.selectedReport ? [entry.selectedReport.body] : []) };
|
|
181
|
+
const material = { ...unsigned, materialDigest: acceptanceDigest(unsigned) };
|
|
182
|
+
if (Buffer.byteLength(acceptanceCanonicalJson(material)) > MAX_ENGINEERING_MATERIAL_BYTES)
|
|
183
|
+
reject('material exceeds 524288 bytes');
|
|
184
|
+
return { material: freeze(material), fingerprint: acceptanceDigest(chain.map(entry => entry.fingerprint)) };
|
|
185
|
+
}
|
|
186
|
+
/** Separate ephemeral authority: no old feedback or Memory capability is
|
|
187
|
+
* upgraded into engineering-source authority merely by installing this API. */
|
|
188
|
+
export class WorkItemEngineeringTargets {
|
|
189
|
+
dependencies;
|
|
190
|
+
#closed = false;
|
|
191
|
+
#capabilities = new WeakMap();
|
|
192
|
+
constructor(dependencies) {
|
|
193
|
+
this.dependencies = dependencies;
|
|
194
|
+
}
|
|
195
|
+
resources() {
|
|
196
|
+
const config = this.dependencies.config, store = this.dependencies.store(), feedback = this.dependencies.feedback();
|
|
197
|
+
if (this.#closed || !this.dependencies.current() || !store || store.closed || !feedback)
|
|
198
|
+
throw new WorkItemError('missing-dependency', 'engineering source reader is unavailable');
|
|
199
|
+
return { config, configDigest: acceptanceDigest(config), store, feedback };
|
|
200
|
+
}
|
|
201
|
+
issue(feedbackCapability) {
|
|
202
|
+
try {
|
|
203
|
+
const frame = this.resources();
|
|
204
|
+
return frame.feedback.withTargetsFence([feedbackCapability], proofs => {
|
|
205
|
+
const proof = proofs[0], owner = frame.feedback.engineeringFrameOwner(), current = this.resources();
|
|
206
|
+
if (!proof || !owner || current.store !== frame.store || current.feedback !== frame.feedback || current.config !== frame.config || current.configDigest !== frame.configDigest)
|
|
207
|
+
return undefined;
|
|
208
|
+
const snapshot = readChain(frame.store, proof, owner), capability = Object.freeze(Object.create(null));
|
|
209
|
+
this.#capabilities.set(capability, { feedbackCapability, feedbackProofDigest: proof.proofDigest, materialDigest: snapshot.material.materialDigest,
|
|
210
|
+
fingerprint: snapshot.fingerprint, ...frame });
|
|
211
|
+
return capability;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
resolve(capability) {
|
|
219
|
+
try {
|
|
220
|
+
return this.withTargetsFence([capability], materials => materials[0]);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
withTargetsFence(capabilities, callback) {
|
|
227
|
+
if (!Array.isArray(capabilities) || typeof callback !== 'function')
|
|
228
|
+
throw new WorkItemError('invalid-input', 'engineering target fence arguments are invalid');
|
|
229
|
+
const descriptors = Object.getOwnPropertyDescriptors(capabilities), length = descriptors['length']?.value, input = [];
|
|
230
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length) || length < 0 || length > 1000)
|
|
231
|
+
throw new WorkItemError('invalid-input', 'engineering target fence supports at most 1000 capabilities');
|
|
232
|
+
if (Reflect.ownKeys(descriptors).some(key => typeof key !== 'string' || key !== 'length' && !/^(?:0|[1-9][0-9]*)$/u.test(key)))
|
|
233
|
+
throw new WorkItemError('invalid-input', 'engineering capabilities must be dense data');
|
|
234
|
+
for (let index = 0; index < length; index++) {
|
|
235
|
+
const descriptor = descriptors[String(index)];
|
|
236
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, 'value'))
|
|
237
|
+
throw new WorkItemError('invalid-input', 'engineering capabilities must be dense data');
|
|
238
|
+
input.push(descriptor.value);
|
|
239
|
+
}
|
|
240
|
+
const frame = this.resources(), ownership = this.#capabilities, records = input.map(value => value && typeof value === 'object' ? ownership.get(value) : undefined);
|
|
241
|
+
return frame.feedback.withTargetsFence(records.map(record => record?.feedbackCapability), proofs => {
|
|
242
|
+
const owner = frame.feedback.engineeringFrameOwner(), current = this.resources();
|
|
243
|
+
if (ownership !== this.#capabilities || current.store !== frame.store || current.feedback !== frame.feedback || current.config !== frame.config || current.configDigest !== frame.configDigest) {
|
|
244
|
+
throw new WorkItemError('missing-dependency', 'engineering source generation changed');
|
|
245
|
+
}
|
|
246
|
+
const materials = records.map((record, index) => {
|
|
247
|
+
if (!record || !owner || record.feedback !== frame.feedback || record.store !== frame.store || record.config !== frame.config || record.configDigest !== frame.configDigest
|
|
248
|
+
|| ownership.get(input[index]) !== record || proofs[index]?.proofDigest !== record.feedbackProofDigest)
|
|
249
|
+
return undefined;
|
|
250
|
+
try {
|
|
251
|
+
const snapshot = readChain(frame.store, proofs[index], owner);
|
|
252
|
+
return snapshot.material.materialDigest === record.materialDigest && snapshot.fingerprint === record.fingerprint ? snapshot.material : undefined;
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return callback(Object.freeze(materials));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
close() { this.#closed = true; this.#capabilities = new WeakMap(); }
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=engineering-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineering-context.js","sourceRoot":"","sources":["../src/engineering-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAElG,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,2BAA2B,EAAoC,MAAM,4BAA4B,CAAA;AACrJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAGnF,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAE1F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAuB,MAAM,YAAY,CAAA;AAuB5E,MAAM,CAAC,MAAM,4BAA4B,GAAC,EAAE,CAAA;AAC5C,MAAM,CAAC,MAAM,2BAA2B,GAAC,KAAK,CAAA;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAC,MAAM,CAAA;AAChD,MAAM,CAAC,MAAM,8BAA8B,GAAC,MAAM,CAAA;AAClD,MAAM,GAAG,GAAC,iBAAiB,CAAA;AAC3B,SAAS,MAAM,CAAC,OAAc,IAAS,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAC,uBAAuB,OAAO,EAAE,CAAC,CAAA,CAAA,CAAC;AACnH,SAAS,QAAQ,CAAC,KAAa,IAAmB,OAAO,OAAO,KAAK,KAAG,QAAQ,IAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAE,KAAK,GAAC,CAAC,CAAA,CAAA,CAAC;AACvH,SAAS,QAAQ,CAAC,KAAa,EAAC,OAAO,GAAC,GAAG;IACzC,O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,CAAC,QAAQ,CAAA,CAAC,CAAA,SAAS,CAAA;gBACxI,CAAC;gBAAC,MAAK,CAAC;oBAAA,OAAO,SAAS,CAAA;gBAAA,CAAC;YAC3B,CAAC,CAAC,CAAA;YACF,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,KAAK,KAAQ,IAAI,CAAC,OAAO,GAAC,IAAI,CAAC,CAAA,IAAI,CAAC,aAAa,GAAC,IAAI,OAAO,EAAE,CAAA,CAAA,CAAC;CACjE"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { TrustedWorkItemEvaluationClaims, TrustedWorkItemEvaluationRegistration, WorkItemEvaluationEvidenceState as WorkItemEvaluationEvidenceStateContract, WorkItemSettledBy as WorkItemEvaluationSettledByContract } from '@dsh-enhanced/assistant-evaluation';
|
|
2
|
+
import type { WorkItemExecutionMetrics, WorkItemStore } from './store.js';
|
|
3
|
+
import type { WorkItemEvaluationState, WorkItemOutcomeRecord, WorkItemRecord } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Protocol identity of the work-item → Evaluation producer seam.
|
|
6
|
+
*
|
|
7
|
+
* The `assistant-evaluation` plugin validates this exact string on the
|
|
8
|
+
* registration it hands back, so the two plugins agree on a versioned contract
|
|
9
|
+
* without either importing the other's implementation.
|
|
10
|
+
*/
|
|
11
|
+
export declare const WORK_ITEM_EVALUATION_PROTOCOL = "assistant-work-items/evaluation/v1";
|
|
12
|
+
/** Stable prefix of every Evaluation idempotency key this producer emits. */
|
|
13
|
+
export declare const WORK_ITEM_EVALUATION_ID_PREFIX = "work-items";
|
|
14
|
+
/** Bounded export attempts per settled revision; the row stays `pending`. */
|
|
15
|
+
export declare const WORK_ITEM_EVALUATION_MAX_ATTEMPTS = 5;
|
|
16
|
+
/** Bounded exports per drain pass, so a busy ledger cannot starve the host. */
|
|
17
|
+
export declare const WORK_ITEM_EVALUATION_MAX_PER_SWEEP = 10;
|
|
18
|
+
/**
|
|
19
|
+
* Protocol `assistant-work-items/evaluation/v1` enumerates its `settledBy`
|
|
20
|
+
* values and rejects anything else, and it natively carries
|
|
21
|
+
* `closed-by-thread`: a followed-thread closure is an unverified settlement, and
|
|
22
|
+
* the shared vocabulary says so exactly instead of aliasing it to a window
|
|
23
|
+
* expiry. Adding a local reason without widening the shared enum is what makes
|
|
24
|
+
* such a change a coordinated two-package one.
|
|
25
|
+
*/
|
|
26
|
+
/** Evidence states an exportable settlement can carry; `pending` is excluded. */
|
|
27
|
+
export type WorkItemEvaluationEvidenceState = Exclude<WorkItemEvaluationEvidenceStateContract, 'pending'>;
|
|
28
|
+
/** Alias of the Evaluation contract's settled-by union. */
|
|
29
|
+
export type WorkItemSettledBy = WorkItemEvaluationSettledByContract;
|
|
30
|
+
/** Exact scope identity handed to Evaluation; never includes owner secrets. */
|
|
31
|
+
export type WorkItemEvaluationScope = TrustedWorkItemEvaluationClaims['scope'];
|
|
32
|
+
/**
|
|
33
|
+
* Durable facts exported for one settled outcome revision.
|
|
34
|
+
*
|
|
35
|
+
* This is the exact claims contract from `assistant-evaluation` (type-only
|
|
36
|
+
* import; there is no runtime dependency on the ledger). The claim type is
|
|
37
|
+
* deliberately incapable of asserting an objective: both status fields are
|
|
38
|
+
* literal `'unknown'` and no execution-status field exists, so a work item can
|
|
39
|
+
* contribute evidence but never grade itself through Evaluation. The
|
|
40
|
+
* Evaluation side re-proves the same invariants at runtime.
|
|
41
|
+
*/
|
|
42
|
+
export type WorkItemEvaluationClaims = TrustedWorkItemEvaluationClaims;
|
|
43
|
+
/** Registration an Evaluation producer installs back into this plugin. */
|
|
44
|
+
export type WorkItemEvaluationRegistration = TrustedWorkItemEvaluationRegistration;
|
|
45
|
+
/** Structural producer capability consumed by `assistant-evaluation`. */
|
|
46
|
+
export interface WorkItemEvaluationProducer {
|
|
47
|
+
trustedWorkItemProducerGeneration(): string;
|
|
48
|
+
registerTrustedWorkItemEvaluationSink(registration: Readonly<WorkItemEvaluationRegistration>): () => void;
|
|
49
|
+
}
|
|
50
|
+
/** Runtime guard; `assistant-evaluation` keeps an equivalent local copy. */
|
|
51
|
+
export declare function isWorkItemEvaluationProducer(value: unknown): value is WorkItemEvaluationProducer;
|
|
52
|
+
/** Stable identity of one settled revision for Evaluation's idempotency check. */
|
|
53
|
+
export declare function workItemEvaluationIdempotencyKey(itemId: string, revision: number, evidenceState: WorkItemEvaluationEvidenceState): string;
|
|
54
|
+
/**
|
|
55
|
+
* Situation taxonomy shared by every work item of one admitted kind.
|
|
56
|
+
*
|
|
57
|
+
* Grouping by kind (not by item) keeps downstream learning comparable; the
|
|
58
|
+
* per-item identity lives in the idempotency key and evidence refs instead.
|
|
59
|
+
*/
|
|
60
|
+
export declare function workItemEvaluationSituation(kind: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Project one store outcome into the exact claims Evaluation accepts.
|
|
63
|
+
*
|
|
64
|
+
* `execution` is the bounded ledger count bag when the caller could read it;
|
|
65
|
+
* omitting it keeps the live-record fallback so a direct projection call still
|
|
66
|
+
* works. Returns `null` for revisions that are not exportable at all: a window
|
|
67
|
+
* still `pending` can change, so publishing it would contradict a later
|
|
68
|
+
* revision.
|
|
69
|
+
*/
|
|
70
|
+
export declare function workItemEvaluationClaims(outcome: WorkItemOutcomeRecord, scope: WorkItemEvaluationScope, item: WorkItemRecord | undefined, execution?: Readonly<WorkItemExecutionMetrics>): WorkItemEvaluationClaims | null;
|
|
71
|
+
export interface WorkItemEvaluationExporterOptions {
|
|
72
|
+
/** Lazily resolved so a disabled intake never opens the ledger for export. */
|
|
73
|
+
store: () => WorkItemStore | undefined;
|
|
74
|
+
/** Exact scope, or `null` when this deployment has no owner route. */
|
|
75
|
+
scope: () => WorkItemEvaluationScope | null;
|
|
76
|
+
/** Export only from an active intake with settlement armed. */
|
|
77
|
+
enabled: () => boolean;
|
|
78
|
+
now: () => number;
|
|
79
|
+
maxPerSweep?: number;
|
|
80
|
+
warn?: (message: string) => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Bounded work-item → Evaluation exporter.
|
|
84
|
+
*
|
|
85
|
+
* Evaluation owns the append; this class owns only its own outbox columns. A
|
|
86
|
+
* pass is bounded by `maxPerSweep`, never runs on a timer (it is triggered by
|
|
87
|
+
* registration and by the transaction boundaries that can create a new settled
|
|
88
|
+
* revision), and a failed append leaves the row `pending` with a capped attempt
|
|
89
|
+
* count that health can surface instead of silently dropping evidence.
|
|
90
|
+
*/
|
|
91
|
+
export declare class WorkItemEvaluationExporter implements WorkItemEvaluationProducer {
|
|
92
|
+
#private;
|
|
93
|
+
constructor(options: WorkItemEvaluationExporterOptions);
|
|
94
|
+
get generation(): string;
|
|
95
|
+
get connected(): boolean;
|
|
96
|
+
get degraded(): string | null;
|
|
97
|
+
/** Capability consumed by `assistant-evaluation`; stable for this instance. */
|
|
98
|
+
trustedWorkItemProducerGeneration(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Accept the exact registration Evaluation built for this generation.
|
|
101
|
+
*
|
|
102
|
+
* Exactly one sink may be registered: a second registration is refused so
|
|
103
|
+
* evidence cannot be double-exported under two capabilities, and the returned
|
|
104
|
+
* disposer only clears the registration it owns.
|
|
105
|
+
*/
|
|
106
|
+
registerTrustedWorkItemEvaluationSink(registration: Readonly<WorkItemEvaluationRegistration>): () => void;
|
|
107
|
+
/** Withdraw any sink on service disposal. */
|
|
108
|
+
dispose(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Run bounded export passes serially; a caller never joins a stale pass.
|
|
111
|
+
*
|
|
112
|
+
* A drain that arrives while one is in flight queues exactly one follow-up
|
|
113
|
+
* pass instead of returning the in-flight result: the settlement that
|
|
114
|
+
* prompted the second call may have committed after the first pass read its
|
|
115
|
+
* candidates, and silently joining it would postpone that evidence until the
|
|
116
|
+
* next unrelated transaction.
|
|
117
|
+
*
|
|
118
|
+
* Never rejects: every failure is recorded as degraded health so a caller on
|
|
119
|
+
* a transaction boundary cannot fail because Export is unavailable.
|
|
120
|
+
*/
|
|
121
|
+
drain(limit?: number): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
/** Re-exported so tests can assert the exported state machine without a cast. */
|
|
124
|
+
export type WorkItemOutcomeEvaluationState = WorkItemEvaluationState;
|
|
125
|
+
//# sourceMappingURL=evaluation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation.d.ts","sourceRoot":"","sources":["../src/evaluation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAC/B,qCAAqC,EACrC,+BAA+B,IAAI,uCAAuC,EAC1E,iBAAiB,IAAI,mCAAmC,EACzD,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACf,MAAM,YAAY,CAAA;AAGnB;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,uCAAuC,CAAA;AACjF,6EAA6E;AAC7E,eAAO,MAAM,8BAA8B,eAAe,CAAA;AAC1D,6EAA6E;AAC7E,eAAO,MAAM,iCAAiC,IAAI,CAAA;AAClD,+EAA+E;AAC/E,eAAO,MAAM,kCAAkC,KAAK,CAAA;AAEpD;;;;;;;GAOG;AAEH,iFAAiF;AACjF,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAA;AACzG,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG,mCAAmC,CAAA;AAEnE,+EAA+E;AAC/E,MAAM,MAAM,uBAAuB,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAA;AAE9E;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,CAAA;AAEtE,0EAA0E;AAC1E,MAAM,MAAM,8BAA8B,GAAG,qCAAqC,CAAA;AAElF,yEAAyE;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