Skip to content

feat(flow): keep only declared fields of captured bodies on disk - #2480

Open
abrichr wants to merge 12 commits into
mainfrom
claude/nodb-capture-privacy
Open

abrichr wants to merge 12 commits into
mainfrom
claude/nodb-capture-privacy

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

Network captures used to write raw request and response bodies to disk. Only credentials were redacted. This change keeps the declared fields of each body and replaces every other value with a hash. The hashing runs in memory on the device, before anything is written.

What changes

  • New openadapt_flow/capture_privacy.py (stdlib only):
    • JSON, url-encoded and plain multipart bodies keep the values of declared fields. Every other value becomes hmac-sha256:<hex>.
    • The hash key is made for one capture and is never written, so hashes of short values can't be reversed offline. Equal values hash equally within one capture. Hashes from different captures can't be compared.
    • HTML, text, binary, truncated and file-carrying bodies keep only their length, content type and hash.
    • URL query values that aren't declared are hashed too.
  • network.jsonl (record --capture-network):
    • Bodies are minimized by default. The declared fields are the recording's --param and --identifier fields.
    • The header gains "bodies": "minimized" | "raw", which network_capture.bodies_mode() reads.
    • --capture-network-bodies raw (or NetworkCapture(bodies="raw")) keeps the redacted bodies. It is refused up front, and again at write time, unless the recording is encrypted or OPENADAPT_FLOW_PLAINTEXT_AT_REST allows plaintext.
  • Wire-tap HAR (dump_har, save_har):
    • Bodies are minimized by default. The kept fields are the policy's id_fields and version_fields.
    • load_har, from_har and har_to_summary rebuild a JSON body from the kept fields only, so entity ids and versions still replay. A POST with a withheld body is still classified as a mutation, so nothing becomes a read.
    • raw_bodies=True is the debugging opt-in. Files are always sealed through write_private_record.
    • TODO(Encrypt recordings, bundles and runs at rest by default (key hierarchy) #2423): move raw captures onto the key hierarchy's data key.
  • parse_multipart moved into capture_privacy. network_capture re-exports it.
  • The wire-tap import-boundary test allows openadapt_flow.capture_privacy and asserts that the module imports only the stdlib.

Capability change

Readers find no body in a minimized capture, so they propose nothing from one: no API step, no undo proposal, no record check from the app's reads. Users who want API step proposals must record with --capture-network-bodies raw. Raw recordings are encrypted by default for web. The docs, CAPABILITIES.md, the CHANGELOG and llms-full.txt are updated.

  • Benchmarks: the four that build NetworkCapture and compile from it now pass bodies="raw", so they fail loudly rather than silently lose proposals.
  • agent_guard: its run-1 recorder (agent_guard/session.py) is not encrypted and passes no param fields. It now writes minimized captures, so run 2 loses its network-derived effects. The fix is to encrypt that recording and opt into raw; that is left to whoever owns the guard.

Not covered

  • URL path segments such as /patients/1234.
  • JSON keys that look like field names. Keys that don't look like field names are hashed.
  • Header values beyond the existing credential redaction.
  • benchmark/openemr_api_tier/spike/capture_har.py, which writes a raw embedded HAR through Playwright. It is a lab spike and is untouched.

Tests

tests/test_capture_privacy.py puts synthetic PHI only in bodies and URL queries. It scans every file under the test directory after decryption, in raw, percent-encoded, JSON-escaped, base64 and gzip forms. Positive controls show that the PHI is present when raw is opted in, and absent from the raw bytes when sealed.

network.jsonl and saved wire-tap HARs now keep declared field values and a
per-capture keyed hash of everything else. Raw bodies are an explicit opt-in
that is refused unless sealed at rest.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: b44d8ad

Codex run on b44d8ad (codex exec --sandbox read-only, diff against merge base 576f87b on stdin, blockers only). It reported 15 blockers. Its findings follow verbatim, with local worktree links shortened to repository paths.

Privacy and mutation classification

  1. HAR replay can turn a mutation into a read. I verified two round trips where har_to_summary changed one mutation into one read. A GraphQL POST batch with query declared lost its second operation, a mutation. A GET mutation at /api?query=… became a read after its query was hashed. Replay reclassifies both from incomplete evidence. Preserve a recorded mutation as a lower bound and classify conservatively whenever the body or query needed to establish a read was withheld. wire_tap.py:1147

  2. One HAR marker disables minimization for every entry. Appending a raw entry to a loaded minimized HAR and calling default dump_har preserves that entry’s raw body and query. The writer trusts any mapping at log._openadapt_minimized. The reader also leaves raw text intact on entries without a body descriptor. Enforce the effective field policy per entry and reject inconsistent marked documents. wire_tap.py:1912 · wire_tap.py:2002

  3. HAR metadata retains values the export explicitly withholds. With dump_har(tap, keep_fields=()), I verified that the response’s kept list was empty while _tx.extracted_entity_id and _tx.version still contained the original body values. A HAR dictionary can also retain the original query in log.pages[].title when the title is the navigation URL. Derive body-sourced metadata from the effective kept fields and drop or minimize duplicate URL-bearing metadata. capture_privacy.py:260 · capture_privacy.py:303

  4. Truncated forms and opaque content can retain plaintext fields. An oversized URL-encoded POST with a declared field at the start writes that value to form_minimized.kept even with request_truncated: true. Separately, a text/plain, text/html, or application/octet-stream body containing {"id":"sample"} retains sample when id is declared. Apply truncation and opaque MIME rules before parsing or retaining fields, including body-derived _tx fields. capture_privacy.py:347 · capture_privacy.py:184

  5. Case folding can expose a declared secret. With --secret code --param CODE, the case-sensitive subtraction leaves CODE in the keep set. The minimizer then lowercases it. I verified that ?code=xy survives verbatim because the earlier redactor skips short values during global replacement. Match kept fields using the declaration’s actual field name and give secret-name matching precedence on every query value, regardless of length. network_capture.py:125 · capture_privacy.py:93

  6. Query values survive in other URL representations. A frame URL ending in #/search?q=sample is written unchanged to network.jsonl. An unkeyed search such as ?SyntheticSearch becomes ?SyntheticSearch=, preserving the search term. The recording also writes the original --url to meta.json.app_url, so a starting URL with an ordinary ?q=sample leaves a plaintext copy even when network.jsonl hashes it. Strip or minimize fragment queries, hash unkeyed search terms, and apply the same policy to the persisted starting URL. capture_privacy.py:199 · recorder.py:528

  7. The raw network write can fall back to plaintext after its encryption check. A write to a finalized sealed recording checks the destination, serializes the capture, then resolves the destination again. If the recording directory is replaced by an unsealed directory between those operations, write_bytes takes its ordinary plaintext branch without checking the allowance. Use a sealed-only write operation that refuses if the sealed destination disappears. network_capture.py:356 · sealed_set.py:1122

  8. A pathless raw HAR export skips the required gate. dump_har(tap, raw_bodies=True) returns serialized raw bodies with no encrypted destination and no plaintext allowance. Require the explicit allowance for a pathless raw export, or require a destination for that mode and use the sealed writer. wire_tap.py:1925

Capture and replay correctness

  1. JSON reconstruction can invent an entity ID or lose a version. I verified that {"data":{"id":["one","two"]}} has no scalar entity ID live, but replay reports one. The reader drops array indices and keeps the first colliding value. Separately, the default wire policy extracts data.record.meta.versionId live, but the minimizer withholds it and replay loses the version. Preserve object and array structure and use the wire extractor’s field-resolution rules when selecting kept leaves. capture_privacy.py:226 · capture_privacy.py:93

  2. The recorder loses or misreports opaque-body evidence. A two-byte binary request containing ff fe reports six bytes and hashes the UTF-8 replacement characters. A binary fetch response gets no descriptor, and an attached multipart file gets only body_omitted. URL-encoded responses also bypass capture entirely. Compute size and HMAC from the original bytes before decoding or dropping them, and pass supported structured response types through the minimizer. network_capture.py:251 · network_capture.py:305

  3. A params-only HAR form loses every field. For a HAR request represented by postData.params without text, default dump_har writes params: [] and a null descriptor. Both declared values and withheld hashes disappear. Minimize the parameter pairs before clearing them and handle file parts as opaque. capture_privacy.py:282

  4. An escaped surrogate aborts the capture. An undeclared JSON string containing the escape \ud800 parses successfully, then tag() raises UnicodeEncodeError while hashing it. One response can therefore prevent the entire capture from being written. Use a deterministic JSON encoding that represents isolated surrogates as escapes, or fall back to hashing the opaque body. capture_privacy.py:83

Tests and published claims

  1. The privacy scan can pass without inspecting the plaintext it claims to check. _plain swallows decryption failures and returns ciphertext. It only gunzips a whole file, so a gzip body embedded in HAR base64 escapes inspection. All four canaries also have identical raw and JSON-escaped spellings. Fail the test on decryption errors, decode body containers, and add a distinct positive control for each claimed encoding. The separate “key is never written” test should also search actual serialized output for a known injected test key. test_capture_privacy.py:36 · test_capture_privacy.py:58 · test_capture_privacy.py:333

  2. The published raw-recording instructions fail under the actual defaults. DEFAULT_SEALS_ARTIFACTS is False, so the API-tier example refuses raw capture in an unconfigured environment even with --no-encrypt absent. Conversely, CAPABILITIES and the changelog say encryption is mandatory although the explicit plaintext allowance permits raw network.jsonl. Show strict mode or a configured recording key in the example and refusal message, and document the allowance consistently. NETWORK_CAPTURE.md:85 · API_TIER.md:38 · at_rest.py:350 · CAPABILITIES.md:260 · CHANGELOG.md:29

  3. Four benchmark recording commands now fail after driving their fixtures. They request raw bodies and write to ordinary directories. Without the plaintext allowance, capture finalization raises AtRestRefused. Use a sealed recording or make the synthetic-data allowance explicit in the benchmark commands and check it before driving the fixture. api_generalization/harness.py:146 · feature_e2e.py:82 · undo_proposal/run.py:117 · zero_config_verify/run.py:95

VERDICT: REQUEST CHANGES

…review

- Replay keeps a minimized HAR entry's recorded write as a floor, and
  treats a withheld write body or hashed GraphQL query as a write.
- dump_har minimizes every entry, re-checks earlier kept values against
  the current fields, and hashes wire-tap ids and versions that were not
  kept; page titles are minimized like URLs.
- Truncated forms are opaque; JSON is parsed only from JSON-labelled or
  unlabelled bodies; params-only HAR forms are minimized.
- Declared secrets are withheld whatever their case; fragment queries and
  bare search terms are hashed; lone surrogates hash instead of failing.
- Kept JSON is restored with its list structure and dotted-suffix fields
  (meta.versionId); colliding paths restore nothing.
- Raw network.jsonl writes check and write in one sealed lookup; raw
  dump_har needs a path; benchmarks check raw readiness before driving.
- The privacy scanner fails on undecryptable files, decodes HAR bodies,
  and has a distinct positive control per encoding.
@abrichr

abrichr commented Nov 22, 2026 •

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES (void: wrong prompt)

From: Gemini
Reviewed-Head: facb4ec

Void. This Gemini run on facb4ec received the review prompt for a different PR (#2476, the verdict kernel) together with this PR's diff. A shared scratch file had been overwritten before the run, so this is not a valid review of #2480. That explains its first "blocker" (files from #2476 missing). Its second point was real: dump_har(raw_bodies=True) returned the raw payload in memory. Commit eb95a37 fixes it, and the valid re-review is in the next comment.

A correction to the earlier wording: facb4ec did not resolve all 15 blockers from the first Codex review. What is still open is listed in the next comment.

… no raw HAR text

- A body minimized before and reloaded (its kept fields restored as text)
  keeps its description instead of being minimized again from the kept
  fields alone.
- dump_har(raw_bodies=True) writes the sealed file and returns an empty
  string, so raw bodies are never handed back in memory.
- The replay test also covers default fields, where the recorded write
  floor is what keeps the counts.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: eb95a37

Gemini run on eb95a37 (gemini-3.1-pro-preview). Codex is at its usage limit until Nov 27. Gemini got this PR's blockers-only prompt and the full diff against the merge base 576f87b. It had no repository access.

Gemini found no blockers. It says unparseable bodies and edge cases fail closed to opaque or hashed. It also says undeclared fields and URL query values are hashed, withheld bodies don't make writes replay as reads, and raw bodies are gated by sealed_set and write_private_record.

The review is short and saw the diff only, so it is weaker than the first Codex run. It raised none of the open items below, but it also did not show that any of them is resolved.

Fixed since the first Codex review (facb4ec, eb95a37):

  • Replay classification: a minimized HAR entry's recorded write is kept as a floor on replay.
  • HAR minimization: every entry is minimized and re-checked, and ids and versions that weren't kept are hashed in _tx. Page titles are minimized, and so are params-only forms.
  • Forms and JSON parsing: a truncated form is opaque, and text or HTML that looks like JSON is opaque.
  • Secrets and query values: a secret declared in a different case is withheld. Queries in the fragment and bare search terms are hashed.
  • Robustness and restore: a lone surrogate is hashed instead of failing, and JSON is restored with its list structure and meta.versionId.
  • Raw writes: raw network.jsonl writes use a single lookup that only writes sealed. Raw dump_har needs a path and returns nothing.
  • Benchmarks: they check raw readiness before driving the fixture.
  • Scanner test: it fails on files it can't decrypt, decodes HAR bodies and has a positive control for each encoding.
  • Docs: they match how raw capture is gated.
  • Reload: a reloaded minimized HAR keeps its descriptions.

Still open from the first Codex review:

  • Ag23 #10: binary request size and hash are computed after UTF-8 decoding. Binary and url-encoded responses get no descriptor. This affects descriptor accuracy; nothing reaches disk in plaintext.
  • Pull request_alvolate #6, partly: meta.json app_url keeps the starting URL's query. That is the recorder's navigation input, encrypted when the recording is.
  • Modify record.py to accept a command line description of the task that is being performed #4, partly: JSON in an application/octet-stream body is still parsed, because that is the wire tap's type when the header is missing. This is now documented.
  • alembic upgrade head #2, partly: load_har still accepts raw text on an entry, in a marked document, that has no descriptor. Every write path minimizes it again.

…rivacy

# Conflicts:
#	packages/flow/CHANGELOG.md
- Size and hash every body from its bytes as sent; binary bodies,
  multipart files and non-text responses get an opaque descriptor, and
  url-encoded responses are minimized (Codex #10).
- Minimize the query of meta.json app_url with the capture's key (#6).
- Parse JSON only when labelled JSON or with no content type; the wire
  tap records a missing header as "" (#4).
- load_har refuses a document marked minimized whose body carries raw
  text or params (#2).
- Minimize URL-valued HAR headers (Referer, Content-Location, Refresh).
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a6a8976

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: a6a8976

Gemini run on a6a8976 (gemini-3.1-pro-preview; Codex is at its usage limit until Nov 27). Gemini got the 15 Codex findings, the status note posted at eb95a37, the full diff against the merge base, and the complete post-change text of every changed source, benchmark and test file (including __main__.py, interactive_recorder.py and recorder.py): about 570k prompt tokens. It was asked to confirm each finding one by one and to look for any remaining plaintext path, including error and debug paths. Its answer follows verbatim. Where it says the status note claims something is only partly fixed, it means the note written at eb95a37, before this head.


Here is the review of PR #2480 against the 15 blockers reported by Codex, followed by a hunt for remaining plaintext leaks.

1. Codex Findings

1. HAR replay can turn a mutation into a read.
FIXED. mutation_floor (openadapt_flow/capture_privacy.py:497) now checks _tx.is_mutation first. If absent, it falls back to checking if the method is a write with a withheld/opaque body, or if it's a GraphQL query with hashed values. import_har (openadapt_flow/tx/wire_tap.py:1113) passes this floor to record_exchange via assume_mutation, which _begin_request (wire_tap.py:1324) uses to force is_mut = True. Covered by test_replay_keeps_writes_whose_evidence_was_withheld (tests/test_capture_privacy.py:440).

2. One HAR marker disables minimization for every entry.
FIXED. The status note claims this is only partly fixed, but the code proves otherwise. load_har (openadapt_flow/tx/wire_tap.py:2004) calls _restore_minimized_entry (wire_tap.py:2016) for every entry if the document is marked minimized. If an entry lacks a descriptor, kept becomes "". If that entry carries raw text or params, the check if (text not in (None, "", kept)) or container.get("params"): raises a ValueError and refuses the entire document. Covered by test_marked_har_with_a_raw_body_is_refused_on_load (tests/test_capture_privacy.py:833), which explicitly tests appending a raw entry to a minimized HAR.

3. HAR metadata retains values the export explicitly withholds.
FIXED. _minimize_har_entry (openadapt_flow/capture_privacy.py:396) collects all kept_values from the minimized bodies. For _TX_VALUES (extracted_entity_id, version), it checks if the value is in kept_values. If not, it hashes it using minimizer.tag(value). Covered by test_raw_entry_added_to_a_minimized_har_is_minimized (tests/test_capture_privacy.py:485).

4. Truncated forms and opaque content can retain plaintext fields.
FIXED. BodyMinimizer.body (openadapt_flow/capture_privacy.py:165) checks if truncated: and immediately returns {"format": "opaque", "truncated": True} before parsing. _parse (capture_privacy.py:216) checks json_type = ctype == "" or ctype.endswith(("/json", "+json")). An explicit application/octet-stream makes json_type False, so it is not parsed as JSON and stays opaque. _build_har_entry (openadapt_flow/tx/wire_tap.py:693) now defaults a missing content-type to "" instead of application/octet-stream, keeping the two distinct. Covered by test_explicit_octet_stream_json_is_opaque_and_unlabelled_json_parses (tests/test_capture_privacy.py:791) and test_truncated_forms_and_non_json_types_keep_nothing (tests/test_capture_privacy.py:498).

5. Case folding can expose a declared secret.
FIXED. BodyMinimizer.__init__ (openadapt_flow/capture_privacy.py:80) lowercases withhold into withheld. When building self._keep, it checks if str(f) and str(f).lower() not in withheld. This ensures that a declared secret (e.g., code) prevents any case variant (e.g., CODE) from entering the keep set, even if the caller's subtraction was case-sensitive. Covered by test_declared_secret_is_withheld_whatever_its_case (tests/test_capture_privacy.py:508).

6. Query values survive in other URL representations.
FIXED. The status note claims meta.json app_url keeps the query, but the code actually minimizes it. Recorder.finish (openadapt_flow/recorder.py:528) calls self._network_capture.minimize_url(self._app_url). NetworkCapture.minimize_url (openadapt_flow/network_capture.py:416) calls self._minimizer.url(url) unless bodies == RAW. BodyMinimizer.url (openadapt_flow/capture_privacy.py:247) correctly parses and hashes fragments (#/search?q=...), and BodyMinimizer.query (capture_privacy.py:266) hashes unkeyed search terms (?term). Covered by test_recording_meta_app_url_query_is_minimized (tests/test_capture_privacy.py:764) and test_fragment_queries_and_bare_terms_are_hashed (tests/test_capture_privacy.py:525).

7. The raw network write can fall back to plaintext after its encryption check.
FIXED. sealed_set.write_bytes (openadapt_flow/sealed_set.py:1119) now accepts sealed_only=True. If the path is not in a sealed set, it raises PermissionError in the exact same lookup as the write. NetworkCapture.write (openadapt_flow/network_capture.py:405) catches this and raises _raw_refusal(). Covered by test_raw_network_write_never_falls_back_to_plaintext (tests/test_capture_privacy.py:585).

8. A pathless raw HAR export skips the required gate.
FIXED. dump_har (openadapt_flow/tx/wire_tap.py:1928) explicitly checks if raw_bodies and path is None: and raises a ValueError. It also returns "" if raw_bodies else payload (wire_tap.py:1950), ensuring raw bodies never leak back in memory. Covered by test_raw_har_without_a_path_is_refused (tests/test_capture_privacy.py:580).

9. JSON reconstruction can invent an entity ID or lose a version.
FIXED. restore_kept_json (openadapt_flow/capture_privacy.py:304) uses _place (capture_privacy.py:324), which correctly handles list indices (seg.isdigit()) and dict keys, preserving the original structure. It returns b"" on any collision. Covered by test_restored_json_keeps_lists_and_dotted_versions (tests/test_capture_privacy.py:539).

10. The recorder loses or misreports opaque-body evidence.
FIXED. NetworkCapture._response_body (openadapt_flow/network_capture.py:265) and _request_body (network_capture.py:332) compute the size and HMAC from the ORIGINAL body or full bytes before any decoding or truncation. minimize_line (openadapt_flow/capture_privacy.py:568) pops _request_digest and _response_digest and merges them into the minimized descriptors, ensuring the metadata reflects the exact bytes sent over the wire. Covered by test_binary_and_file_bodies_are_measured_and_hashed_as_sent (tests/test_capture_privacy.py:645) and test_text_bodies_report_the_size_and_hash_sent_not_the_redacted_text (tests/test_capture_privacy.py:681).

11. A params-only HAR form loses every field.
FIXED. _minimize_har_body (openadapt_flow/capture_privacy.py:472) checks elif raw is None and isinstance(params, list) and params: and calls _minimize_params. _minimize_params (capture_privacy.py:482) treats the form as opaque if any param has fileName or contentType, otherwise it minimizes the pairs. Covered by test_params_only_har_form_is_minimized (tests/test_capture_privacy.py:548).

12. An escaped surrogate aborts the capture.
FIXED. BodyMinimizer.tag (openadapt_flow/capture_privacy.py:104) uses json.dumps(value, ensure_ascii=False).encode("utf-8", "surrogatepass"), which safely encodes isolated surrogates. Covered by test_lone_surrogate_is_hashed_not_fatal (tests/test_capture_privacy.py:575).

13. The privacy scan can pass without inspecting the plaintext it claims to check.
FIXED. test_capture_privacy.py _plain (tests/test_capture_privacy.py:50) no longer swallows decryption failures. _decoded (test_capture_privacy.py:64) recursively decodes JSON strings, base64, and gzip. test_scanner_finds_each_encoding checks 7 distinct encodings, and test_scanner_finds_gzip_inside_a_har_body_and_refuses_ciphertext ensures ciphertext fails the test.

14. The published raw-recording instructions fail under the actual defaults.
FIXED. API_TIER.md now shows OPENADAPT_FLOW_AT_REST=strict openadapt-flow record ... --capture-network-bodies raw. NETWORK_CAPTURE.md documents the encryption requirement. network_capture.py _raw_refusal explicitly mentions the keys or strict mode.

15. Four benchmark recording commands now fail after driving their fixtures.
FIXED. require_raw_ready(out) is called before driving the fixture in api_generalization/harness.py:129, feature_e2e.py:76, undo_proposal/run.py:110, and zero_config_verify/run.py:95.

2. Hunt for Remaining Plaintext Leaks

I audited the codebase for any remaining paths where synthetic PHI could reach disk in plaintext with default settings (bodies="minimized"):

  • network.jsonl: NetworkCapture.write calls cp.minimize_line which removes body, form, and response_text, replacing them with minimized descriptors. Failed requests (_on_failed) extract the body/form, but minimize_line still processes them.
  • meta.json: Recorder.finish calls minimize_url on app_url, which hashes undeclared query parameters.
  • Saved HARs: dump_har calls minimize_har which minimizes request.url, request.queryString, response.redirectURL, URL headers (Location, Referer, Content-Location, Refresh), and bodies.
  • Reloaded and re-saved HARs: load_har restores kept JSON fields but refuses any raw text. dump_har minimizes again. _minimize_har_body checks if it was minimized before and re-filters.
  • Error paths: test_no_phi_reaches_disk_on_error_and_debug_paths explicitly tests failed requests, refused raw writes, refused loads, and raw exports with DEBUG logging enabled. No PHI reaches disk.
  • Debug/log output: NetworkCapture does not log bodies. _TapProxyRequestHandler.log_message is a no-op.

The implementation is extremely robust. The use of sealed_only=True for raw writes, the strict HAR minimization checks, and the comprehensive test suite ensure that no PHI leaks to disk by default.

3. New Blockers

None found. The author has thoroughly addressed all previous findings and added excellent test coverage.

VERDICT: APPROVE

# Conflicts:
#	packages/flow/CHANGELOG.md
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 4bfdc86

Delta versus Gemini APPROVE at a6a8976e899a01f63223d632e4ff56dd16f3377e (request 7082912814). No prior Grok verdict at this head. The unique capture-privacy tree is byte-identical to that head. I compared it to current main and re-read the minimizer, the raw-body gates, and load_har. I did not merge, tag, publish, or dispatch.

The main-merge delta is documentation and CLI-surface alignment only: CAPABILITIES.md and llms-full.txt picked up later main rows, CHANGELOG.md kept this PR's Unreleased capture-privacy entry under main's effect-location notes, and __main__.py still routes record through cli_mode / add_cli_arguments after absorbing main's later __main__.py edits.

The unique tree stays fail-closed. Default --capture-network is minimized: only declared --param / --identifier fields are kept, withheld names are never kept, and everything else is a per-capture HMAC that is not written to disk. --capture-network-bodies raw is refused before anything is recorded unless the recording is encrypted or OPENADAPT_FLOW_PLAINTEXT_AT_REST explicitly allows plaintext. load_har refuses a HAR marked minimized that still carries a raw body or form params. Tests pin those cases, including no-PHI-on-disk, encrypted raw bodies, and a marked HAR with a raw body.

No package version or lock change (changelog is Unreleased only). This does not auto-publish. Launcher CI is red on the known #2421 / #2546 openadapt --help snapshot; this PR's unique __main__.py change only swaps in the network-capture flags. I did not merge.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: 3312611

I checked that the head matches. I read capture_privacy.py, the network_capture.py, wire_tap.py, recorder.py, interactive_recorder.py and sealed_set.py changes, and the readers of network.jsonl. I ran small probes with synthetic values against BodyMinimizer and minimize_har. I did not run the test suite because the load average was about 35, above the limit of 15.

Fail-open paths: none found

  • Parse failures: none keep raw bytes. Bad JSON, a UTF-8 BOM, a non-JSON type (including explicit octet-stream and text/plain holding JSON), non-UTF-8 bytes, compressed bytes, a cut body, and multipart with a file or a bad boundary all become opaque (length, type and keyed hash only). A request that fails to decode as text goes to opaque() before minimize_line runs.
  • Bodies and queries: nested JSON and arrays are walked to their leaves, and only scalar leaves can be kept. A form is checked one name at a time. A query hashes bare terms, undeclared values and a query inside the fragment. Keys that don't look like field names are hashed.
  • HAR: postData.params is cleared, the queryString is rebuilt from the minimized URL, URL-valued headers are minimized, and _tx ids and versions are hashed unless the body kept them. load_har refuses a document marked minimized whose body still carries text.
  • Raw mode: it is refused both at the CLI and at write time (sealed_only=True). dump_har(raw_bodies=True) returns "" and never hands the plaintext back.

Verification when the evidence was filtered out: fails closed

  • readiness/reference.py: a minimized POST, PUT or PATCH has neither body nor form. parse_body_fields then returns <body>, which raises ReferenceRefused("save_unreadable"). It does not compare zero fields and call that a match.
  • Undo proposals, record-check synthesis and API proposals find no body, form or response_text, so they propose nothing. No reader treats *_minimized.kept as the whole body.
  • Replaying a minimized HAR keeps a POST counted as a mutation through mutation_floor, so a withheld write does not turn into a read.

Engine code and protected paths

No app is named in engine code. App names appear only under benchmark/, tests and docs. None of the changed files is listed in .github/agent-safety-manifest.json, so this PR needs no separate cross-vendor review on those grounds.

Non-blocking findings

  • P2: a declared name matches every record in a response. _declared compares the leaf name or a dotted suffix at any depth. With --param lname --param dob, this search response keeps every patient's surname and birth date in the clear:

    {"results": [{"lname": "Smith", "dob": "1950-02-03"}, {"lname": "Jones", "dob": "1961-07-08"}]}

    The probe returned results.0.lname, results.0.dob, results.1.lname and results.1.dob as kept. The wire-tap default (id, uuid, pid) likewise keeps the id of every element in a list response. NETWORK_CAPTURE.md does say "wherever they appear", and web recordings are sealed by default, so I don't block on this. However, a minimized capture is allowed in plaintext (for example with --no-encrypt), and that file then holds the declared field for every other person in the response, not only the value the person typed. Two possible fixes:

    • Keep response values only when they equal a value sent in the request.
    • Keep response values only at an exact declared path.
  • P3: a forged descriptor survives minimize_har. If an input HAR already carries _openadapt_minimized, refilter() re-checks kept but copies withheld and any other keys unchanged. In a probe, [["a", "John Smith 1950-02-03"]] and an extra note key passed through as written. Only HARs that this module wrote, or that load_har accepted, normally reach this path. Re-tagging any withheld entry that isn't a TAG, and dropping unknown keys, would close it.

  • P3: fragments and matrix parameters stay as written. A fragment with no ? or = (#Smith%20John) is kept. A matrix parameter (/p;dob=1950-02-03) is also kept, which falls under the documented "path segments not covered".

# Conflicts:
#	packages/flow/CHANGELOG.md
#	packages/flow/openadapt_flow/tx/wire_tap.py
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 36f697e

VERDICT: APPROVE

Independent cross-vendor delta review of 36f697ea7cca0233dead4438f2531520ecb5285a (Claude-authored claude/nodb-capture-privacy; I authored none of this PR).

  • Pure origin/main merges only: All four commits since Grok's cross-vendor APPROVE at 4bfdc861 (#7083780680) and Gemini's APPROVE at a6a8976e (#7072092693) are Merge remote-tracking branch 'origin/main' into HEAD (3c34fec7, 3312611d, 6606a890, 36f697ea). No PR-unique production code or fail-closed privacy invariant changed.

This branch has not been deployed

No deployments
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