Skip to content

feat(browser): retain cleanup evidence for failed Agent Tasks - #139

Open
seonghobae wants to merge 12 commits into
test/agent-task-pristine-profile-admissionfrom
test/agent-task-failure-cleanup-evidence
Open

feat(browser): retain cleanup evidence for failed Agent Tasks#139
seonghobae wants to merge 12 commits into
test/agent-task-pristine-profile-admissionfrom
test/agent-task-failure-cleanup-evidence

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Partial implementation of #28, stacked on current exact PR #136 head 1cffb2e23d4002f12e8462c4c8c24f404a4eeee7.

Buyer/reliability gap

The controlled Agent Task runner previously discarded temporary-profile cleanup evidence whenever either the ordinary browser pass or forced-close probe failed. Outer loops retained only trial number, failure state, and exception type, while cleanup/isolation checks filtered to successful trials. A failed or interrupted task could therefore lack credential-free teardown evidence even though #28 requires deterministic failure/recovery and no leaked task profile.

A later exact-path audit found an additional owned exceptional-condition gap: bounded ChromeDriver teardown already used wait(timeout=5) with kill() fallback, but subprocess.TimeoutExpired from that reviewed teardown path was not among the trial wrappers' classified failures. A real teardown timeout could therefore escape the trial boundary instead of producing the same bounded failed-trial cleanup evidence.

Dependency and writer alignment

This Draft targets current exact #136 head 1cffb2e23d4002f12e8462c4c8c24f404a4eeee7 and must remain Draft while #136/#132 and their prerequisites remain active. Current exact #139 head is 10a60f59046c1a29a6e73084804aee0203798bbb. The current base is preserved as ancestry; no force-push, destructive rebase, base mutation, or predecessor evidence transfer occurred.

Test-first repair sequence

Earlier RED/GREEN cycles established ordinary and forced-close failure cleanup evidence plus separate all-trial cleanup gates. The latest resilience repair was also test-first:

  1. Exact RED head 0e66b24395aae595c569ad86b46e76ca3aad3a4a added ordinary and forced-close regressions that inject subprocess.TimeoutExpired with private synthetic command paths. The required result is passed: false, failure_type: "TimeoutExpired", profile_cleaned: true, with no raw command path in returned evidence.
  2. CI run 32443705971, Rust-contracts job 96659262887, checked out that exact RED head and failed at exactly those two intended Python boundaries because TimeoutExpired escaped instead of becoming bounded trial evidence.
  3. Current production head 10a60f59046c1a29a6e73084804aee0203798bbb adds only subprocess.TimeoutExpired to the reviewed failure classes in _run_agent_task_trial and _run_agent_task_forced_close_trial.

Implemented contract

Both Agent Task trial wrappers now:

  • catch only the reviewed browser-run/teardown failure classes (OSError, ValueError, RuntimeError, json.JSONDecodeError, subprocess.TimeoutExpired) inside the temporary-profile lifecycle;
  • retain only bounded failure type, never exception message, command path, browser text, or page content;
  • verify profile removal after the TemporaryDirectory context exits;
  • fail with a dedicated cleanup error if the profile remains;
  • return trial number, passed: false, failure type, profile_cleaned: true, and duration when reviewed browser/teardown work fails but profile cleanup succeeds;
  • preserve full successful-trial evidence plus profile_cleaned: true; and
  • leave unknown/unreviewed exception classes unnormalized.

Aggregate evidence computes cleanup across every ordinary and forced-close trial and applies distinct fail-closed cleanup gates before repeatability/recovery acceptance. A teardown timeout is therefore classified as failure evidence rather than success, and it does not weaken the later repeatability/recovery gate.

Exact-current-head validation

On unchanged exact head 10a60f59046c1a29a6e73084804aee0203798bbb against exact current prerequisite 1cffb2e23d4002f12e8462c4c8c24f404a4eeee7:

  • CI run 32444083415: success;
  • Manifest V3 Compatibility run 32444083543: success;
  • SAST Semgrep run 32444083450: success;
  • Security Scan run 32444083490: success;
  • GitHub reports the Draft mergeable against its exact current prerequisite;
  • fresh formal review inventory contains no review submissions; and
  • fresh inline review inventory contains no unresolved review threads.

No predecessor-head, prerequisite-head, synthetic-merge, skipped, cancelled, absent, stale, status-only, or model-only evidence is promoted as current proof.

Truth boundary

This lane records controlled temporary-profile teardown evidence only. It does not prove process termination, adversarial filesystem erasure, deletion of every browser artifact, operating-system keychain cleanup, renderer-crash attribution, arbitrary-task recovery, browser/adapter authenticity, policy authorization, durable incident evidence, or #28 completion. A production runtime still needs trusted task/process ownership, durable recovery evidence, and separately reviewed cleanup/retention semantics.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35474ee0-8f33-404d-a236-ac9baca1f015

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@seonghobae seonghobae changed the title test(browser): require failed Agent Task cleanup evidence feat(browser): retain cleanup evidence for failed Agent Tasks Aug 13, 2026
@seonghobae
seonghobae marked this pull request as ready for review August 26, 2026 22:06

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Open in Devin Review

Comment thread docs/README.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Large unrelated documentation revert in scope

Beyond the Agent Task cleanup-evidence change, the PR deletes many docs (DOCUMENTATION_FITNESS.md, ADR 0013/0014, evidence dossiers, extension-authority UML, several traceability files, six doc test files) and reverts PRD/TRD/traceability/ADR indexes to a simpler earlier state, dropping the maturity vocabulary and the ADR index-completeness rule. The PR description covers only cleanup evidence, so this scope needs confirmation as intentional rather than a rebase artifact.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread docs/adr/README.md
Comment on lines 24 to 26
| [0004](0004-resolved-destination-policy.md) | Logical origin and resolved destination safety | Accepted | SSRF/rebinding/special-purpose address and redirect authority |
| [0005](0005-direct-socket-binding.md) | Exact direct TCP peer binding | Accepted | explicit socket authority and operating-system peer proof |
| [0006](0006-tls-server-identity.md) | TLS service identity over the verified peer | Accepted | WebPKI identity, roots, time, ALPN and stream binding |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Accepted ADRs dropped from index but files remain

The ADR index in README.md and the list in README.md now stop at ADR 0006, yet docs/adr/00070010 still exist on disk. These Accepted decisions become undiscoverable, and the same change removes the index-completeness rule that would have flagged them.

(Refers to this code)

Prompt for agents
The ADR files docs/adr/0007-purpose-bound-sensitive-data-authority.md, 0008-leaf-validity-horizon.md, 0009-hourly-agent-credential-boundary.md and 0010-session-context-bound-node-authority.md still exist in the tree but are no longer referenced by either canonical index (docs/adr/README.md 'Current protected-main decisions' table and docs/README.md 'Protected-main architecture decisions' list, both of which now stop at ADR 0006). Either restore index rows/links for 0007-0010 with their correct lifecycle status, or, if these ADRs are intentionally being retired, remove/supersede the files themselves so the tree and the indexes agree. Confirm this orphaning is intended given the PR's stated scope is Agent Task cleanup evidence.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +1057 to +1067
duration_ms = round((time.monotonic() - trial_started) * 1000)
if failure_type is not None:
return {
"trial_number": trial_number,
"passed": False,
"failure_type": failure_type,
"profile_cleaned": True,
"duration_ms": duration_ms,
}
if result is None:
raise RuntimeError("Agent Task browser pass returned no result")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Cleanup-evidence-on-failure change is consistent

Both trial wrappers catch the reviewed failure classes, verify profile removal after the TemporaryDirectory exits, and return only failure_type/profile_cleaned (no exception text). The new agent_task_profiles_cleaned/forced_close_profiles_cleaned gates use .get() over all trials, so a genuine cleanup failure (which raises and yields a dict lacking profile_cleaned) still fails closed. Evidence is emitted before the gate raises.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant