Skip to content

fix(cooperation): preserve upload diagnostics during invalidation - #759

Closed
Jarvis636431 wants to merge 1 commit into
Tencent:mainfrom
Jarvis636431:fix/756-control-context-receipts
Closed

Jarvis636431 wants to merge 1 commit into
Tencent:mainfrom
Jarvis636431:fix/756-control-context-receipts

Conversation

@Jarvis636431

Copy link
Copy Markdown

Refs #756.

Root cause

A same-URL history.pushState during an upload emits a root Page.navigatedWithinDocument, which invalidates cooperation while the collector's document identity remains unchanged. The next guarded upload probe then latches revoked with Page interaction coverage changed; wait and synchronize.

uploadThroughActivatedFileInput already converts that guard failure into a phased file_input_probe_failed / resolve_input receipt. However, CooperationController.run() replaces it with generic control_context_invalid, even when the post-action refresh succeeds. This hides the upload phase and cause requested in #756.

Fix

When there is no structured checkFailure, preserve the upload handler's code, message, reason, phase, and transfer diagnostics, while taking effect_state and recovery guidance from the control failure.

This keeps the conservative effect_state: "unknown" after the upload trigger ran. Structured precondition failures remain authoritative, and the invalidated context cannot be reused.

Real-browser before/after evidence

I reproduced the reported control_context_invalid path using the real daemon + CLI + built MV3 extension in isolated headless Chrome 158.0.8127.37. The visible upload button performs history.pushState({}, "", location.href) without activating the hidden file input.

Version code reason phase effect_state
Parent 72d51aae, isolated reproduction permission_denied control_context_invalid control unknown
This branch, checked-in browser regression cdp_failed file_input_probe_failed resolve_input unknown

The after run also verifies that the trigger ran exactly once, no file was assigned, and the pathname remained unchanged. An immediate replay was blocked by the CLI ledger with uncertain_prior_effect and dispatched: false; after synchronization, the stale extension context was rejected with control_context_invalid.

This is a deterministic reproduction of the reported receipt path, not a claim to have exercised the reporter's private CMS or ruled out other triggers.

Tests

  • pnpm --filter @browser-skill/extension test — 4076 passed, 8 skipped
  • pnpm --filter @browser-skill/extension compile
  • pnpm --filter @browser-skill/extension build
  • Biome checks on all changed source and regression files
  • Real Chrome evals/browser/cases/regression/cooperation/run.mjs target-policy suite, including the new CLI upload scenario and existing CLI/MCP scenarios

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T10:44:52.417057Z 684b3f8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@NianJiuZst

Copy link
Copy Markdown
Collaborator

Closing this PR for two reasons:

  • Still no real-world reproduction evidence or verified root cause: The synthetic fixture in target-policy.html does not even activate — it merely calls history.pushState({}, '', location.href) to force the control_context_invalid branch. Fabricating a dummy button to match an error code is not a real upload reproduction and does not verify the actual root cause of [Bug]: 0.5.0 Windows/Edge upload still returns coverage-changed/unknown; internal phase/cause unavailable #756.
    The proposed change introduces multiple bugs and regressions:
    False error classification: It turns cooperation assert() rejections into code: "cdp_failed" / reason: "file_input_probe_failed" while still keeping the generic "Page interaction coverage changed; wait and synchronize" message, hiding what actually invalidated coverage.
  • Breaks cooperation contracts & downstream consumers: !checkFailure does not cover human_intervention, control_held, or document_changed. During tool.upload, those authoritative permission_denied reasons are overwritten by the upload catch wrapper, breaking bsk recipe handoff/retry logic and CLI error rendering.
    Drops frame diagnostics: Only effect_state and recovery are copied from controlFailure.data, discarding controlFailure.data.frames on FrameUnresponsiveError.
    Pre-click effect_state inflation: Failures before any click is dispatched (e.g., arm_input_probe) are still forced to effect_state: "unknown".

To maintain engineering quality, PRs must be backed by genuine reproduction evidence and a verified root cause rather than speculative fixtures.

@NianJiuZst NianJiuZst closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants