Merge wake repairs and managed expiry ordering into sleep-30-inbound-wake-notices

Co-Authored-By: Paperclip <noreply@paperclip.ing>

* codex/sleep-29-native-chat-progress:
  fix: expire stale managed arguments before consuming admission
This commit is contained in:
DottaandPaperclip committed 2026-10-27 04:43:30 -05:00
commit 7e0d385474
2 files changed
+44 -19

No files matched your search

+23
View File
@@ -231,3 +231,26 @@ claim validation fixed it. Typechecking then exposed root-client-only signatures
which were narrowed to their actual database capabilities. The final complete
suites and TypeScript check pass; stack integration and current-head CI remain
separate gates. This proves worker and admission behavior, not deployed host sleep.
## Managed-argument expiry ordering
Latest-head CI exposed a preparation-order regression in
`tool-gateway.test.ts`: a valid historical Shopify approval whose managed UCP
arguments were obsolete became `failed` instead of `expired`. The new consuming
admission compared the current invocation identity before the existing managed
argument expiry owner ran. It prevented dispatch, but bypassed the correct saved
expiry outcome.
Approved execution now verifies target/signed/managed arguments and content
before consuming admission. Exact claim fencing, fresh policy checks, atomic
rate receipts, and the final issue-open check remain before dispatch. No check
was removed and stale payloads are not permitted to execute.
The existing regression reproduced the CI failure on this owner in
`/tmp/sleep-approved-managed-expiry-red.log`. All 92 gateway acceptance cases
pass after the ordering change (`/tmp/sleep-approved-managed-expiry-full.log`),
including the historical approval's expired request, failed invocation with
`approvalState: expired`, and zero provider requests. Server typecheck passes
in `/tmp/sleep-approved-managed-expiry-types.log`. Latest-head remote CI and
combined-stack acceptance still need their own results.
+21 -19
View File
@@ -8107,25 +8107,6 @@ export function createToolGatewayService(
session,
tool,
);
const currentAccess = await policyService.admitInvocation(
policyInputForTool({
session,
tool,
parameters: signedPayload.arguments,
consumeRateLimit: false,
}),
invocation.id,
claim,
);
if (
!currentAccess.allowed &&
currentAccess.decision !== "require_approval"
)
throw new ToolGatewayHttpError(
403,
currentAccess.explanation,
currentAccess.reasonCode,
);
if (
!approvalSnapshotsMatch(
signedPayload.approvalSnapshot,
@@ -8184,6 +8165,27 @@ export function createToolGatewayService(
sensitiveMode: "redact",
promptInjectionMode: "ignore",
})).summary;
// Validate the signed and managed payload before consuming admission.
// Historical payload drift belongs to the expiry owner above.
const currentAccess = await policyService.admitInvocation(
policyInputForTool({
session,
tool,
parameters: signedPayload.arguments,
consumeRateLimit: false,
}),
invocation.id,
claim,
);
if (
!currentAccess.allowed &&
currentAccess.decision !== "require_approval"
)
throw new ToolGatewayHttpError(
403,
currentAccess.explanation,
currentAccess.reasonCode,
);
// Final recheck at the last DB write before dispatch: tool and snapshot
// resolution above involve network calls, so re-verify the issue is still
// open now that only the provider call remains. A close that commits after