@dharma-ai-labs/agent-fabric 0.2.196 → 0.2.198
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/dist/codexBootstrapCompletion.test.js +13 -3
- package/dist/codexBootstrapCompletion.test.js.map +1 -1
- package/dist/codexSetupPortalIngress.test.js +2 -0
- package/dist/codexSetupPortalIngress.test.js.map +1 -1
- package/dist/codexSetupSessionHandoff.d.ts +7 -0
- package/dist/codexSetupSessionHandoff.d.ts.map +1 -1
- package/dist/codexSetupSessionHandoff.js +119 -21
- package/dist/codexSetupSessionHandoff.js.map +1 -1
- package/dist/codexSetupSessionHandoff.test.js +263 -10
- package/dist/codexSetupSessionHandoff.test.js.map +1 -1
- package/dist/codexSetupSourceRequalification.test.d.ts +2 -0
- package/dist/codexSetupSourceRequalification.test.d.ts.map +1 -0
- package/dist/codexSetupSourceRequalification.test.js +109 -0
- package/dist/codexSetupSourceRequalification.test.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -15,6 +15,21 @@ export function codexSetupSessionPolicyHash(policy) {
|
|
|
15
15
|
return sha256(canonicalize({ ...policy, serverAuthorization: authorization }));
|
|
16
16
|
}
|
|
17
17
|
const originalSenders = new WeakMap();
|
|
18
|
+
const acknowledgedSetupSessions = new WeakMap();
|
|
19
|
+
export function assertCodexSetupSessionPostCommitAcknowledged(scope, input) {
|
|
20
|
+
const acknowledgment = acknowledgedSetupSessions.get(scope);
|
|
21
|
+
if (!acknowledgment || acknowledgment.operationId !== input.request.operationId
|
|
22
|
+
|| acknowledgment.intentDigest !== input.request.intentDigest
|
|
23
|
+
|| acknowledgment.requestHash !== sha256(canonicalize(input.request))
|
|
24
|
+
|| acknowledgment.resultHash !== sha256(canonicalize(input.result))
|
|
25
|
+
|| acknowledgment.acceptedAt !== input.acceptedAt
|
|
26
|
+
|| acknowledgment.resultRecordedAt !== input.resultRecordedAt) {
|
|
27
|
+
throw new Error('setup_session_post_commit_unconfirmed');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function clearCodexSetupSessionPostCommitAcknowledgment(scope) {
|
|
31
|
+
acknowledgedSetupSessions.delete(scope);
|
|
32
|
+
}
|
|
18
33
|
/** Private original-lease continuation. Public-shaped JSON is not admission. */
|
|
19
34
|
export async function withCodexSetupSessionSender(input, operation) {
|
|
20
35
|
const prepared = await inspectCodexBootstrapHostPreparation(input.scope);
|
|
@@ -50,38 +65,110 @@ export async function awaitCodexSetupSession(input) {
|
|
|
50
65
|
}
|
|
51
66
|
const submission = await input.scope.step(() => input.vault.stageCodexSetupSession(input.leaseId, request.intentDigest, request));
|
|
52
67
|
try {
|
|
53
|
-
const expiresAt = Date.parse(request.expiresAt);
|
|
54
|
-
|
|
68
|
+
const issuedAt = Date.parse(request.issuedAt), expiresAt = Date.parse(request.expiresAt);
|
|
69
|
+
const pendingDeadline = Math.min(Date.now() + waitMs, expiresAt);
|
|
70
|
+
let deadline = pendingDeadline;
|
|
55
71
|
let accepted = false;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
let acceptedAt = null;
|
|
73
|
+
let sawAccepted = false;
|
|
74
|
+
let immediateObservationScheduled = false;
|
|
75
|
+
const observe = async () => {
|
|
59
76
|
const observation = await input.scope.step(() => input.vault.readCodexSetupSession(request.operationId, request.intentDigest));
|
|
60
77
|
if (!observation || canonicalize(observation.request) !== canonicalize(request) || observation.state === 'withdrawn') {
|
|
61
78
|
throw new Error('setup_session_scope_changed');
|
|
62
79
|
}
|
|
63
80
|
if (accepted && observation.state !== 'accepted')
|
|
64
81
|
throw new Error('setup_session_scope_changed');
|
|
65
|
-
|
|
82
|
+
return observation;
|
|
83
|
+
};
|
|
84
|
+
while (Date.now() < expiresAt) {
|
|
85
|
+
const observation = await observe(), observedAt = Date.now();
|
|
86
|
+
if (observedAt >= expiresAt)
|
|
87
|
+
break;
|
|
88
|
+
if (observation.state === 'accepted') {
|
|
89
|
+
sawAccepted = true;
|
|
90
|
+
if (typeof observation.acceptedAt !== 'string')
|
|
91
|
+
throw new Error('setup_session_timing_unavailable');
|
|
92
|
+
const observedAcceptance = Date.parse(observation.acceptedAt);
|
|
93
|
+
if (!Number.isFinite(observedAcceptance) || new Date(observedAcceptance).toISOString() !== observation.acceptedAt
|
|
94
|
+
|| observedAcceptance < issuedAt || observedAcceptance >= expiresAt || observedAcceptance > observedAt
|
|
95
|
+
|| (acceptedAt !== null && acceptedAt !== observation.acceptedAt))
|
|
96
|
+
throw new Error('setup_session_scope_changed');
|
|
97
|
+
acceptedAt = observation.acceptedAt;
|
|
98
|
+
if (!accepted) {
|
|
99
|
+
if (observedAcceptance > pendingDeadline || observedAt >= pendingDeadline)
|
|
100
|
+
break;
|
|
101
|
+
// Acceptance is not readiness. Derive the remaining startup budget
|
|
102
|
+
// from its authenticated vault timestamp, never from a late poll.
|
|
103
|
+
accepted = true;
|
|
104
|
+
deadline = Math.min(observedAcceptance + acceptedWaitMs, expiresAt);
|
|
105
|
+
immediateObservationScheduled = false;
|
|
106
|
+
}
|
|
107
|
+
if (observation.result) {
|
|
108
|
+
if (typeof observation.resultRecordedAt !== 'string')
|
|
109
|
+
throw new Error('setup_session_timing_unavailable');
|
|
110
|
+
const recordedAt = Date.parse(observation.resultRecordedAt);
|
|
111
|
+
if (!Number.isFinite(recordedAt) || new Date(recordedAt).toISOString() !== observation.resultRecordedAt
|
|
112
|
+
|| recordedAt < observedAcceptance || recordedAt >= expiresAt || recordedAt > observedAt) {
|
|
113
|
+
throw new Error('setup_session_scope_changed');
|
|
114
|
+
}
|
|
115
|
+
if (recordedAt <= deadline && observedAt < deadline) {
|
|
116
|
+
const result = parseLocalCodexSetupSessionResult(observation.result);
|
|
117
|
+
const sender = originalSenders.get(input.scope);
|
|
118
|
+
if (sender?.active.value && currentBootstrapHostScope() === input.scope) {
|
|
119
|
+
const acknowledgment = Object.freeze({ operationId: request.operationId, intentDigest: request.intentDigest,
|
|
120
|
+
requestHash: sha256(canonicalize(request)), resultHash: sha256(canonicalize(result)),
|
|
121
|
+
acceptedAt: observation.acceptedAt, resultRecordedAt: observation.resultRecordedAt });
|
|
122
|
+
const existing = acknowledgedSetupSessions.get(input.scope);
|
|
123
|
+
if (existing && canonicalize(existing) !== canonicalize(acknowledgment)) {
|
|
124
|
+
throw new Error('setup_session_scope_changed');
|
|
125
|
+
}
|
|
126
|
+
acknowledgedSetupSessions.set(input.scope, acknowledgment);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (observation.resultRecordedAt !== null)
|
|
132
|
+
throw new Error('setup_session_scope_changed');
|
|
133
|
+
}
|
|
134
|
+
else if (observation.acceptedAt !== null || observation.result !== null || observation.resultRecordedAt !== null) {
|
|
135
|
+
throw new Error('setup_session_scope_changed');
|
|
136
|
+
}
|
|
137
|
+
if (observedAt >= deadline)
|
|
66
138
|
break;
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
139
|
+
// Reserve a small interval for the next protected read to complete
|
|
140
|
+
// before the authority deadline. A result first visible after that read
|
|
141
|
+
// is retained as evidence but cannot authorize success.
|
|
142
|
+
const remaining = deadline - observedAt;
|
|
143
|
+
// Waiting is not a protected effect. Requalify once on the next vault
|
|
144
|
+
// observation instead of repeatedly exercising repository, account and
|
|
145
|
+
// protected-store checks while no state can have changed locally.
|
|
146
|
+
const delay = remaining > 25 ? Math.min(1_000, remaining - 25) : Math.floor(remaining / 2);
|
|
147
|
+
if (delay === 0 && immediateObservationScheduled)
|
|
73
148
|
break;
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
await
|
|
77
|
-
|
|
78
|
-
|
|
149
|
+
if (delay === 0)
|
|
150
|
+
immediateObservationScheduled = true;
|
|
151
|
+
await new Promise(resolveWait => {
|
|
152
|
+
let timer;
|
|
153
|
+
let immediate;
|
|
154
|
+
const finish = () => {
|
|
155
|
+
if (timer)
|
|
156
|
+
clearTimeout(timer);
|
|
157
|
+
if (immediate)
|
|
158
|
+
clearImmediate(immediate);
|
|
159
|
+
input.scope.signal.removeEventListener('abort', finish);
|
|
160
|
+
resolveWait();
|
|
161
|
+
};
|
|
162
|
+
if (delay > 0)
|
|
163
|
+
timer = setTimeout(finish, delay);
|
|
164
|
+
else
|
|
165
|
+
immediate = setImmediate(finish);
|
|
79
166
|
input.scope.signal.addEventListener('abort', finish, { once: true });
|
|
80
167
|
if (input.scope.signal.aborted)
|
|
81
168
|
finish();
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
throw new Error(
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
throw new Error(sawAccepted ? 'setup_session_accepted_unconfirmed' : 'setup_session_receiver_timeout');
|
|
85
172
|
}
|
|
86
173
|
finally {
|
|
87
174
|
// Exact pending-request cleanup remains available after scope withdrawal.
|
|
@@ -165,7 +252,18 @@ export async function consumeCodexSetupSessions(input) {
|
|
|
165
252
|
// Unconfirmed cleanup must not be masked by a recorded disposition.
|
|
166
253
|
await cleanup.stopFresh();
|
|
167
254
|
assertOwner();
|
|
168
|
-
|
|
255
|
+
try {
|
|
256
|
+
acceptance.record({ state: 'unconfirmed', code: 'session_start_unconfirmed' });
|
|
257
|
+
}
|
|
258
|
+
catch (recordError) {
|
|
259
|
+
// Expiry can win after acceptance while the owned startup is being
|
|
260
|
+
// drained. The accepted row is already the durable no-retry fence;
|
|
261
|
+
// failing to append a late result must not abort unrelated requests.
|
|
262
|
+
if (!(recordError instanceof Error && recordError.message === 'setup_session_scope_unavailable')) {
|
|
263
|
+
reportFailure(error);
|
|
264
|
+
throw recordError;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
169
267
|
reportFailure(error);
|
|
170
268
|
}
|
|
171
269
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codexSetupSessionHandoff.js","sourceR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CAAC;oBACjG,aAAa,CAAC,KAAK,CAAC,CAAC;oBAAC,MAAM,WAAW,CAAC;gBAC1C,CAAC;YACH,CAAC;YACD,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;gBAAS,CAAC;YAAA,MAAM,GAAG,KAAK,CAAC;YAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAAA,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -9,7 +9,7 @@ import { LocalVault } from '@dharma-ai-labs/agent-fabric-local-vault';
|
|
|
9
9
|
import { prepareCodexBootstrapHost, runCodexBootstrapHostScope } from './bootstrapHostScope.js';
|
|
10
10
|
import { createCodexSetupAdmission } from './codexSetupAdmission.js';
|
|
11
11
|
import { createNamedSessionChildOwner } from './namedSessionChildOwner.js';
|
|
12
|
-
import { awaitCodexSetupSession, consumeCodexSetupSessions, currentAcceptedSetupSessionScope, originalCodexSetupSessionSender, withCodexSetupSessionSender } from './codexSetupSessionHandoff.js';
|
|
12
|
+
import { assertCodexSetupSessionPostCommitAcknowledged, awaitCodexSetupSession, clearCodexSetupSessionPostCommitAcknowledgment, consumeCodexSetupSessions, currentAcceptedSetupSessionScope, originalCodexSetupSessionSender, withCodexSetupSessionSender } from './codexSetupSessionHandoff.js';
|
|
13
13
|
const uuid = (n) => `${String(n).padStart(8, '0')}-1111-4111-8111-111111111111`;
|
|
14
14
|
const digest = `sha256:${'a'.repeat(64)}`;
|
|
15
15
|
async function fixture(run) {
|
|
@@ -47,6 +47,7 @@ test('accepted startup can finish after 30 seconds without restaging or extendin
|
|
|
47
47
|
await fixture(async (f) => {
|
|
48
48
|
let now = Date.now(), reads = 0, submissions = 0, withdrawals = 0;
|
|
49
49
|
t.mock.method(Date, 'now', () => now);
|
|
50
|
+
const acceptedAt = new Date(now).toISOString();
|
|
50
51
|
const result = { state: 'started', bindingId: uuid(9), sessionId: 'synthetic_delayed',
|
|
51
52
|
sessionPid: 42, supervisorPid: process.pid, sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
52
53
|
const vault = {
|
|
@@ -54,12 +55,14 @@ test('accepted startup can finish after 30 seconds without restaging or extendin
|
|
|
54
55
|
async readCodexSetupSession() {
|
|
55
56
|
reads++;
|
|
56
57
|
if (reads === 1)
|
|
57
|
-
return { request: f.request, state: 'accepted', result: null };
|
|
58
|
+
return { request: f.request, state: 'accepted', acceptedAt, result: null, resultRecordedAt: null };
|
|
58
59
|
if (reads === 2) {
|
|
59
60
|
now += 31_000;
|
|
60
|
-
return { request: f.request, state: 'accepted',
|
|
61
|
+
return { request: f.request, state: 'accepted',
|
|
62
|
+
acceptedAt, result: null, resultRecordedAt: null };
|
|
61
63
|
}
|
|
62
|
-
return { request: f.request, state: 'accepted', result
|
|
64
|
+
return { request: f.request, state: 'accepted', acceptedAt, result,
|
|
65
|
+
resultRecordedAt: new Date(now).toISOString() };
|
|
63
66
|
},
|
|
64
67
|
};
|
|
65
68
|
assert.deepEqual(await awaitCodexSetupSession({ vault, scope: f.scope, request: f.request, leaseId: f.leaseId }), result);
|
|
@@ -79,21 +82,220 @@ test('accepted wait rejects invalid budgets before staging any authority', async
|
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
84
|
});
|
|
85
|
+
test('accepted wait bounds protected-scope churn while retaining final observations', async () => {
|
|
86
|
+
await fixture(async (f) => {
|
|
87
|
+
let reads = 0, protectedSteps = 0;
|
|
88
|
+
const acceptedAt = new Date().toISOString();
|
|
89
|
+
const scope = { ...f.scope, async step(operation) {
|
|
90
|
+
protectedSteps++;
|
|
91
|
+
return f.scope.step(operation);
|
|
92
|
+
} };
|
|
93
|
+
const vault = {
|
|
94
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
95
|
+
async readCodexSetupSession() {
|
|
96
|
+
reads++;
|
|
97
|
+
return { request: f.request, state: 'accepted', acceptedAt, result: null, resultRecordedAt: null };
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
await assert.rejects(awaitCodexSetupSession({ vault, scope, request: f.request,
|
|
101
|
+
leaseId: f.leaseId, acceptedWaitMs: 250 }), /setup_session_accepted_unconfirmed/);
|
|
102
|
+
assert.ok(reads >= 2 && reads <= 8, `unexpected final observation count: ${reads}`);
|
|
103
|
+
assert.equal(protectedSteps, reads + 1);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
test('accepted wait returns a result recorded during its final idle interval', async () => {
|
|
107
|
+
await fixture(async (f) => {
|
|
108
|
+
let reads = 0, available = false, resultRecordedAt = null;
|
|
109
|
+
const acceptedAt = new Date().toISOString();
|
|
110
|
+
const result = { state: 'started', bindingId: uuid(9),
|
|
111
|
+
sessionId: 'synthetic_final_observation', sessionPid: 42, supervisorPid: process.pid,
|
|
112
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
113
|
+
const timer = setTimeout(() => { available = true; resultRecordedAt = new Date().toISOString(); }, 50);
|
|
114
|
+
const vault = {
|
|
115
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
116
|
+
async readCodexSetupSession() {
|
|
117
|
+
reads++;
|
|
118
|
+
return { request: f.request, state: 'accepted', acceptedAt,
|
|
119
|
+
result: available ? result : null, resultRecordedAt };
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
try {
|
|
123
|
+
assert.deepEqual(await awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
124
|
+
leaseId: f.leaseId, acceptedWaitMs: 250 }), result);
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
clearTimeout(timer);
|
|
128
|
+
}
|
|
129
|
+
assert.equal(reads, 2);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
test('pending wait observes a timely acceptance and result from its final idle interval', async () => {
|
|
133
|
+
await fixture(async (f) => {
|
|
134
|
+
let reads = 0, acceptedAt = null, resultRecordedAt = null;
|
|
135
|
+
const result = { state: 'started', bindingId: uuid(9),
|
|
136
|
+
sessionId: 'synthetic_pending_final_observation', sessionPid: 42, supervisorPid: process.pid,
|
|
137
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
138
|
+
const timer = setTimeout(() => {
|
|
139
|
+
acceptedAt = new Date().toISOString();
|
|
140
|
+
resultRecordedAt = acceptedAt;
|
|
141
|
+
}, 50);
|
|
142
|
+
const vault = {
|
|
143
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
144
|
+
async readCodexSetupSession() {
|
|
145
|
+
reads++;
|
|
146
|
+
return acceptedAt === null
|
|
147
|
+
? { request: f.request, state: 'pending', acceptedAt: null, result: null, resultRecordedAt: null }
|
|
148
|
+
: { request: f.request, state: 'accepted', acceptedAt, result, resultRecordedAt };
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
assert.deepEqual(await awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
153
|
+
leaseId: f.leaseId, waitMs: 250 }), result);
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
clearTimeout(timer);
|
|
157
|
+
}
|
|
158
|
+
assert.equal(reads, 2);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
test('short valid pending budgets retain a bounded final observation', async (t) => {
|
|
162
|
+
await fixture(async (f) => {
|
|
163
|
+
let now = Date.now(), reads = 0;
|
|
164
|
+
const acceptedAt = new Date(now + 5).toISOString();
|
|
165
|
+
const result = { state: 'started', bindingId: uuid(9),
|
|
166
|
+
sessionId: 'synthetic_short_budget', sessionPid: 42, supervisorPid: process.pid,
|
|
167
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
168
|
+
t.mock.method(Date, 'now', () => now);
|
|
169
|
+
const vault = {
|
|
170
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
171
|
+
async readCodexSetupSession() {
|
|
172
|
+
reads++;
|
|
173
|
+
if (reads === 1)
|
|
174
|
+
return { request: f.request, state: 'pending',
|
|
175
|
+
acceptedAt: null, result: null, resultRecordedAt: null };
|
|
176
|
+
now += 5;
|
|
177
|
+
return { request: f.request, state: 'accepted', acceptedAt,
|
|
178
|
+
result, resultRecordedAt: acceptedAt };
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
assert.deepEqual(await awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
182
|
+
leaseId: f.leaseId, waitMs: 20 }), result);
|
|
183
|
+
assert.equal(reads, 2);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
test('a frozen final clock tick permits only one zero-delay observation', async (t) => {
|
|
187
|
+
await fixture(async (f) => {
|
|
188
|
+
const now = Date.now();
|
|
189
|
+
let reads = 0;
|
|
190
|
+
t.mock.method(Date, 'now', () => now);
|
|
191
|
+
const vault = {
|
|
192
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
193
|
+
async readCodexSetupSession() {
|
|
194
|
+
reads++;
|
|
195
|
+
return { request: f.request, state: 'pending',
|
|
196
|
+
acceptedAt: null, result: null, resultRecordedAt: null };
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
await assert.rejects(awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
200
|
+
leaseId: f.leaseId, waitMs: 1 }), /setup_session_receiver_timeout/);
|
|
201
|
+
assert.equal(reads, 2);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
test('acceptance starts a fresh bounded final-observation phase', async (t) => {
|
|
205
|
+
await fixture(async (f) => {
|
|
206
|
+
const now = Date.now();
|
|
207
|
+
let reads = 0;
|
|
208
|
+
const acceptedAt = new Date(now).toISOString();
|
|
209
|
+
const result = { state: 'started', bindingId: uuid(9),
|
|
210
|
+
sessionId: 'synthetic_cross_phase_final', sessionPid: 42, supervisorPid: process.pid,
|
|
211
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
212
|
+
t.mock.method(Date, 'now', () => now);
|
|
213
|
+
const vault = {
|
|
214
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
215
|
+
async readCodexSetupSession() {
|
|
216
|
+
reads++;
|
|
217
|
+
if (reads === 1)
|
|
218
|
+
return { request: f.request, state: 'pending',
|
|
219
|
+
acceptedAt: null, result: null, resultRecordedAt: null };
|
|
220
|
+
return { request: f.request, state: 'accepted', acceptedAt,
|
|
221
|
+
result: reads === 3 ? result : null, resultRecordedAt: reads === 3 ? acceptedAt : null };
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
assert.deepEqual(await awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
225
|
+
leaseId: f.leaseId, waitMs: 1, acceptedWaitMs: 1 }), result);
|
|
226
|
+
assert.equal(reads, 3);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
test('a timely acceptance timestamp observed only after the pending deadline cannot authorize startup', async (t) => {
|
|
230
|
+
await fixture(async (f) => {
|
|
231
|
+
let now = Date.now(), reads = 0;
|
|
232
|
+
const acceptedAt = new Date(now + 50).toISOString();
|
|
233
|
+
const result = { state: 'started', bindingId: uuid(9),
|
|
234
|
+
sessionId: 'synthetic_late_acceptance_visibility', sessionPid: 42, supervisorPid: process.pid,
|
|
235
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
236
|
+
t.mock.method(Date, 'now', () => now);
|
|
237
|
+
const vault = {
|
|
238
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
239
|
+
async readCodexSetupSession() {
|
|
240
|
+
reads++;
|
|
241
|
+
if (reads === 1)
|
|
242
|
+
return { request: f.request, state: 'pending',
|
|
243
|
+
acceptedAt: null, result: null, resultRecordedAt: null };
|
|
244
|
+
now += 251;
|
|
245
|
+
return { request: f.request, state: 'accepted', acceptedAt,
|
|
246
|
+
result, resultRecordedAt: acceptedAt };
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
await assert.rejects(awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
250
|
+
leaseId: f.leaseId, waitMs: 250 }), /setup_session_accepted_unconfirmed/);
|
|
251
|
+
assert.equal(reads, 2);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
test('a result committed before its deadline but observed after it cannot satisfy setup', async (t) => {
|
|
255
|
+
await fixture(async (f) => {
|
|
256
|
+
let now = Date.now(), reads = 0;
|
|
257
|
+
const acceptedAt = new Date(now).toISOString();
|
|
258
|
+
const resultRecordedAt = new Date(now + 50).toISOString();
|
|
259
|
+
const result = { state: 'started', bindingId: uuid(9),
|
|
260
|
+
sessionId: 'synthetic_late_result_visibility', sessionPid: 42, supervisorPid: process.pid,
|
|
261
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
262
|
+
t.mock.method(Date, 'now', () => now);
|
|
263
|
+
const vault = {
|
|
264
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
265
|
+
async readCodexSetupSession() {
|
|
266
|
+
reads++;
|
|
267
|
+
if (reads === 1)
|
|
268
|
+
return { request: f.request, state: 'accepted',
|
|
269
|
+
acceptedAt, result: null, resultRecordedAt: null };
|
|
270
|
+
now += 101;
|
|
271
|
+
return { request: f.request, state: 'accepted', acceptedAt, result, resultRecordedAt };
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
await assert.rejects(awaitCodexSetupSession({ vault, scope: f.scope, request: f.request,
|
|
275
|
+
leaseId: f.leaseId, acceptedWaitMs: 100 }), /setup_session_accepted_unconfirmed/);
|
|
276
|
+
assert.equal(reads, 2);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
82
279
|
test('accepted wait cannot extend pending timeout, original expiry, or its own finite deadline', async (t) => {
|
|
83
280
|
await fixture(async (f) => {
|
|
84
281
|
let now = Date.now();
|
|
85
282
|
t.mock.method(Date, 'now', () => now);
|
|
86
283
|
for (const mode of ['pending', 'expiry', 'accepted-budget']) {
|
|
87
284
|
now = Date.parse(f.request.issuedAt) + 1000;
|
|
285
|
+
const acceptedAt = new Date(now).toISOString();
|
|
88
286
|
let reads = 0, stages = 0, withdrawals = 0;
|
|
89
287
|
const vault = { async stageCodexSetupSession() { stages++; return { async withdraw() { withdrawals++; } }; },
|
|
90
288
|
async readCodexSetupSession() {
|
|
91
289
|
reads++;
|
|
92
|
-
if (mode === 'pending')
|
|
290
|
+
if (mode === 'pending') {
|
|
93
291
|
now += 30_001;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
292
|
+
return { request: f.request, state: 'pending', acceptedAt: null, result: null, resultRecordedAt: null };
|
|
293
|
+
}
|
|
294
|
+
if (reads === 2)
|
|
295
|
+
now = mode === 'expiry' ? Date.parse(f.request.expiresAt) : now + 1001;
|
|
296
|
+
const result = reads === 2 ? unconfirmed : null;
|
|
297
|
+
return { request: f.request, state: 'accepted', acceptedAt, result,
|
|
298
|
+
resultRecordedAt: result ? new Date(now).toISOString() : null };
|
|
97
299
|
} };
|
|
98
300
|
await assert.rejects(awaitCodexSetupSession({ vault, scope: f.scope, request: f.request, leaseId: f.leaseId,
|
|
99
301
|
acceptedWaitMs: mode === 'accepted-budget' ? 1000 : 120_000 }), mode === 'pending' ? /setup_session_receiver_timeout/ : /setup_session_accepted_unconfirmed/);
|
|
@@ -107,13 +309,16 @@ test('cancellation and state regression after acceptance never restage or return
|
|
|
107
309
|
for (const mode of ['cancel', 'regress'])
|
|
108
310
|
await fixture(async (f) => {
|
|
109
311
|
let reads = 0, stages = 0, withdrawals = 0;
|
|
312
|
+
const acceptedAt = new Date().toISOString();
|
|
110
313
|
const vault = { async stageCodexSetupSession() { stages++; return { async withdraw() { withdrawals++; } }; },
|
|
111
314
|
async readCodexSetupSession() {
|
|
112
315
|
reads++;
|
|
113
316
|
if (reads === 2 && mode === 'cancel')
|
|
114
317
|
f.abort();
|
|
115
|
-
return
|
|
116
|
-
|
|
318
|
+
return reads === 2 && mode === 'regress'
|
|
319
|
+
? { request: f.request, state: 'pending', acceptedAt: null, result: null, resultRecordedAt: null }
|
|
320
|
+
: { request: f.request, state: 'accepted', acceptedAt,
|
|
321
|
+
result: reads === 2 ? unconfirmed : null, resultRecordedAt: reads === 2 ? new Date().toISOString() : null };
|
|
117
322
|
} };
|
|
118
323
|
await assert.rejects(awaitCodexSetupSession({ vault, scope: f.scope, request: f.request, leaseId: f.leaseId }), mode === 'cancel' ? /codex_setup_host_scope_unavailable/ : /setup_session_scope_changed/);
|
|
119
324
|
assert.equal(stages, 1);
|
|
@@ -203,6 +408,37 @@ test('post-acceptance policy change records bounded unconfirmed disposition and
|
|
|
203
408
|
assert.equal(starts, 0);
|
|
204
409
|
});
|
|
205
410
|
});
|
|
411
|
+
test('expiry during accepted startup retains its no-retry fence and does not abort a later request', async () => {
|
|
412
|
+
await fixture(async (f) => {
|
|
413
|
+
const first = { ...f.request, expiresAt: new Date(Date.now() + 250).toISOString() };
|
|
414
|
+
f.vault.stageCodexSetupSession(f.leaseId, digest, first);
|
|
415
|
+
const sibling = f.vault.claimCodexSetupOperation(uuid(7), digest);
|
|
416
|
+
if (sibling.state !== 'acquired')
|
|
417
|
+
throw new Error('fixture_claim_missing');
|
|
418
|
+
const second = { ...f.request, operationId: uuid(7), name: 'implementer' };
|
|
419
|
+
f.vault.stageCodexSetupSession(sibling.leaseId, digest, second);
|
|
420
|
+
const owner = createNamedSessionChildOwner(f.signal), failures = [];
|
|
421
|
+
let starts = 0;
|
|
422
|
+
await owner.run(async () => {
|
|
423
|
+
assert.equal(await consumeCodexSetupSessions({ vault: f.vault, owner, signal: f.signal,
|
|
424
|
+
authorize: async () => true, onFailure: failure => { failures.push(failure); }, start: async (scope) => {
|
|
425
|
+
starts++;
|
|
426
|
+
if (scope.request.operationId === first.operationId) {
|
|
427
|
+
await new Promise(resolve => setTimeout(resolve, 350));
|
|
428
|
+
throw new Error('setup_session_scope_unavailable');
|
|
429
|
+
}
|
|
430
|
+
return unconfirmed;
|
|
431
|
+
} }), 2);
|
|
432
|
+
});
|
|
433
|
+
const interrupted = f.vault.readCodexSetupSession(first.operationId, digest);
|
|
434
|
+
assert.equal(interrupted?.state, 'accepted');
|
|
435
|
+
assert.equal(interrupted?.result, null);
|
|
436
|
+
assert.deepEqual(f.vault.readCodexSetupSession(second.operationId, digest)?.result, unconfirmed);
|
|
437
|
+
assert.equal(starts, 2);
|
|
438
|
+
assert.equal(failures.length, 1);
|
|
439
|
+
assert.equal(failures[0]?.category, 'setup_session_scope_unavailable');
|
|
440
|
+
});
|
|
441
|
+
});
|
|
206
442
|
test('claimed process metadata cannot substitute for the standing owner fresh child', async () => {
|
|
207
443
|
await fixture(async (f) => {
|
|
208
444
|
f.vault.stageCodexSetupSession(f.leaseId, digest, f.request);
|
|
@@ -348,6 +584,23 @@ test('original sender requires the admitted lease and original context; copied a
|
|
|
348
584
|
await withCodexSetupSessionSender({ scope: prepared.scope, vault: sender(f.vault), lease }, async () => {
|
|
349
585
|
assert.equal((await originalCodexSetupSessionSender(prepared.scope)).lease, lease);
|
|
350
586
|
admitted++;
|
|
587
|
+
const result = { state: 'started', bindingId: uuid(21),
|
|
588
|
+
sessionId: 'synthetic_acknowledged', sessionPid: 42, supervisorPid: process.pid,
|
|
589
|
+
sessionStartTicks: '1', supervisorStartTicks: '1' };
|
|
590
|
+
const acceptedAt = new Date().toISOString(), resultRecordedAt = acceptedAt;
|
|
591
|
+
const observed = await awaitCodexSetupSession({ scope: prepared.scope, request: f.request,
|
|
592
|
+
leaseId: lease.leaseId, vault: {
|
|
593
|
+
async stageCodexSetupSession() { return { async withdraw() { } }; },
|
|
594
|
+
async readCodexSetupSession() {
|
|
595
|
+
return { request: f.request, state: 'accepted',
|
|
596
|
+
acceptedAt, result, resultRecordedAt };
|
|
597
|
+
},
|
|
598
|
+
} });
|
|
599
|
+
assert.deepEqual(observed, result);
|
|
600
|
+
assert.doesNotThrow(() => assertCodexSetupSessionPostCommitAcknowledged(prepared.scope, { request: f.request, result, acceptedAt, resultRecordedAt }));
|
|
601
|
+
assert.throws(() => assertCodexSetupSessionPostCommitAcknowledged(prepared.scope, { request: f.request, result: { ...result, sessionPid: 43 }, acceptedAt, resultRecordedAt }), /setup_session_post_commit_unconfirmed/);
|
|
602
|
+
clearCodexSetupSessionPostCommitAcknowledgment(prepared.scope);
|
|
603
|
+
assert.throws(() => assertCodexSetupSessionPostCommitAcknowledged(prepared.scope, { request: f.request, result, acceptedAt, resultRecordedAt }), /setup_session_post_commit_unconfirmed/);
|
|
351
604
|
await assert.rejects(withCodexSetupSessionSender({ scope: prepared.scope, vault: sender(f.vault), lease }, async () => { admitted++; }), /sender_conflict/);
|
|
352
605
|
late = () => originalCodexSetupSessionSender(prepared.scope);
|
|
353
606
|
});
|