Skip to content

refactor(helpers): share data-home, dotenv parsing and path redaction - #136

Merged
lanyue-llk merged 10 commits into
mainfrom
refactor/shared-env-datahome-redaction
Nov 3, 2026
Merged

lanyue-llk merged 10 commits into
mainfrom
refactor/shared-env-datahome-redaction

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #91. This PR covers data-home resolution, .env parsing and local-path redaction.

Remaining work, moved to #150:

  • sha256 / JSON digest helpers and JSON read/write helpers (separate PR).
  • Per-surface redaction rules are centralized, not merged; see "Redaction" below.

Summary

One owner per concern, every caller migrated, the private copies removed. Grep tests with negative controls keep new copies out.

Data home: harness/data_home.py

Promoted from web_fetch/storage.py. The copies disagreed as follows:

Input Before Now
~/x expanded by some; a literal ~ directory in lexbench/report.py, catalog_release.py expanded
relative path resolved by some resolved
empty value default in storage.py; working directory in the others default
unset, symlinked home unresolved in storage.py, resolved in web_search/publication.py resolved, so containment checks agree
evaluation time import time in lexbench/report.py every call; ROOT is gone

Behavior changes to review:

  • lexbench/verification.py --site and public_webarena/release.py --formal-root hard-coded ~/.browser-eval. Their defaults now follow BROWSER_EVAL_DATA_HOME.
  • public_webarena/webarena.py still requires an explicit home or --output, through configured_data_home().

Left alone on purpose:

  • harness/benchmarks/data.py cache: docs/benchmarks.md says changing the evidence directory does not change the dataset cache.
  • lexbench_webfetch/inputs.py: a separate package with its own LEXBENCH_DATA_HOME precedence and default.

.env parsing: harness/env_file.py

There were three hand-written runtime parsers, two more in web_fetch/accounts.py and web_fetch/wcxb_report_check.py, plus direct dotenv_values calls in report_languages, browser_use/runner and web_search/relevance. All now use parse_env_file, which is the locked python-dotenv grammar without interpolation. A locked library replaces hand-written syntax rules, and turning interpolation off keeps "values are data".

Syntax Web Fetch / public WebArena before catalog_runner before dotenv_values callers before Now
A="x' mismatched quotes kept with quotes repaired to x dropped dropped with a line-number warning
export A=1 ignored key export A A=1 A=1
A=x # note x # note x # note x x
A="a\nb" literal backslash literal backslash newline newline
A=${B} literal literal expanded in report_languages; literal in browser_use/runner and web_search/relevance since #134 literal
duplicate name first wins, except Web Fetch credentials last wins last wins last wins
value spanning physical lines not supported not supported delivered dropped with a line-number warning
A=1 then A="x' raw "x' for overriding Web Fetch credentials; otherwise 1 x 1 A missing
A=1 then A="x / y" raw "x for overriding Web Fetch credentials; otherwise 1 x x\ny A missing
A=1 then bare A 1 1 no value A missing

python-dotenv alone lets an unterminated quote run to the next matching quote, so A="x\nB="\nC=1 would deliver A as a value containing the next line. The wrapper drops any value that spans physical lines, and the name that opens it counts as missing. A name on an absorbed line is not assigned there, so B=1 followed by A="x / B=" keeps B=1. Such a value cannot be told apart from an intended multi-line one, so intended ones are dropped too; no .env.example name needs one, and an escaped \n in double quotes still gives a newline. Both forms are pinned by tests.

The last statement of a name decides it, including one that yields no value: a rejected assignment or a bare A line removes an earlier A, so the name counts as missing. Failing closed won over falling back because a rotated credential with a quoting typo would otherwise run on the stale value with only a line-number warning, and import_credentials would report it as present. Lines that do not assign the name, such as A B=2 or A trailing, leave A alone. Bare names and rejected duplicates in .env are a further case for operators to check.

Which credentials are read does not change: removal of parent-shell credentials, the repository-only rule, setdefault and the symlink rejection stay in each caller, and a test pins them. The parsed value can change for a .env that uses the syntax in the table, so operators with inline comments, duplicate names or backslashes in double quotes should check their files. .env.example uses none of the affected forms.

scripts/import_benchmark_env.py (accounts.import_credentials) now decides whether a value is usable from parse_env_file, so it cannot report complete credentials that the runtime reads as missing. It copies the winning statement verbatim through read_env_statements, so an export prefix or spaces around = are now copied rather than normalized. A whitespace-only value now counts as empty. It refuses, without changing the target, when an unterminated quote already in the target would absorb the addition. The WCXB visual check treats an empty CHROMIUM_BINARY= as missing instead of passing an empty path on.

web_search/runner.py adds harness/env_file.py to collection_implementation(), because parsing moved out of a file it already freezes. Together with the edit to web_fetch/config.py, this makes validate_resume_implementation reject resuming a Web Search cohort started before this PR, so an in-flight cohort must finish on its original checkout. Completed cohorts are unaffected.

Redaction: harness/reporting/privacy.py

The existing module now owns every rule, including ones the issue did not list (browser_use, public_webarena, lexbench, wcxb_scoring, web_fetch/runner, publication_privacy, fix_log and the release checks).

Public redaction output does not change, so no disclosure applies. The rules are not merged, because their outputs differ and rebuilt public files are hash-bound. Each surface keeps a named policy with its pattern moved verbatim, and test_surfaces_keep_their_disagreements fails if two surfaces are later merged. Converging them would change published bytes and needs an owner decision.

The replacements count in public-view receipts is also unchanged.

Test plan

  • After rebasing onto a26f6ed (build(packaging): bundle package data and move package gate to Python #135), on head 7738fc2: ruff check (both gates) passes. tests/test_golden_reports.py passes with snapshots unchanged. The golden, PR and conflicted-file tests give 11 failed, 1797 passed. The same 11 fail on unmodified a26f6ed from this nested worktree: 2 are on the known local failure list and 9 raise the Historical benchmark source lookup error described below. These runs set the import path with pytest's pythonpath option, so subprocess-based tests may import another checkout.
  • After review round 2, on head f96b8ea: ruff check (both gates) passes. tests/test_env_file.py, tests/test_data_home.py, tests/test_config.py, tests/test_accounts.py, tests/test_golden_reports.py (snapshots unchanged), tests/trajectory_replay/public_webarena/test_config.py, tests/test_runtime_entrypoints.py, tests/test_cli_scope.py, tests/web_search/test_runner.py: 183 passed. With the parser change reverted, 11 of the new tests/test_env_file.py cases fail. The full local suite was not rerun; CI is the full-suite gate. The older entries below describe earlier revisions.
  • ruff check (both gates): pass on f96b8ea.
  • After review round 1, on the head of that round: tests/test_env_file.py, tests/test_data_home.py, tests/test_config.py, tests/test_accounts.py, tests/test_local_path_privacy.py, tests/test_storage.py, tests/test_golden_reports.py (135 passed, snapshots unchanged) and tests/trajectory_replay/public_webarena/test_config.py, tests/test_runtime_entrypoints.py, tests/test_cli_scope.py, tests/web_search/test_runner.py (65 passed). The full local suite was not rerun for this round; the figures below are from the first revision.
  • --site and --formal-root defaults are pinned by test_retained_report_entry_points_default_under_the_selected_home, which stops at parse_args.
  • The extended grep guard was checked against the two parsers it missed, at 289eeed: it matches both.
  • New: tests/test_data_home.py, tests/test_env_file.py, tests/test_local_path_privacy.py: all pass.
  • One-off differential against the regexes at 2740130: 50,000 generated strings across every substitution policy and the found checks, 0 mismatches. It ran before the last edit to found, which only swaps a comparison for search on non-URL policies. It did not cover receipt counts; the full suite caught and I fixed a len() bug there.
  • tests/test_golden_reports.py: passes with snapshots unchanged, no route hash regenerated.
  • Full local suite in the worktree: 66 failed, 18876 passed, 60 skipped. These are not a clean local result:
    • Most fail with Historical benchmark source is not recorded in the dataset lock, because benchmark_input_path walks up from the worktree into a stale evaluation/lexbench-webfetch.json in the parent checkout.
    • Rerunning the 22 files with failures from a copy outside that checkout left 18 failures. 15 are on the known local failure list.
    • The other 3 are in tests/test_optional_reports.py, whose subprocess imports the shared environment's checkout rather than this branch. I did not confirm them further, so they rely on CI.
  • Subprocess-based local tests can import that other checkout for the same reason. CI on Linux is the authoritative gate.
  • I did not verify hash-bound receipts against real private evidence. Only the synthetic examples and tests ran.

@lexmount-ocr lexmount-ocr 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.

✅ Review complete · 289eeed

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 1

Reviewed head 289eeed4. CI is green on this head (Tests and static checks, Installation and packaging, Rendered reference and report checks). The redaction and data-home work holds up. The .env consolidation is incomplete: two more parsers remain and the PR says otherwise.

Findings

P1: src/harness/web_fetch/wcxb_report_check.py:586-590: a hand-written .env parser remains, with the defect #91 names.
binary_from_env does line.split('=', 1)[1].strip().strip('"').strip("'"), the same mismatched-quote repair the issue cites in catalog_runner.py. The PR body says all parsers now use parse_env_file. Run against this head, it disagrees with the shared parser on every row of the PR's table that applies:

.env content binary_from_env parse_env_file
CHROMIUM_BINARY="/opt/chrome' /opt/chrome dropped
CHROMIUM_BINARY=/opt/chrome # local /opt/chrome # local /opt/chrome
CHROMIUM_BINARY=/a then CHROMIUM_BINARY=/b /a /b
export CHROMIUM_BINARY=/a raises "missing" /a

The WCXB visual check can therefore use a different browser binary from the rest of the harness reading the same file.
Fix: use parse_env_file(path).get('CHROMIUM_BINARY') and keep the existing ValueError when it is absent. Add a case to test_every_loader_reads_the_same_values.

P2: src/harness/web_fetch/accounts.py:63-83: the credential importer keeps its own parser, and this PR makes it diverge from runtime.
assignments() (first wins) and usable() (hand-written quote handling) decide whether a key is already configured. Neither is migrated, and neither is listed under "Remaining". On this head:

Target .env Importer usable Runtime value
CLOUDFLARE_API_TOKEN="abc' True missing
CLOUDFLARE_API_TOKEN=abc then CLOUDFLARE_API_TOKEN= True empty

In both cases import_credentials skips the key and scripts/import_benchmark_env.py prints "Hosted benchmark credentials complete", while the runtime has no usable credential. The first row is new with this PR: before it, Web Fetch delivered the value with its quotes.
Fix: decide usable from parse_env_file, and keep raw line text only where the importer copies bytes. This changes parsing, not which credentials are read. If it is deferred to the #95 work instead, list it under "Remaining" and say why.

P2: tests/test_env_file.py:125: the guard misses both parsers above, so the stated enforcement does not hold.
The pattern only matches from dotenv, import dotenv and "=" not in line. It passes with line.split('=', 1) in wcxb_report_check.py and with the ASSIGNMENT regex in accounts.py. #91's acceptance requires that no private re-implementation remains, enforced by a grep test or banned-api.
Fix: after migrating, extend the guard to catch .split('=', 1) or startswith('NAME=') applied to lines read from an env file, with negative controls using those two forms. Exempt the argument parsers that use partition("=") on name=path values.

P3: PR body, .env section: "a corrupted value is never delivered" is too strong.
A="x\nB="\nC=1 parses to {'A': 'x\nB=', 'C': '1'}. When the next quote ends its line, the unterminated value absorbs the following line and is delivered. tests/test_env_file.py:55 pins only the NEXT_KEY="value" form, which does fail closed.
Fix: narrow the sentence and pin this form as well, or reject values containing a newline if multi-line values are not wanted.

P3: src/harness/lexbench/verification.py:1031, src/harness/trajectory_replay/public_webarena/release.py:60: disclosed default changes have no test.
The PR lists --site and --formal-root following BROWSER_EVAL_DATA_HOME as behavior changes to review, and this item asks for each difference to be pinned. tests/test_data_home.py covers data_home() and the Lexbench report, not these two defaults. The grep guard would catch a return to Path.home() / ".browser-eval", but not a default that ignores the home some other way.
Fix: add a small parser-default test where the parser can be reached without side effects. Otherwise, say in the PR that these two are covered only by the grep guard.

Verified without findings

  • Redaction bytes: I ran my own differential against the pre-PR regexes, rewritten from the base diff. It used 40,000 generated strings across all eight text policies, the two byte policies (including subn counts) and TRAJECTORY_REPLAY.found, and found 0 mismatches. Inputs included backslash and \g<0> tokens. The replacements arithmetic in project_file is equivalent to the old len() form.
  • Redaction inventory: no path rule remains outside reporting/privacy.py, apart from the plain substring guards the PR discloses (webarena_report.py:2620, web_search/report.py:1795). No references to the removed names remain.
  • Data home: no BROWSER_EVAL_DATA_HOME read remains in src/harness or Python scripts outside data_home.py. lexbench_webfetch/inputs.py (its own default) and benchmarks/data.py (.browser-eval/datasets) are left alone, as the PR discloses. lexbench/report.py no longer has import-time ROOT, and its test would fail with the old code. No caller imports data_home through storage. .resolve() on the default did not break any containment check I traced: web_search/publication.py already resolved, and risk_control.py resolves both sides.
  • Hash bindings: no file under evaluation/ or research/ names a changed source file. configs/report-templates.json names webarena_report.py as a renderer path only. The implementation_sha256, orchestrator and remote-execution bindings I found cover unchanged files. The Web Search resume rejection is disclosed and applies only to unfinished cohorts: execution_revision repairs skip the implementation comparison, and a cohort with a receipt cannot resume.
  • .env.example: it uses none of the affected syntax and has no duplicate names, as claimed.
  • Scope claim: "Part of #91" is correct, since the hash and JSON helpers remain.

Tests run

  • Both ruff gates: pass.
  • tests/test_data_home.py, test_env_file.py, test_local_path_privacy.py, test_golden_reports.py, test_storage.py: 72 passed, snapshots unchanged.
  • tests/test_config.py, test_accounts.py, web_search/test_runner.py, trajectory_replay/test_webarena_report.py, test_dynamic_100_moli_119.py: 109 passed, 3 skipped, 1 failed. The failure, test_migrated_roots_and_worker_paths, came from running under the /tmp symlink. tests/test_config.py passes in full (11 tests) from /private/tmp.
  • I did not run the full suite locally; CI is the full-suite gate. I did not verify receipts against real private evidence.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1: all five findings fixed, none disputed. No hash-bound or frozen file was changed, and tests/test_golden_reports.py passes with snapshots unchanged.

  • P1, wcxb_report_check.binary_from_env (5a361c7): now reads through parse_env_file and keeps the ValueError. An empty value also counts as missing instead of passing an empty path on. The tests compare it with the shared parser on duplicate names, inline comments, export and mismatched quotes.
  • P2, accounts.py (65b783c): assignments() and the raw-text usable() are gone, and usability comes from parse_env_file. The winning statement is copied verbatim through the new read_env_statements. A whitespace-only value now counts as empty. I also found that an unterminated quote already in the target could absorb an appended KEY="value", so the import checks the staged file and refuses without touching the target.
  • P2, grep guard (e362beb): now covers env-line split/partition, "=" in line, startswith('NAME=') and (?:export\s regexes, each with a negative control. Four name=path argument-parser forms are pinned as exempt. It matches both parsers it missed at 289eeed.
  • P3, value absorbing the next line (e99756f): took the rejection option. parse_env_file now drops any value spanning physical lines and warns with the line number only, so A="x\nB="\nC=1 gives {C: 1}. An escaped \n in double quotes still gives a newline. An intended multi-line value is dropped too, because it cannot be told apart from an unterminated quote. No .env.example name needs one, and the PR body now discloses this.
  • P3, entry point defaults (2e6b2e0): --site and --formal-root are pinned to BROWSER_EVAL_DATA_HOME by a test that stops at parse_args, so it has no side effects.

The PR body's parser list, syntax table, unterminated-quote paragraph and test plan are updated. This round ran targeted tests locally, not the full suite. CI on the new head is the full-suite gate.

@lexmount-ocr lexmount-ocr 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.

⚠️ Re-review complete · 2e6b2e0

This review found 1 issue(s), including 1 blocking issue(s).

Comment thread src/harness/env_file.py Resolved

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 2

Reviewed head 2e6b2e03. Two findings below: one P2 and one P3. All five round 1 fixes hold.

Findings

P2, src/harness/env_file.py:25 (also :21 and the docstring at :32): a rejected assignment leaves an earlier value of the same name active.

The docstring says the last assignment wins and that mismatched quotes and multi-line values "yield no value, so the caller reports the name as missing". The PR body repeats this. With an earlier assignment of the same name, the old value is delivered instead. I ran both forms on this head:

Target .env parse_env_file import_credentials on that target
KEY=old then KEY="new / value" KEY=old imports nothing
KEY=old then KEY="new' KEY=old imports nothing

So a rotated credential with a quoting typo runs on the stale credential with only a line-number warning, and the import command reports it as present. Before this PR, Web Fetch credentials used the last line's raw value and catalog_runner repaired it, so neither loader fell back to the older value. The fallback is new for those loaders and missing from the PR's behaviour table. No test covers a duplicate name combined with a rejected statement. lexmount-ocr flagged the multi-line form on this head as well, and its check is failing for that reason. I reproduced it independently and also found the mismatched-quote form.

Fix:

  • Multi-line branch: call bindings.pop(binding.key, None) before continue.
  • binding.error branch: the key is None, so recover the leading name from binding.original.string and remove that binding too. If you would rather not do that, narrow the docstring and PR body and disclose the fallback.
  • Add duplicate-name regressions for both forms, in parse_env_file and import_credentials.
  • Also narrow "both names then count as missing". B=1 followed by A="x, B=" keeps B=1, because only A is rejected.
  • Pin or disclose the related case: a bare A line after A=1 now removes A, where the hand-written parsers ignored that line.

P3, tests/test_data_home.py:98: the data-home grep guard misses two common forms.

os.getenv("BROWSER_EVAL_DATA_HOME") and Path("~/.browser-eval") both pass forbidden (I ran the regex on both). #91 requires enforcement of "no private re-implementations", and these are the likeliest ways to write a new copy. No such copy exists today.

Fix: match BROWSER_EVAL_DATA_HOME in getenv as well as environ, add ~/\.browser-eval, and add both as negative controls.

Verified without findings

  • Redaction: I compared every moved pattern and replacement with the 2740130 source, including the BROWSER_USE_CHECK_SOURCE fragment, the bytes rules in publication_privacy, and the found URL-span logic. All are byte-equivalent. subn counts equal the old len(finditer), so receipt replacements do not change. I read this rather than re-running the differential. No path-redaction regex remains outside reporting/privacy.py.
  • .env parsers: no hand-written parser remains under src/harness or scripts. The remaining partition("=") and split("=") uses are all argument parsers. Old and new parsers read .env.example identically (69 names, 0 differences), which supports the PR's claim about it.
  • Secrets: warnings carry line numbers only. The import refusal leaves the target unchanged and removes its temporary file.
  • Data home: there are no import-time evaluations and no storage.data_home alias or caller. The two exemptions (benchmarks/data.py, lexbench_webfetch/inputs.py) are sound.
  • Scope: "Part of #91" is accurate, and the hash and JSON helpers are correctly listed as remaining.
  • Frozen files and goldens: the PR changes nothing under evaluation/ and no golden snapshot.

Test runs and CI

  • Lint: both ruff gates pass.
  • Local tests: the env-file, data-home, config, accounts, privacy, storage and golden suites, plus the public_webarena config, entry-point, CLI-scope, web_search runner and resume, and webarena_report tests, gave 263 passed and 1 failed.
  • The one failure: test_config.py::test_migrated_roots_and_worker_paths is caused by my worktree path, /tmp versus /private/tmp. All of tests/test_config.py passes from the resolved path.
  • Not run: the full local suite, and real private evidence or receipts.
  • CI on this head: Tests and static checks, Installation and packaging, and Rendered reference and report checks all pass. ocr-review fails because of the P2 above.

lanyue-llk added a commit that referenced this pull request Nov 2, 2026
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2

Fixed

  • P2, rejected statement reviving an earlier value: 0b244df3. _read_bindings now removes the earlier value for a multi-line value and for a rejected assignment, recovering the name from the statement's source text with python-dotenv's key grammar (export prefix and quoted keys included). parse_env_file and import_credentials have duplicate-name regressions for both forms. With the parser change reverted, 11 of the new cases fail.
    • The docstring and PR body no longer say both names count as missing. B=1 then A="x / B=" keeps B=1, and a test pins it.
    • Bare A after A=1 keeps removing A. That is now pinned and disclosed in the behaviour table, along with the two fallback rows.
    • Lines that do not assign the name (A B=2, A trailing, A.dotted="x', a comment) keep A, also pinned.
  • P3, data-home grep guard: b70565fb. It now matches getenv and ~/.browser-eval, with both as negative controls. No src/harness or scripts Python file matches the wider pattern, so no new copy was hiding.

Disputed

None.

Lint passes, and the focused tests give 183 passed with golden snapshots unchanged. The full suite is left to CI, and I did not verify against real private evidence. An operator .env with one of these forms now reports the name as missing instead of using the old value. No evidence, frozen profile or receipt changes.

@lexmount-ocr lexmount-ocr 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.

✅ Re-review complete · b70565f

No findings in this incremental review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 3

Head reviewed: b70565fb. One P3 finding. No correctness, scope or evidence defect found.

Findings

P3, tests/test_local_path_privacy.py:91: the redaction grep guard only recognises rules that name /Users in two forms.

forbidden = re.compile(r"Users\||/Users/\[|/Users/\|") passes all of these when run directly:

  • re.sub(r"/home/[^/]+", "x", v)
  • re.compile(r"/(?:home|Users)/[^\s]+")
  • re.compile(r"/tmp/[^\s]+")
  • re.compile(rb"/(?:root|home)/")

Each is a likely form for a new private rule, and #91's acceptance requires the guard to catch one. This is the same gap round 2 closed in the data-home guard. No such rule exists today.

Suggested fix: extend the pattern to also match /home/\[, /tmp/\[, /root/\[, and alternations such as home\|, \|home\b, root\| and \|root\b. Add these forms as negative controls. A grep with these forms over src/harness and scripts, excluding reporting/privacy.py, finds nothing, so the wider guard passes on the current tree.

What I verified

CI on this head: Tests and static checks, Installation and packaging, Rendered reference and report checks, Python 3.11 and ocr-review all pass.

Local runs:

  • Both ruff gates pass.
  • tests/test_env_file.py, test_data_home.py, test_local_path_privacy.py, test_accounts.py, test_storage.py and test_golden_reports.py pass, with snapshots unchanged.
  • tests/test_config.py had one failure from a worktree path under the /tmp symlink. All 11 tests pass from /private/tmp, so this is not caused by the PR.

Redaction:

  • I ran a 100,000-string differential against the regexes copied from the 2740130 diff. It covered every substitution policy, the replay found check and both byte views with their counts. There were 0 mismatches.
  • ANOMALY_REVIEW_LOCAL_PATH, FIX_LOG_LOCAL_ROOT and the two release-check fragments were compared with the old text by reading the diff, not by the differential.
  • No removed name is still referenced.

.env parsing, round 2 fix: a rejected or multi-line statement removes the earlier value, and an absorbed name keeps its value. Both match the behaviour table. These are the probes I ran:

  • CRLF, because read_text normalises newlines
  • export with tabs
  • quoted keys
  • trailing junk
  • 
 and \x85 inside values, which do not count as line breaks

read_env_statements: 200,000 generated files gave 0 cases where a copied statement re-parsed to a different value.

import_credentials: I ran a matrix of broken targets and sources. Imported keys always read back as the source value, and other names were never changed. Every refusal left the target byte-identical.

.env.example: the old Web Fetch parser (reimplemented for the check) and parse_env_file give identical results, which supports the PR's claim for that file.

Data home:

  • No module-level or default-argument call remains.
  • lexbench/report.py reads the home at call time.
  • benchmarks/data.py and lexbench_webfetch/inputs.py are exempt as the PR says.

Frozen bindings: nothing under evaluation/ names an edited source file. collection_implementation is only compared on resume, and the PR discloses that.

Scope: "Part of #91" is correct, and hashing and JSON are listed as remaining.

Observations, no change requested

  • harness.web_fetch.native_routes now imports dotenv through config.py, and crawl4ai_worker imports native_routes. At 2740130 it imported without dotenv, so this is a new requirement for a worker run under an OSS_PYTHON override. The repository's own frozen environment has dotenv. I expect a crawl4ai environment to have it too, but I confirmed that only from memory of crawl4ai's dependencies, not from an installed copy.
  • A= # note delivers # note as the value. All the old parsers did the same, so this is not a regression.

Not verified

  • Hash-bound receipts against real private evidence.
  • The full local test suite. I relied on CI for that.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 3: one finding fixed, none disputed.

Fixed in f96b8ea (tests/test_local_path_privacy.py, P3): the redaction grep guard only recognised rules naming /Users. It now recognises two shapes for each of Users, home, root, tmp, private, var and opt: the root directly followed by a regex construct ([, |, a backslash class, .*, .+ or (), and the root inside an alternation in either position.

This goes slightly past the finding's list:

  • private, var and opt are included because reporting/privacy.py has rules for them too.
  • Backslash classes and .*/.+ are included so that /home/\w+ and /home/.+ cannot slip through.
  • The owner exemption now matches the exact path src/harness/reporting/privacy.py instead of any file named privacy.py.

Each form is a parametrized negative control. Separate controls pin text the guard must ignore: "/Users/" in html, Path("/tmp/plain"), chrome|firefox, users|accounts, and the private[-_]?token| alternation in web_fetch/runner.py and publication_privacy.py.

Results:

  • The wider guard passes on the current tree, so no production code changed.
  • With a /tmp/[^\s]+ rule temporarily planted under src/harness/, the guard test failed, as it should.
  • Ruff is clean. tests/test_local_path_privacy.py and tests/test_golden_reports.py passed locally (51 tests), with no golden changes.

@lexmount-ocr lexmount-ocr 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.

ℹ️ Review skipped · f96b8ea

No reviewable content was selected for this run.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 4

Head reviewed: f96b8eae. No defects found. CI is green on this head: Tests and static checks, Installation and packaging, Rendered reference and report checks, and OCR dispatch all pass.

What I verified

Round 3 fix. With a file planted under src/harness, the redaction guard fails on /tmp/[^\s]+. The .env guard fails on an "=" in line parser and the data-home guard fails on Path("~/.browser-eval").

.env parsing

  • I read the whole diff of every loader and probed parse_env_file with 28 edge inputs: CRLF, lone CR, BOM, duplicates, rejected and bare statements, quoted keys, comments, and form feed and Unicode line separators. All results match the docstring and the PR behaviour table.
  • With both removal branches in _read_bindings disabled, 11 tests in tests/test_env_file.py fail, as the PR says.
  • The old Web Fetch parser and parse_env_file return identical values for all 69 names in .env.example.
  • import_credentials leaves the target unchanged on refusal and removes its temporary file. An addition absorbed by a broken quote in the target is rejected.
  • relevance.judge_main cannot reach the new FileNotFoundError for a missing .env, because the token check fails first.
  • Every remaining split("=") or partition("=") in src/harness and scripts parses a command-line argument or a URL query, not a .env file.

Redaction

  • Differential against the regexes copied from 27401304: 40,000 generated strings across every substitution policy, the Trajectory Replay found check, and the two Web Fetch byte views with their counts. 0 mismatches. This closes the receipt-count gap the PR body says its own differential left open.
  • The only local-path mentions left outside reporting/privacy.py are two plain substring checks and two container PATH values.

Data home

  • No module-level data_home() call remains, and lexbench/report.py has no ROOT.
  • The default of --site and --formal-root is computed inside main.
  • harness.web_fetch.storage uses data_home but no module imports it from there.

Isolation and binding

  • Workers do not import the modules that now depend on python-dotenv, which is a locked main dependency.
  • The PR changes only .py files. It touches nothing under evaluation/, no golden snapshot and no workflow.
  • Nothing in evaluation/ or configs/ names a changed source file. collection_implementation is checked only on resume, which matches the PR's disclosure.

Scope. "Part of #91" is correct: the hashing and JSON helpers remain, and the PR lists them.

Local runs

  • Both ruff gates pass.
  • test_env_file, test_data_home, test_local_path_privacy, test_golden_reports, test_accounts, test_config, test_storage, web_search/test_runner, test_runtime_entrypoints, test_cli_scope and public_webarena/test_config gave 237 passed and 1 failed, with no snapshot changes.
  • The failure is test_config.py::test_migrated_roots_and_worker_paths. It came from running under the /tmp symlink, and tests/test_config.py passes in full (11 passed) from /private/tmp.

Not verified. I did not run the full suite locally, so CI is the full-suite gate. I did not check hash-bound receipts against real private evidence.

Noted, not raised as findings

Neither of these is worth another round:

  • The multi-line warning reports where python-dotenv's statement starts, which includes preceding blank lines. A=1, a blank line, then B="x reports line 2 rather than 3. The next non-blank line is still the right one, and upstream's own warning behaves the same way.
  • The PR test plan's "on the current head" lines predate f96b8eae. That commit changes only a test file, and the round 3 comment records its results.

lanyue-llk added a commit that referenced this pull request Nov 2, 2026
@lanyue-llk
lanyue-llk force-pushed the refactor/shared-env-datahome-redaction branch from f96b8ea to 7738fc2 Compare November 3, 2026 05:32

@lexmount-ocr lexmount-ocr 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.

✅ Review complete · 7738fc2

No findings in this review.

@lanyue-llk
lanyue-llk merged commit ebdf047 into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/shared-env-datahome-redaction branch November 3, 2026 05:59
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.

Consolidate copy-pasted hashing, JSON I/O, data-home, dotenv and redaction helpers

1 participant