Skip to content

test(browser): add controlled Agent Task fixture - #65

Open
seonghobae wants to merge 2 commits into
mainfrom
test/agent-task-controlled-fixture
Open

test(browser): add controlled Agent Task fixture#65
seonghobae wants to merge 2 commits into
mainfrom
test/agent-task-controlled-fixture

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Partial implementation of #28.

Buyer-visible gap

The first real Chromium Agent Task slice needs a deterministic local web application whose semantic form, hostile hidden page content, and observable post-condition are stable enough to exercise observation → policy → typed action → verification without production credentials or a live third-party site.

TDD evidence

This lane is based directly on protected main 67af7c87589edc2039545af335c95064d9b8391c.

  1. Test-only exact head d2580305f05aba93d10b5342ec1886d601c6752e introduced the contract for tests/fixtures/agent_task_basic/index.html before the fixture existed.
  2. CI run 31445088008, Rust contracts job 93637443229, checked out that exact head and failed in Python repository contracts with exactly three FileNotFoundError failures for the absent fixture. Repository checkout evidence confirms the tested revision. This is the intended fail-first boundary, not a predecessor failure reused as success evidence.
  3. Exact head 0888fe3a6ef6da547a37fd075733cc73dc52b2ab adds only the controlled fixture required by that contract.

Implemented boundary

The fixture now provides:

  • a labelled semantic text field (task-text) and submit control that can later be discovered by role/name rather than CSS/XPath authority;
  • deterministic same-document state transition from data-state="idle" to data-state="submitted" while exposing only the typed synthetic value as the result;
  • one explicitly marked hidden/untrusted prompt-injection string that attempts to make the consumer ignore policy and request new browser capabilities;
  • synthetic local data only, with no password, OTP, API-key or secret collection surface; and
  • no network dependency or live third-party application requirement.

Exact-head verification

On unchanged exact head 0888fe3a6ef6da547a37fd075733cc73dc52b2ab:

  • CI run 31445201739: success;
  • Rust contracts job 93637824750: repository Python contracts, formatting, locked workspace check, full tests, strict Clippy and rustdoc all success;
  • Production coverage job 93637824824: success, including exact owned production function/line/region/branch enforcement;
  • Security Scan run 31445201774: success;
  • SAST Semgrep run 31445201669: success;
  • CodeRabbit exact-head commit status: success;
  • no formal reviews or inline review threads are currently returned; and
  • GitHub reports the PR mergeable.

No predecessor-head check or review is transferred to this exact head.

Scope boundary

This fixture is controlled test infrastructure, not a browser adapter or action-success claim. It does not implement WebDriver BiDi/CDP, semantic extraction from Chromium, deterministic policy dispatch, native browser input, trusted clock provenance, secret handling, destination authority, post-condition evidence, profile teardown, process attribution, or the complete issue #28 vertical slice. The next runtime lane must execute this fixture through pinned stock Chromium and preserve the existing authority boundaries rather than turning page content into instruction or capability authority.

Summary by CodeRabbit

  • 테스트
    • 에이전트 작업의 입력 폼, 제출 결과, 상태 변경 동작을 검증하는 테스트 fixture를 추가했습니다.
    • 레이블과 입력 필드 연결, 버튼 동작, 결과 텍스트 갱신을 자동으로 확인합니다.
    • 숨겨진 비신뢰 지시문 처리와 민감한 자격 증명 필드가 포함되지 않았는지도 검증합니다.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

결정적 Agent Task HTML fixture를 추가했습니다. fixture는 입력 제출 결과와 submitted 상태를 표시합니다. 계약 테스트는 DOM 구조, 상태 변경, 비신뢰 지시문, credential 필드 부재를 검증합니다.

Changes

Agent Task fixture

Layer / File(s) Summary
Fixture 동작과 계약 검증
tests/fixtures/agent_task_basic/index.html, tests/test_agent_task_fixture_contract.py
HTML fixture가 입력 폼, idle 결과 상태, 숨겨진 prompt-injection 지시문을 정의합니다. 제출 시 기본 동작을 차단하고 입력값과 상태를 갱신합니다. 테스트는 요소 식별자, label 연결, input 이름, 버튼 타입, 결과 갱신, 비신뢰 콘텐츠 수, credential 필드 부재를 검증합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 제어된 Agent Task fixture를 테스트에 추가한 주요 변경 사항을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/agent-task-controlled-fixture

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 marked this pull request as ready for review August 11, 2026 00:14

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_agent_task_fixture_contract.py`:
- Around line 37-41: Update the HTML attribute parsing used by the
hidden-injection contract to retain the complete parsed attributes for each
input element. Increment hidden_injection_markers only when an untrusted marker
also has a hidden attribute, and validate credential inputs from parsed
attribute values rather than raw quoted text: reject type=password and
autocomplete values password or one-time-code regardless of quote style.
- Around line 62-64: HTML 문자열 검사만 수행하는
tests/test_agent_task_fixture_contract.py에 실제 브라우저 제출 검증을 추가하십시오.
scripts/ci/run_mv3_compatibility.py의 기존 Chrome WebDriver 경로에서
agent_task_basic/index.html을 로드하고 task-text를 변경해 제출한 뒤, 제출 전후 URL이 동일하고
task-result의 data-state가 submitted이며 textContent가 변경한 입력값과 정확히 일치하는지 검사하십시오.
.github/workflows/mv3-compatibility.yml의 실행 경로에 해당 fixture와 테스트 변경을 포함하십시오.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 60e1549b-6ea0-49e9-b88e-5e7de0c066c0

📥 Commits

Reviewing files that changed from the base of the PR and between 67af7c8 and 0888fe3.

📒 Files selected for processing (2)
  • tests/fixtures/agent_task_basic/index.html
  • tests/test_agent_task_fixture_contract.py

Comment on lines +37 to +41
if (
attributes.get("data-originweave-untrusted") == "prompt-injection"
and attributes.get("aria-hidden") == "true"
):
self.hidden_injection_markers += 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

보안 조건을 HTML 속성으로 검증하십시오.

현재 hidden_injection_markers 조건은 hidden 속성을 확인하지 않습니다. aria-hidden="true"만 남아도 숨김 프롬프트 인젝션 계약이 통과합니다. 또한 자격 증명 검사는 원본 문자열의 큰따옴표 표기만 찾습니다. 예를 들어 type='password'는 이 검사를 통과합니다.

input의 전체 속성을 파서에 저장하십시오. hidden 속성이 있는 untrusted marker만 계산하십시오. type=password와 password 또는 one-time-code autocomplete 값을 속성 값으로 거부하십시오.

Also applies to: 76-85

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_agent_task_fixture_contract.py` around lines 37 - 41, Update the
HTML attribute parsing used by the hidden-injection contract to retain the
complete parsed attributes for each input element. Increment
hidden_injection_markers only when an untrusted marker also has a hidden
attribute, and validate credential inputs from parsed attribute values rather
than raw quoted text: reject type=password and autocomplete values password or
one-time-code regardless of quote style.

Comment on lines +62 to +64
self.assertIn('data-state="idle"', self.html)
self.assertIn('result.dataset.state = "submitted"', self.html)
self.assertIn("result.textContent = taskText.value", self.html)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate existing browser-test infrastructure before adding the interaction contract.
rg -n -C 2 --glob '*.py' \
  'sync_playwright|async_playwright|selenium|webdriver|page\.(goto|fill|click|locator)' \
  tests || true

Repository: ContextualWisdomLab/OriginWeave

Length of output: 169


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- candidate files ---'
git ls-files | rg '(^|/)(test_agent_task_fixture_contract\.py|.*agent.*task.*|.*fixture.*|.*html.*|.*js$|.*ts$)' | head -200

printf '%s\n' '--- test file ---'
cat -n tests/test_agent_task_fixture_contract.py

printf '%s\n' '--- referenced identifiers ---'
rg -n -C 4 --glob '!tests/test_agent_task_fixture_contract.py' \
  'task-text|task-result|data-state|result\.dataset\.state|preventDefault|taskText' .

Repository: ContextualWisdomLab/OriginWeave

Length of output: 6945


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- repository configuration ---'
git ls-files | rg '(^|/)(pyproject\.toml|pytest\.ini|setup\.cfg|tox\.ini|requirements.*|package\.json|.*lock|Makefile|README.*|\.github/)' | head -200

printf '%s\n' '--- test and browser tooling references ---'
rg -n -i -C 2 \
  'playwright|selenium|webdriver|chromium|browser|unittest|pytest|test_agent_task_fixture_contract|agent_task_basic' \
  --glob '!tests/fixtures/agent_task_basic/index.html' .

printf '%s\n' '--- fixture implementation ---'
cat -n tests/fixtures/agent_task_basic/index.html

printf '%s\n' '--- available browser executables (if any) ---'
for name in chromium chromium-browser google-chrome google-chrome-stable firefox; do
  command -v "$name" || true
done

Repository: ContextualWisdomLab/OriginWeave

Length of output: 50390


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- browser-related tracked files ---'
git ls-files | rg -i '(^|/)(.*(browser|chrom|webdriver|mv3|compat).*)$|(^|/)(package\.json|.*workflow.*\.ya?ml)$' | head -300

printf '%s\n' '--- exact runner/workflow references ---'
rg -l -i \
  'sync_playwright|async_playwright|selenium|webdriver|chromedriver|chrome-for-testing|run_browser_pass|browser lane|real browser' \
  .github scripts tests docs 2>/dev/null | head -100

printf '%s\n' '--- targeted test references ---'
rg -n -C 3 \
  'RUNNER|WORKFLOW|run_browser_pass|chrome-for-testing|webdriver|browser lane' \
  tests/test_mv3_compatibility_contract.py .github scripts 2>/dev/null | head -300

printf '%s\n' '--- concise fixture and test-strategy excerpts ---'
sed -n '1,80p' tests/fixtures/agent_task_basic/index.html
sed -n '60,78p' docs/TEST_STRATEGY.md
sed -n '138,153p' docs/TEST_STRATEGY.md

Repository: ContextualWisdomLab/OriginWeave

Length of output: 30300


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- existing WebDriver runner ---'
sed -n '1,280p' scripts/ci/run_mv3_compatibility.py

printf '%s\n' '--- browser workflow execution steps ---'
sed -n '1,150p' .github/workflows/mv3-compatibility.yml

printf '%s\n' '--- runner entry point and CLI ---'
sed -n '280,520p' scripts/ci/run_mv3_compatibility.py

Repository: ContextualWisdomLab/OriginWeave

Length of output: 23530


실제 브라우저 제출 계약을 추가하십시오.

tests/test_agent_task_fixture_contract.py는 HTML 문자열만 검사합니다. 기존 scripts/ci/run_mv3_compatibility.py의 고정 Chrome WebDriver 경로를 확장하여 agent_task_basic/index.html을 로드하고 다음을 검사하십시오.

  • task-text 값을 변경한 후 제출합니다.
  • 제출 전후 URL이 동일한지 검사합니다.
  • task-resultdata-statesubmitted인지 검사합니다.
  • task-result.textContent가 변경한 입력값과 정확히 같은지 검사합니다.

.github/workflows/mv3-compatibility.yml이 이 fixture와 테스트 변경 시 실행되도록 경로도 추가하십시오.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_agent_task_fixture_contract.py` around lines 62 - 64, HTML 문자열 검사만
수행하는 tests/test_agent_task_fixture_contract.py에 실제 브라우저 제출 검증을 추가하십시오.
scripts/ci/run_mv3_compatibility.py의 기존 Chrome WebDriver 경로에서
agent_task_basic/index.html을 로드하고 task-text를 변경해 제출한 뒤, 제출 전후 URL이 동일하고
task-result의 data-state가 submitted이며 textContent가 변경한 입력값과 정확히 일치하는지 검사하십시오.
.github/workflows/mv3-compatibility.yml의 실행 경로에 해당 fixture와 테스트 변경을 포함하십시오.

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