Repository navigation
Closed
Description
Problem
#622 needs concrete browser-extension behavior tests. The Python receiver has normal pytest coverage, but the JavaScript/MV3 extension still lacks a behavior harness and package smoke gate.
This should be owned separately from receiver hardening: the missing contract is browser-extension behavior before data reaches the Python receiver.
Current state
browser-extension/
manifest.json
README.md
src/
Receiver side:
polylogue/browser_capture/
models.py
receiver.py
server.py
The extension and receiver are loosely coupled through an HTTP envelope POST. The harness should test the JS/MV3 side in isolation where possible, and reserve Python receiver integration for envelope compatibility checks.
Scope
Add a browser-extension test/package gate for the behavior contract in #622.
Likely implementation shape:
- Add a
browser-extension/package.jsonwith focusedtest,lint, and package/build scripts if none exists. - Use a CI-friendly JS test harness for content-script/background/popup behavior without requiring a full interactive browser unless a browser runner proves necessary.
- Add a packaging smoke that verifies the shipped zip/artifact contains the expected manifest, content scripts, background/popup files, and no checkout-only assumptions.
- Wire the gate into the verification surface for browser-extension changes, either via a focused
devtoolscommand, CI job, or documented package-local command that Proof Pack can point to.
Required behavior coverage
- Default mode performs no POST from content scripts before explicit manual capture.
- Auto-capture mode is persisted opt-in and visible in popup/badge state.
- Ambiguous role extraction yields
unknownor skips with diagnostics; no index-parity user/assistant fallback. - Envelope shape stays compatible with
polylogue/browser_capture/models.pywithout requiring receiver internals in every JS test. - The harness can exercise both ChatGPT and Claude content-script paths, or documents a phased split with linked follow-up.
Non-goals
- Do not use this issue to redesign browser capture storage semantics.
- Do not make the JS harness depend on a live ChatGPT/Claude page unless no deterministic fixture approach works.
- Do not duplicate all Python receiver tests in JavaScript.
- Do not route this through the broader verification-lab abstraction unless it adds real value over a standard package-local JS gate.
Acceptance criteria
- MV3 behavior harness verifies the required coverage above.
- Build/lint/package smoke runs in the normal verification surface chosen for browser-extension changes.
- Package gate proves the shipped artifact contains the expected manifest/content scripts and no checkout-only assumptions.
- The PR body records the exact JS/package command and any devtools/CI command that exercises it.
- If full ChatGPT + Claude path coverage is split, the remaining provider path has a linked follow-up issue with concrete missing fixtures.
Activity
Sinity commentedon May 2, 2026
Current browser extension state
Four Python modules on the receiver side:
Implementation notes
The Python receiver and JS extension are loosely coupled — the receiver is an HTTP server that accepts envelope POSTs. This issue's harness needs to test the JS side in isolation from the Python side.
Key boundary: the harness should be self-contained JS/MV3 tests. The
server.py/receiver.pyPython side is already covered by existing pytest infrastructure. The gap this issue fills is the JS behavior contract:unknownskip with diagnostics, not user/assistant fallbackFor build/lint/package smoke, the simplest CI-friendly approach: add a
package.jsonwithbuildandlintscripts tobrowser-extension/, wire them into adevtoolscommand or CI step, and verify the produced zip contains the expected manifest + content script files.Sinity commentedon May 6, 2026
Execution supplement
Mass-execution wave: #852 Wave 0 or Wave 5, mostly independent.
Focused verification:
polylogue/browser_capture/models.pyonly where the JS/Python boundary changes;devtools verify --quick, then fulldevtools verifybefore PR if repo-level tooling or Python receiver code changes.This should use standard JS/package gates unless a custom devtools hook clearly adds value.
Sinity commentedon May 7, 2026
Reconnaissance Report for #649
Current codebase evidence
Browser extension JS files (
browser-extension/src/):common.jsbuildEnvelope), FNV-1a hashing,sendCapture,refreshArchiveStatebackground.jspopup.jspopup.htmlcontent/chatgpt.jscontent/claude.jsNo
package.jsonexists -- confirmed zero match.No JS tests exist -- no test infrastructure of any kind.
Python receiver (
polylogue/browser_capture/):models.pyBrowserCaptureEnvelope,BrowserCaptureTurn,BrowserCaptureSession, etc.receiver.pyexisting_capture_stateserver.pyThreadingHTTPServer), origin auth, CORS__init__.pyExisting tests:
tests/unit/sources/test_browser_capture.py-- Python-side tests (provider detection, parsing, deduplication)Critical behavioral gap -- #622 changed the contract but JS not updated for test harness requirements:
Per #622 (latest revision 2026-05-01): Auto-capture is the default for supported pages. This supersedes the earlier "manual by default" language in this issue's body. The content scripts already implement auto-capture:
chatgpt.jsline 45-48:scheduleCapture()called on load, MutationObserver watches for changesclaude.jsline 40-43: same patternRole extraction with index-parity fallback (known bug to fix per #622):
chatgpt.jsline 11:return index % 2 === 0 ? "user" : "assistant"-- fallback when no DOM attribute foundclaude.jsline 8:return index % 2 === 0 ? "user" : "assistant"-- same issueunknownwith diagnostics; no user/assistant role assignment by index parity." This is currently violated.Envelope compatibility:
buildEnvelope()incommon.js(lines 25-57) builds the same shape asBrowserCaptureEnvelopeinmodels.pypolylogue_capture_kind,schema_version,capture_id,source,provenance(with all sub-fields),session(withprovider,provider_session_id,title,updated_at,model,turns)turnsincludeprovider_turn_id,role,text,ordinal,provider_metaBuild this (concrete behavior)
Add
browser-extension/package.json:{ "name": "polylogue-browser-capture", "version": "0.1.0", "private": true, "scripts": { "test": "...", "lint": "...", "build": "..." } }buildscript: produce a zip artifact containingmanifest.json, allsrc/files, READMElintscript: ESLint or similar JS linter for all.jsand.htmlfilestestscript: JS test runner (vitest/jest with jsdom for DOM fixture testing)Test harness files (
browser-extension/tests/orbrowser-extension/src/__tests__/):common.test.js--buildEnvelopeshape,fnv1adeterminism,conversationIdFromUrlchatgpt.test.js--collectTurnswith deterministic DOM fixtures,roleFromNodefor known/unknown nodesclaude.test.js-- same for Claude DOM fixturesenvelope.test.js-- envelope compatibility against Pythonmodels.pycontract (field names, types, required fields)package.test.jsor shell script -- verify zip contents (manifest.json present, src/ files present, no checkout-only files)Behavior coverage (updated for fix(browser-capture): harden capture mode, receiver, and adapters #622 final state):
chrome.storage.local@sitivityaisuppression is no longer needed -- auto-capture ON by default"unknown"with diagnostics when DOM attributes are ambiguous (NOT index-parity user/assistant)BrowserCaptureEnvelopemodel (all required fields present)Non-browser test strategy:
jsdomfor DOM fixture tests (no live browser needed)chrome.runtime.sendMessage,chrome.storage.local,chrome.tabs.queryvia Jest/Vitest mocksPackage gate:
npm run buildproducesdist/polylogue-browser-capture.zipmanifest.json,src/background.js,src/common.js,src/popup.js,src/popup.html,src/content/chatgpt.js,src/content/claude.jsare present.git,node_modules,tests/, or checkout-only files in zipCI/Verification surface:
cd browser-extension && npm ci && npm run lint && npm test && npm run builddevtools verify --quickor document as separate gateDo NOT build this
"unknown"return change. The fix(browser-capture): harden capture mode, receiver, and adapters #622 fix should be its own PR; this issue tests the contract.Files to touch
browser-extension/package.jsonbrowser-extension/tests/common.test.jsbrowser-extension/tests/chatgpt.test.jsbrowser-extension/tests/claude.test.jsbrowser-extension/tests/envelope.test.jsbrowser-extension/tests/package.test.jsbrowser-extension/.eslintrc.json(or eslint.config.js)browser-extension/vitest.config.js(or jest.config.js)browser-extension/README.mdbrowser-extension/.gitignorenode_modules/,dist/polylogue/browser_capture/models.pydevtools/(some file)npmgate into devtools verifyCoordination
browser-extension/index % 2 === 0 ? "user" : "assistant") in bothchatgpt.jsandclaude.jscurrently violates the fix(browser-capture): harden capture mode, receiver, and adapters #622 contract ("ambiguous DOM nodes are skipped or markedunknown"). Consider whether to fix here or in a separate PR.Focused tests
Final gates
devtools verify --quick(if JS gate is wired in)devtools verifybefore PR ONLY IF Python receiver or devtools code changesAcceptance criteria for #649
npm testpasses -- MV3 behavior harness verifies:npm run lintpasses all JS filesnpm run buildproduces zip with expected manifest + content scriptsBrowserCaptureEnvelopecontractAmbiguities / stale comments
unknownor skips with diagnostics; no index-parity user/assistant fallback"). Recommendation: make the fix here since the test harness needs to assert it, but keep it minimal (change return to"unknown"in both content scripts).devtools verifyor remain package-local? Issue body says "either via a focuseddevtoolscommand, CI job, or documented package-local command." Recommend: start with package-local, document in README and PR; wire into devtools only if it proves useful.feat: browser extension harness, reader smoke tests, session lineage (#…
feat: browser extension MV3 harness, reader smoke, lineage (#940)
Sinity commentedon May 7, 2026
Reopening after closed-issue/codebase reconciliation. This issue is not close enough to complete to fold into #944 as generic cleanup.
Current evidence on
master:browser-extension/package.json:7-11hastest,test:watch, andlint, but nobuildor package/zip smoke script.browser-extension/package-lock.json;cd browser-extension && npm ci --ignore-scriptsfails withnpm cirequiring an existing lockfile.cd browser-extension && npm run buildfails withMissing script: "build".browser-extension/src/content/chatgpt.js:11andbrowser-extension/src/content/claude.js:8still use index-parity role fallback, which violates the fix(browser-capture): harden capture mode, receiver, and adapters #622/test(browser-extension): add MV3 behavior harness and package gate #649 contract for ambiguous nodes.browser-extension/tests/content/chatgpt.test.js:7-10,90-95,114-122andbrowser-extension/tests/content/claude.test.js:7-10,90-94,124-133document/assert the parity fallback as the current behavior rather than failing on it.browser-extension/README.md:9andbrowser-extension/src/popup.js:42saypolylogue browser-capture serve, while the current docs usepolylogued browser-capture serve;browser-extension/manifest.json:5still says captures go into the local inbox.What remains in this issue:
npm ciwith committed lockfile or chosen equivalent).build/package smoke that proves the shipped MV3 artifact contents and excludes checkout-only files.Scope note: this should be excluded from #944's generic lint/baseline cleanup. #944 can reference it as a reopened specialized browser-extension gap.
feat: browser extension MV3 harness, reader smoke, lineage (#940)
Sinity commentedon May 8, 2026
Closing: core implementation landed. Remaining edges are incremental.