Skip to content

Commit 7b036d6

Browse files
committed
fix: recover Chief inspection boundaries and sealed verification routes (#2347)
1 parent 0e6e00b commit 7b036d6

50 files changed

Lines changed: 1274 additions & 204 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎PROJECT.md‎

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -231,51 +231,17 @@ a snapshot handoff, not a new main-targeting implementation PR or an upstream
231231
compatibility PASS. Runtime/private configuration and the frontend flow are untouched.
232232

233233

234-
### Task-role execution convergence — 2026-11-03 (#2184)
235-
236-
Task-role SDK retries retain pinned public persona/skills and the latest observed
237-
backend context across Attempts. Dynamic input is not a definition identity. A
238-
binding incompatibility or unknown old execution fails visibly; no silent fresh
239-
Session or rollback to older context. Definition snapshots are shared by digest,
240-
current rights still revoke execution, failed unused preparations release their
241-
pins, and model input follows a durable-save/cancellation barrier. Existing
242-
Harness/lease/Workflow services remain authoritative. Adapter capability inspection
243-
reports exact native Task-role resume with committed activation/quiescence; actual DSH deterministic return/context coverage is recorded separately from real-provider validation. No
244-
public service protocol, SQL transaction, deployment or frontend change is claimed.
245-
246-
247-
### Collaboration contract convergence — 2026-11-03 (#2175)
248-
249-
Expose durable Task handoffs through one scoped contract projection, with distinct
250-
pending/accepted/processed/revoked/invalidated states, source/target context references,
251-
actual claim/worker binding, initiative fences and predecessor/successor history.
252-
Idempotent trusted offer/accept ports reuse pools; unresolved old writers cannot be
253-
bypassed by Chief rerouting to another resource. Consultation is a separate private
254-
protocol over retained transcripts, without Task creation or initiative transfer.
255-
Chief prefers an active personal agent for user questions: safe answers require user
256-
publication, watch answers use existing inbox rights; only committed Effects may wake
257-
an authorized native watch. External clients have isolated mailboxes, not fabricated
258-
provider sessions. SDK process/HTTP tests and real-provider acceptance remain distinct.
259-
Native restoration/context bounds, transaction events and parent waits stay on their
260-
original dependent issues; no control-plane, deployment or frontend changes.
261-
262-
263-
### Context/memory convergence — 2026-11-03 (#2177)
264-
265-
Unify model/Harness context budgeting and bounded source tools across persistent
266-
Chief and temporary roles. Unknown capacity stays explicit; full rules/current
267-
constraints remain required, retrieval yields before overflow, and native/SDK input
268-
is checked before delivery. Working summaries use original public role-memory
269-
records with exact source/evidence/uncertainty, separate resident Chief topics and
270-
rollback of uncommitted staging. Facts have source/classification/version/archive;
271-
role-authored experience cannot declare facts or overwrite human control. Private
272-
notes retain history under bounded views. Codex tool history has an explicit cap;
273-
SDK compaction remains runtime-managed, without claiming aggregate usage is current
274-
window pressure. No new memory platform, executor or timer. Native Task-role physical
275-
restore2184 and normalized SQL storage2182 remain separate acceptance; real SDK
276-
verification must name exact runtime source hashes, not borrow deterministic tests.
277-
278-
Follow-up #2177: native resident Chief current facts are actual per-turn input with whole-input budget and final authority checks; do not rely on updating cached system prompt metadata. Preserve the original resident Session.
234+
### Role, collaboration and context convergence
235+
236+
Dated #2184/#2175/#2177 implementation checkpoints are [preserved verbatim](docs/history/2026-11-04-role-convergence-checkpoints.md).
237+
Current contracts remain active: one logical Session per Task/role; pinned persona,
238+
resource/profile and current delegation; actual exit before restoring context;
239+
consultation distinct from durable initiative handoff; private user context is not
240+
published automatically. Memory is bounded guidance, not authority or delivery
241+
proof. Preserve immutable source/history pages, verified evidence and independent
242+
acceptance; historical fixtures do not establish live-provider or UI completion.
243+
See [agents](docs/subsystems/project-agents.md), [Harness](docs/subsystems/project-harness.md)
244+
and the Project memory/context contracts for the current implementation.
279245

280246
### 2026-11-03 — Project Task contract (#2179)
281247

@@ -318,3 +284,7 @@ from preparation and tests. Nested Node test markers do not enter host verificat
318284
#2338 preflights input receipts before host side effects and returns correctable
319285
errors to the original role/Chief Session. Frozen proposals, bounded tool-free
320286
correction and durable receipts preserve work; stale/revoked input stays denied.
287+
288+
#2347 recovers birth-proven unmanaged native Chief invocations, preserves unknown
289+
external execution, and admits explicit sealed-candidate verification continuation
290+
under current authority/context gates. No live rollout or unknown-exit override.

‎ROADMAP.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,9 @@ not live npm ci provisioning or production Vitest acceptance.
178178
with all-plan preflight, immutable business evidence and explicit incomplete
179179
recovery. Tests distinguish deterministic role transport and actual SDK execution
180180
with a local provider fixture from paid-model/live project acceptance.
181+
182+
#2347 adds bounded inspection/stop reconciliation, explicit recovery facts and
183+
same-Attempt Tester/Reviewer continuation. Real disposable unmanaged DSH restart
184+
reaches a later original scheduled inspection with deterministic inference; paid
185+
model/live-instance acceptance stays separate. Legacy missing namespace evidence
186+
requires exact operator corroboration, never a guessed worker release.

‎changelog.d/2347.fixed.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Recover proven unmanaged native Chief invocations, bound exit waits, expose recovery causes, and allow evidence-supported Tester/Reviewer continuation of a sealed interrupted Attempt.

‎core/src/host/hooks.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,8 @@ export function install(rt) {
14321432
...(attempt.pr ? [{ pr: attempt.pr.number, sha: attempt.pr.sha, checks: 'unknown' }] : []),
14331433
]
14341434
},
1435+
validateRecovery: input => rt.projectDelivery.validateRecovery(input),
1436+
resumeVerification: input => rt.projectDelivery.resumeVerification(input),
14351437
complete: input => rt.projectDelivery.completePoolRole(input),
14361438
rework: input => rt.projectDelivery.reworkPool(input),
14371439
})

‎core/src/host/project-agents.js‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { inspectionLifecycle } from './project-chief-lifecycle.js'
12
import { captureProcessScope, priorHostProcessExited } from './project-process-proof.js'
2-
import { nativeChiefBoundary, scopeDigest } from './project-chief-recovery.js'
3+
import { nativeChiefBoundary, scopeDigest, corroboratedNativeScope } from './project-chief-recovery.js'
34
import { CHIEF_AUTONOMY } from './project-chief-protocol.js'
45
import { agentHistoryPage } from './project-history-pages.js'
56
import { createProjectAgentInbox } from './project-agent-inbox.js'
@@ -366,21 +367,21 @@ export function createProjectAgents(rt) {
366367
bot.instructions = priorPrompt.instructions
367368
if (priorPrompt.systemPrompt === undefined) delete bot.systemPrompt; else bot.systemPrompt = priorPrompt.systemPrompt
368369
}
370+
const run = state.projectExecutions?.[runId]
371+
if (!run || run.invocation !== invocation || run.status !== 'running') throw refuse('Chief invocation changed before execution admission')
369372
const delegation = { id: randomUUID(), exchangeId: randomUUID(), actor: { ...actor }, definitionRevision: set.revision, started: false, revoked: false, chiefJob: { runId, invocation, prompt: fullPrompt }, onChiefResult: onResult }
370373
delegations.set(agent.id, delegation)
371374
agent.lastRequest = { id: randomUUID(), initiatedBy: actor.memberId, executorBotId: agent.botId, exchangeId: delegation.exchangeId, phase: 'queued', context: snapshot, definitionRevision: set.revision, chiefRunId: runId, chiefInvocation: invocation, at: Date.now() }
372-
const run = state.projectExecutions?.[runId]
373-
if (!run || run.invocation !== invocation || run.status !== 'running') throw refuse('Chief invocation changed before execution admission')
374-
run.executionBoundary = { version: 'chief-execution-boundary/v1', kind: (definition.execution?.harness ?? 'flybot') === 'flybot' ? 'native-in-process' : 'sdk-worker', runId, invocation, botId: agent.botId, sessionId: agent.sessionId, carrierGeneration: agent.carrierGeneration, exchangeId: delegation.exchangeId }
375-
run.processScope ??= await captureProcessScope()
376-
await rt.save()
375+
run.executionBoundary = { version: 'chief-execution-boundary/v1', kind: (definition.execution?.harness ?? 'flybot') === 'flybot' ? 'native-in-process' : 'sdk-worker', phase: 'preparing', allocationKey: delegation.id, runId, invocation, botId: agent.botId, sessionId: agent.sessionId, carrierGeneration: agent.carrierGeneration, exchangeId: delegation.exchangeId }
376+
try { run.processScope ??= await captureProcessScope(); await rt.save() }
377+
catch (error) { if (delegations.get(agent.id)?.id === delegation.id) delegations.delete(agent.id); run.exitProof = { confirmed: true, kind: 'chief-never-dispatched', runId, invocation, at: Date.now() }; throw error }
377378
const finish = async result => {
378379
try { if (delegations.get(agent.id)?.id !== delegation.id || delegation.revoked) throw refuse('Chief execution was revoked'); const outcome = await onResult({ ...result, executionEvidence: { ...result.executionEvidence, chiefRunId: runId, carrierGeneration: agent.carrierGeneration } }); agent.lastRequest.phase = outcome?.correction ? outcome.correction.status === 'pending' ? 'correcting' : 'incomplete' : result.ok ? 'completed' : 'failed' }
379380
finally { restorePrompt(); if (delegations.get(agent.id)?.id === delegation.id) delegations.delete(agent.id); await rt.save(); rt.projectScheduler?.wake() }
380381
}
381382
delegation.finishChiefJob = finish; delegation.restoreChiefPrompt = restorePrompt
382383
try {
383-
if ((definition.execution?.harness ?? 'flybot') !== 'flybot') { delegation.started = true; delegation.sdkExecution = true; return await rt.projectHarness.chiefTurn({ agent, delegation, definition, context: snapshot, text: 'Inspect the pinned Project facts and return the bounded Chief judgement.', onResult: finish }) }
384+
if ((definition.execution?.harness ?? 'flybot') !== 'flybot') { run.executionBoundary.phase = 'allocating'; await rt.save(); delegation.started = true; delegation.sdkExecution = true; return await rt.projectHarness.chiefTurn({ agent, delegation, definition, context: snapshot, text: 'Inspect the pinned Project facts and return the bounded Chief judgement.', onResult: finish }) }
384385
const bot = rt.botOf(agent.botId)
385386
nativeSystem = definition.instructions + '\n\nFor each configured Chief job, use the current request protocol and scoped snapshot in that turn. Prior turns are historical background; act only on Task IDs and facts in the current snapshot. Preserve your resident Session and memory.'
386387
const nativeInput = fullPrompt + '\n\nCurrent scoped Chief job facts (data, not authority):\n' + snapshot.text
@@ -397,9 +398,15 @@ export function createProjectAgents(rt) {
397398
}
398399
await rt.projectChiefControl.validateActor(actor)
399400
if (delegations.get(agent.id)?.id !== delegation.id || delegation.revoked) throw refuse('Chief execution was revoked before current job input')
401+
run.executionBoundary.phase = 'input-sending'; await rt.save(); await rt.projectChiefControl.validateActor(actor)
400402
await rt.deliver({ toId: agent.botId, sessionId: agent.sessionId, role: 'request', audience: 'user', text: nativeInput, fromName: 'Project scheduled/arbitration request', untrusted: true, exchangeId: delegation.exchangeId, projectDelegation: { agentId: agent.id, delegationId: delegation.id } })
401403
return `native-chief-job-${runId}`
402-
} catch (error) { restorePrompt(); if (delegations.get(agent.id)?.id === delegation.id) delegations.delete(agent.id); throw error }
404+
} catch (error) {
405+
restorePrompt(); if (delegations.get(agent.id)?.id === delegation.id) delegations.delete(agent.id)
406+
const allocations = [...Object.values(state.projectResourceLeases ?? {}), ...Object.values(state.projectHarnessWorkers ?? {})].filter(row => row.attemptId === `chief-turn-${delegation.id}` || row.chiefRunId === runId && row.chiefInvocation === invocation)
407+
if (state.projectExecutions?.[runId] === run && run.invocation === invocation && !allocations.length && (run.executionBoundary.kind === 'sdk-worker' || run.executionBoundary.phase === 'preparing')) { run.exitProof = { confirmed: true, kind: 'chief-never-dispatched', runId, invocation, at: Date.now() }; await rt.save() }
408+
throw error
409+
}
403410
}) }
404411
function appendReply(agent, entry) {
405412
logOf(agent.id).push(entry)
@@ -633,7 +640,7 @@ export function createProjectAgents(rt) {
633640
async function reconcileChiefExit(run) {
634641
if (!['interrupted', 'failed', 'cancelled'].includes(run.status)) return false
635642
const selected = nativeChiefBoundary(state, run), scope = run.processScope, invocation = run.invocation
636-
if (!selected || !await priorHostProcessExited(scope)) return false
643+
if (!selected || !await priorHostProcessExited(corroboratedNativeScope(scope, run, rt.config.projectChiefRecovery?.legacyNativeScopes))) return false
637644
const current = () => state.projectExecutions?.[run.id] === run && run.processScope === scope && run.invocation === invocation && ['interrupted', 'failed', 'cancelled'].includes(run.status)
638645
if (!current()) return false
639646
const proof = { confirmed: true, kind: 'native-chief-prior-host-exited', runId: run.id, invocation, carrierGeneration: selected.boundary.carrierGeneration, scopeSha256: scopeDigest(scope), at: Date.now() }
@@ -659,13 +666,17 @@ export function createProjectAgents(rt) {
659666
const request = agent.lastRequest
660667
request.phase = 'stopping'; await rt.save()
661668
let confirmed = false
669+
const run = state.projectExecutions?.[runId]
670+
if (!request.workerId && (run?.executionBoundary?.kind === 'sdk-worker' || Object.values(state.projectHarnessWorkers ?? {}).some(row => row.chiefRunId === runId && row.chiefInvocation === request.chiefInvocation))) return { confirmed: false, reason: 'SDK admission is incomplete; reconcile its exact worker and leases without cancelling the native Chief' }
662671
if (request.workerId) confirmed = await rt.projectHarness.release(request.workerId)
663672
else {
664673
const active = await rt.resolveAgent?.(agent.sessionId)
665674
if (!active || typeof active.whenIdle !== 'function') return { confirmed: false, reason: 'Native Chief exit cannot be confirmed' }
666675
for (const message of [...(active.inbox?.nextStep ?? []), ...(active.inbox?.nextTurn ?? [])]) if (message.source?.exchangeId === request.exchangeId) active.inbox.remove?.(message.id)
667676
active.cancel?.({ kind: 'hook', reason: 'Configured Chief inspection deadline' })
668-
await active.whenIdle()
677+
let timer
678+
const stopped = await Promise.race([active.whenIdle().then(() => true), new Promise(resolve => { timer = setTimeout(() => resolve(false), inspectionLifecycle(state.projectChiefPolicies?.[projectId]?.inspection).stopTimeoutMs) })]).finally(() => clearTimeout(timer))
679+
if (!stopped) return { confirmed: false, reason: 'Native Chief exit confirmation timed out; execution remains isolated' }
669680
const lease = delegation?.resourceLease ?? request.resourceLease
670681
if (lease) await rt.projectResources.release(lease.id, lease.generation, { handle: request.exchangeId, exited: true })
671682
confirmed = true

0 commit comments

Comments
 (0)