Repository navigation
Preserve chat recovery and unify cancellation - #9142
Draft
mzxchandra wants to merge 2 commits into
Draft
mzxchandra wants to merge 2 commits into
mzxchandra wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Replay chat recovery onto subject delegation. Reuse the acting principal and narrow its chat invocation instead of minting a separate personal-chat identity. Co-authored-by: Cursor <cursoragent@cursor.com>
Chat recovery stays on the subject principal, and workspace admission follows the closed entity-owner grant. The run-stop migration follows the Sentinel migration already on that branch.
mzxchandra
force-pushed
the
marcus/chat-execution-foundation
branch
from
October 18, 2026 22:30
35aaaa9 to
a494e3f
Compare
mzxchandra
changed the base branch from
staging
to
codex/delegated-resource-scopes
October 18, 2026 22:30
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An admitted chat execution must retain its original identity and payer when the chat's current ownership representation changes. Bind authenticated callbacks to the exact actor, chat and original run, then separately authorize current chat and target access. Recovery uses the saved original billing admission. Personal chat authority is narrowly available to internal execution operations.
Add
copilot_run_stopskeyed only by user and stream. Stop/admission and orphan handling read unified plus applicable legacy intent; writes preserve legacy readers atomically. Remove only the run's workflow/workspace source foreign keys while retaining source IDs/indexes and chat/user/organization ownership cascades.This PR provides chat recovery and cancellation compatibility. Existing canonical creation/new-turn activation, attachments, retention, ownership conversion and historical backfill are outside this PR. Companion worker compatibility: simstudioai/mothership#735.
Merge prerequisite: human-subject delegation unification must land first. Preserve this execution/Stop slice, then rebase its own changes onto refreshed staging, adapt to the settled principal contract, and rerun focused validation and hosted CI. Current evidence applies to the present commit; it does not validate the future integration.
Review order
The migration is schema-only: one empty table plus two source-FK removals, with native user FK/PK and the existing migration runner. No row backfill or redundant preflight scan. Source deletion still follows owning chat/user/organization lifecycle; retaining provenance is not target access. Legacy Stop tables remain for compatibility. Later canonical activation requires the agreed compatible app/worker deployment and drain checks.
Testing
Latest remediation commit
35aaaa9c3f: 29 focused PostgreSQL/Redis integration tests passed using versioned migrations. Twelve independently injected regressions failed for the intended reasons, then all faults were restored: target/catalog scope widening, current access revocation, actual CLI execution correlation, forced Stop/admission ordering, transactional legacy-write failure, and source-deletion retention. The CLI path also rejects mismatched and unknown run correlation. Focused source/test types and targeted audits passed. Full hosted checks for this commit passed; prior green CI below is historical.The combined real-model test passed for a crash after the initial user message was durable: a synthetic ownership change from workspace X to organization B, actual worker termination/restart and natural lease recovery, new successful workspace/member tool calls, and persisted browser output. Original X remained accessible, Y was denied, and a subsequent role downgrade plus explicit X revocation denied access; roles/grants were restored. Billing-enabled callbacks retained the distinct original payer A, left B's ledger unchanged, and rejected a duplicate callback without changing the usage ledger. This proves recorded usage accounting, not payment collection.
The original browser's complete answer and idle composer were visually verified in its trace/screenshot. Its exact-text completion locator timed out because the rendered marker had trailing markdown; that automated failure is retained, and reload/access checks passed separately. Extra model CLI attempts were refused. The initial Sim snapshot preceded normal billing-admission persistence; the original run identity and other saved fields were unchanged, and the saved billing admission matched the worker's immutable envelope.
An earlier crash window remains open: after worker admission but before its first conversation input is durable, recovery returns
nothing_to_continue. That failure is preserved and requires a separately reviewed worker storage decision; no new storage has been implemented. The later-boundary pass does not close it. Ownership transitions here are synthetic disposable-data setup, not supported product transfer or canonical activation. Deployed staging and disabled approval flows remain untested.Earlier validation:
INTEGRATION_DB_PROVISION=migrate: Stop/admission races, removal, orphan settlement, original admission and source deletion/history preservation.4163b52766(run), including lint, types, unit/integration tests, builds and desktop/mobile E2E.Actual local Chromium testing with both current PR heads passed session/start/response persistence, history reload, Stop with both persisted intents, active reconnect without duplicate admission, and denied-actor access. That deterministic matrix used a scripted model endpoint through the actual worker SDK; it is separate from real-provider testing and deployed verification. Approval was not exercised because the existing flag is disabled.
A separate real-provider browser pass with Google native
gemini-3.8-flashpassed streamed response/persistence, reload with contextual follow-up, verified read-only workspace/member CLI results, Stop during generation, and active-run reload/reconnect. Actual app/worker paths and stored outcomes were checked. Invalid model CLI argument attempts were refused before successful authorized reads. Local billing was disabled, so this does not prove charged billing.Additional actual-browser lifecycle checks passed immediate reload after Stop and recovery after terminating/restarting the local worker, with the same run, saved request context and immutable worker admission hash; the worker lease advanced once and the run completed. The crash test used normal lease/sweeper timing and a deterministic provider; no database timestamps were altered.
Deployed staging verification is NOT RUN. The private before/after plan requires old-release legacy Stop/recovery fixtures and release/schema evidence before rollout; fixture setup is blocked on the coordinated workspace selection. Local paired proof is not staging or production readiness. No merge, deployment, rollback, flag change or live mutation performed.
Type of Change
Checklist