Skip to content

fix(onboard): settle durable identity after Ready handoff - #11127

Closed
sandl99 wants to merge 18 commits into
mainfrom
fix/10976-ready-identity-handoff
Closed

sandl99 wants to merge 18 commits into
mainfrom
fix/10976-ready-identity-handoff

Conversation

@sandl99

@sandl99 sandl99 commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Qualification status: Blocked on current candidate 7d0e990f1d1c9bbda1055c7ee4b1e11ae5e47193. Required managed-image MCP discovery pass 1 reached Ready and completed the create handoff, then observed the sandbox in Deleting before first exec; pass 2 succeeded. The failed artifact does not retain identity-settlement evidence, so the causal durable-ID ordering is unresolved. No final Telegram repetitions count for this SHA.

Outcome

The investigation remains unresolved. Candidate 7d0e990f1d1c9bbda1055c7ee4b1e11ae5e47193 ends the OpenShell create-client handoff when Ready appears before the nonce-owned durable ID, but a required managed-image run then reached Ready, reported creation complete, and observed the sandbox in Deleting before first exec. The candidate is not accepted as a fix.

Reason

The original Telegram failure on 3076188279c0ea657ec77aeeabebf1f82061eaaf reached Ready before its create-attempt selector returned an ID, then observed Error. Later and latest targets passed. Deterministic tests proved the candidate's intended Ready-before-ID ordering, but the current managed failure shows that ending the client at Ready can still precede a stable usable sandbox. Because that artifact did not retain the settlement record, the evidence cannot distinguish a still-pending durable ID from another OpenShell transition; current-code causality and a safe minimal fix remain unproven.

Related issues

Refs #10976

Candidate changes

  • End the shared Ready handoff when the nonce-owned selector is still empty; reuse the existing bounded selector settlement and publication verification instead of adding retries or another state machine.
  • Record bounded trace diagnostics for every final settlement state, including identity replacement, using only a 16-hex SHA-256 correlation prefix.
  • Retain only the latest final operation state, settlement state, bounded correlation, and its own trace provenance in the existing E2E trace summary; timing remains owned by the longest trace, unusable input and absent events receive explicit bounded states, and raw event attributes and full fingerprints remain excluded.
  • Bind settlement events to their enclosing trace, reject conflicting latest events, and mark a source that exceeds the bounded file limit as incomplete evidence instead of reporting stale final state.
  • Add deterministic coverage where the ID appears only after the create client closes, plus fail-closed coverage when settlement never returns an ID.

Verification

  • Failing-first npx vitest run --project cli src/lib/onboard/sandbox-gpu-create-identity-gate.test.ts --coverage.enabled=false — before the product patch, 1 failed and 28 passed because the Ready check returned false; after the patch, 29 passed.
  • Failing-first identity-replacement diagnostic coverage — before the repair, the targeted test failed because the replacement path did not record its failed final settlement; after the repair, all 29 identity-gate tests passed.
  • Failing-first trace-artifact coverage — before the repair, 5 identity-gate tests failed because lifecycle events supplied the sanitizer-redacted full fingerprint field; after the repair, the trace artifact and lifecycle suites retain a 16-hex correlation without persisting the full fingerprint.
  • Failing-first retained-evidence coverage — before the reducer repair, the E2E-support test failed because the allowlisted settlement record was absent; afterward, it retains the three approved fields and rejects raw IDs and arbitrary event attributes.
  • Failing-first final-evidence selection — before the first repair, the multi-trace reducer could not identify the final attempt without mixing sources, and the workflow-boundary suite failed 4 of 9 tests because a support-only step rename drifted from its pinned contract. The final repair keeps longest-trace timing intact while the latest settlement record carries its own trace ID and validated timestamp; malformed settlement evidence suppresses the record fail-closed, and the pinned workflow step name remains intact.
  • Failing-first bounded-evidence completion — before the final reducer repair, 3 of 9 sanitizer tests failed because a wrong-trace event was accepted, an equal-timestamp conflict disappeared as absent evidence, and a 101-file source reported stale success; afterward, all 9 pass with explicit bounded invalid evidence.
  • Failing-first cloud-onboard boundary coverage — before the validator repair, 8 of 19 workflow-trace tests failed because missing, conditional, or reordered cloud-onboard trace steps and a late source guard were not all rejected; afterward, all 19 pass.
  • Failing-first partial-source evidence — before the final reducer repair, 1 of 10 sanitizer tests failed because a valid trace plus a later malformed JSON file still emitted the earlier matched settlement; afterward, the timing summary remains available but settlement evidence is explicitly invalid.
  • Missing-input and simplification coverage — absent trace input now emits bounded missing evidence, malformed or unusable input emits invalid, the workflow summary renders both recovery directions, and the unconsumed Ready-observation event and its deduplication state are removed.
  • Absent-event coverage — valid traces distinguish absent after the sandbox phase from not_attempted before it, and the generic workflow summary renders both without making the CPU-only cloud-onboard path depend on the GPU create-attempt producer. Direct sanitizer tests now live only in the dedicated sanitizer suite.
  • Producer-to-artifact proof — one representative test in the identity-gate owner drives the delayed-ID handoff through the real create runner, trace collector, and Python reducer, proving that identity verification follows settlement and that neither the raw durable ID nor its full fingerprint is retained. The same owner covers no-ID failure, timeout, replacement, and post-client-exit states; the sanitizer owner covers provenance and invalid evidence. The live workflow summary names the target and valid settlement provenance or visibly reports bounded invalid evidence with conditional recovery guidance.
  • npx vitest run --project cli --project e2e-support src/lib/adapters/openshell/sandbox-identity.test.ts src/lib/onboard/experimental/hermes-portable-onboarding-created-identity.test.ts src/lib/onboard/sandbox-gpu-create-identity-gate.test.ts src/lib/sandbox/create-stream.test.ts src/lib/trace.test.ts test/e2e/support/sanitize-trace-timing.test.ts test/e2e/support/e2e-workflow-trace.test.ts test/e2e/support/hermes-workflow-boundary.test.ts test/e2e/support/e2e-scorecard.test.ts --coverage.enabled=false — 9 files and 205 tests passed on candidate 784ac844a1d297a72c5bb2c25806598727c9face before the behavior-neutral unused-variable cleanup.
  • npx vitest run --project cli src/lib/onboard/sandbox-gpu-create-identity-gate.test.ts --coverage.enabled=false — 30 tests passed after removing the stale local on final candidate 7d0e990f1d1c9bbda1055c7ee4b1e11ae5e47193.
  • npm run test:changed — passed after the final review repair with 45 growth-guardrail tests and 114 selected tests across 7 files; the prior full candidate run passed 508 selected tests across 27 files.
  • npm run typecheck:cli — passed on the final candidate.
  • npm run checks:repository — passed.
  • npm run validate:pr — passed pre-commit, commit-message, and pre-push checks on the final candidate.
  • git diff --check origin/main...HEAD — passed.
  • Required managed-image qualification run 34070897188 — failed on current candidate 7d0e990f1d1c9bbda1055c7ee4b1e11ae5e47193. MCP discovery pass 1 reached Ready, completed the create handoff, then observed the sandbox in Deleting before first exec; its seven cleanup operations passed. The independent pass 2 and all-agent activation passed. This is an unresolved lifecycle failure, not passing acceptance evidence.
  • Main CI run 34070897213 / shard 8 failed in unchanged base-image-publication code when a 100 ms abort produced GitHub API request failed after 1 attempts just before the assertion expected time budget. The PR changes neither the implementation nor test; this inherited timing failure was classified without changing e2e(telegram): sandbox creation can reach Ready before returning a durable ID #10976 scope or rerunning the workflow.
  • Pre-review-repair E2E evidence: repeated manual PR target channels-add-remove three times on candidate 784ac844a1d297a72c5bb2c25806598727c9face, base 30271df8d6b810be4bc10a42a78194e805f9589e, and trusted workflow d7ad11fc64e0066057b958cbc5206b34727ea980, with identical selectors and mock-inference policy. These runs do not count as final exact-SHA evidence after the unused-variable cleanup:
  • Every retained 784ac844 E2E artifact binds the exact candidate and trusted workflow SHAs, reports one passed target with zero failed, skipped, pending, or unhandled results, and records every lifecycle phase as passed. Each cleanup record confirms sandbox destroy, OpenShell sandbox deletion, gateway removal, and fixture closure with no failures; the artifacts contain no symbolic links.
  • Pre-trace-repair E2E evidence: repeated manual PR target channels-add-remove three times on candidate 06f0370aca24f1eeb24d0e20715647ba4f04c1de, base 30271df8d6b810be4bc10a42a78194e805f9589e, and trusted workflow 5b14e5c299c3779c77895a6c092e874770551a18. These runs validate the lifecycle and final-settlement changes but do not count as final exact-SHA evidence after the trace-artifact repair:
  • Every retained pre-trace-repair E2E artifact reports one passed test; zero failed, skipped, pending, or unhandled results; the exact candidate and workflow SHAs; and successful sandbox, OpenShell sandbox, gateway, and fixture cleanup with no failures.
  • Pre-repair E2E evidence: repeated manual PR target channels-add-remove three times on candidate 530ae0fc8836b9e654982ff6614e55ea06e1e637, base 30271df8d6b810be4bc10a42a78194e805f9589e, and trusted workflow 5b14e5c299c3779c77895a6c092e874770551a18. These runs validate the primary lifecycle change but do not count as final exact-SHA evidence after the diagnostic repair:
  • Each retained pre-repair E2E artifact reports one passed test, zero failed/skipped/pending tests, zero unhandled errors, the exact candidate and workflow SHAs, and successful sandbox, OpenShell sandbox, gateway, and fixture cleanup with no failures.
  • Two dispatches are excluded from the repetition count: run 34046666583 stopped at the unpublished managed-image prerequisite, and run 34048393413 rejected an uppercase correlation UUID before collecting a test or creating a sandbox.
  • Secret review — the diff contains no secrets, API keys, credentials, or raw durable sandbox IDs.

Review notes

Sensitive-path self-review confirmed that the create-attempt nonce remains the ownership authority, identity settlement and publication verification remain mandatory before effects, ambiguous or missing identity remains fail-closed with retained recovery, and trace output contains only a 16-hex SHA-256 correlation prefix. The full fingerprint remains limited to retained recovery. The change adds no sleep, workflow retry, Telegram-specific branch, cleanup bypass, or weakened assertion. The duplicate CodeQL review-thread finding for the unused observedSandboxId local is addressed by the behavior-neutral two-line deletion in 7d0e990f.

The Advisor's identity-replacement diagnostic finding is addressed by 06f0370; its trace-sanitizer finding is addressed by ebf24b69; its retained-E2E-evidence finding is addressed by 9ca198fe; its final-event selection and workflow-boundary findings are addressed by ec03a0bf; its end-to-end evidence, duplicate parsing, and null-correlation guidance findings are addressed by df33a13a; its selected-trace ownership, malformed-final-evidence, and Ready-timeout diagnostic findings are addressed by dd1d301b; its final-operation provenance and post-client-exit evidence findings are addressed by c5fe34f2; its invalid-evidence visibility and post-Ready mismatch evidence findings are addressed by 6abfc4d0; its workflow-visible invalid-state finding is addressed by 6a005bdc; its conditional recovery wording, valid-summary consumer proof, and test-owner consolidation findings are addressed by 9482eb2e; its trace-binding, equal-time ambiguity, and bounded-file-completion findings are addressed by 7eb67f7f; its cloud-onboard trace-boundary proof finding is addressed by 30a24384; its partial-source evidence finding is addressed by 6fb4472a; its missing-evidence visibility and redundant-event findings are addressed by 51fa7121; its absent-event classification and sanitizer-owner consolidation findings are addressed by 5f2b492a; and its producer/consumer scoping finding is addressed by 784ac844. The earlier multi-scenario consolidation attempt failed the enforced 1,500-line test-owner budget at 1,538 lines; after reducing to one representative boundary case, the final consolidated owner is 1,452 lines. Its original changelog suggestion is not applicable: docs/changelog/2026-09-01.mdx is historical release evidence for v0.0.118 and accurately describes the ordering shipped in that release; rewriting it for this later fix would misstate release history.


Signed-off-by: San Dang [email protected]

@sandl99 sandl99 self-assigned this Sep 6, 2026
@copy-pr-bot

copy-pr-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit 7d0e990 in the fix/10976-ready-iden... branch remains at 96%, unchanged from commit d7ad11f in the main branch.


Updated September 07, 2026 00:48 UTC

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor finished for commit 7d0e990. Include the Advisor findings in the complete PR feedback collection. Verify and group valid findings before repair.

All previous runs

@sandl99 sandl99 closed this Sep 7, 2026
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow area: security Security controls, permissions, secrets, or hardening labels Nov 16, 2026
@cv
cv deleted the fix/10976-ready-identity-handoff branch November 21, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow area: security Security controls, permissions, secrets, or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants