Plan: the commit review reads the operator’s declared data paths as counts, not bytes

Closes: #916. Relates to: #902 (the battery-store prune this unblocks), #878 (the whole-diff size bound), #558 (a repository may not weaken its own review). Branch: feat/review-data-paths. Status: Done (2026-11-23) — #902’s prune committed through it: 35,150 data files counted, not read, and the review CLEAN

Context

Since #878 the commit review reads a staged diff whole, up to MAX_DIFF_CHARS (1,500,000 characters, packages/pi-workflow/reflection-review.ts), and oversizeRefusal (packages/pi-workflow/commit-pause.ts) refuses a longer one with "Commit it in parts". That is right for code and wrong for measured data. #902’s prune of tools/model-battery/store deletes about 35,000 files, about 200 MB; the store’s last record commit (9b90b41ab, 8,815 files, 414,347 added lines) would be refused today. A reviewer sent 400,000 lines of recorded JSON reviews nothing a person would stop a merge for.

Operator’s rulings (2026-11-22): data paths are declared in the operator’s own gadhs-pi-workflow.json, per repository by origin URL, where an agent’s write, edit and shell redirect are refused by rule (packages/pi-modes/test/credentials.test.ts, "the policy overlays are refused for every write"); a commit with only data is still reviewed; each such commit says so to the human and in its trailer.

Measured while planning (git 2.56.1): git diff --raw --no-renames over 11,831 store files answers in 71 ms and reads no blob; a literal exclude and a glob exclude combine in one pathspec list (':/' ':(top,exclude)a' ':(top,exclude,glob)store/**'); with every path excluded --stat prints nothing. splitApprovedPlan asks git for each staged path’s bytes one call at a time: 200 calls took 1.6 s here, so the prune’s 31,525 evidence files alone would take about four minutes.

Design

The declaration

gadhs-pi-workflow.json gains one key, read by loadWorkflowConfig (packages/pi-workflow/workflow-config.ts, exported, synchronous, throws WorkflowConfigError):

{ "reviewDataPaths": {
    "git@gitlab.com:gadhs/standard/package/pi.git": [
      "tools/model-battery/store/**/*.json",
      "tools/model-battery/store/**/*.jsonl",
      "tools/model-battery/store/**/*.diff"
    ] } }
  • WorkflowConfig gains reviewDataPaths: Readonly<Record<string, readonly string[]>>; DEFAULT_WORKFLOW_CONFIG gives it a frozen {}; KNOWN_KEYS gains the name.

  • A new private readDataPaths(v: unknown, path: string) in the same file validates it and throws WorkflowConfigError naming the key and the offending value. The value is a plain object. Each key is a non-empty string, an origin URL. Each value is an array of 1 to 16 patterns (MAX_DATA_PATTERNS = 16).

  • A pattern (isDataPattern(s: string): boolean, exported for the tests) is at most 200 characters of [A-Za-z0-9._/-] only, split on / into at least two segments, none empty, none . or .., the first without . So , /.json, /abs/x, :(top)x, a/../b, a//b, a b/c, a/[x] and store are each refused; store/ and tools/model-battery/store//.json are accepted. No pattern can begin with :, so none is read by git as pathspec magic of its own.

  • A malformed key is a malformed file: loadTunables (packages/pi-workflow/index.ts, private) already reports it at session start and runs with the defaults, which hold no data paths.

  • REPOSITORY_KEYS is unchanged, so a repository’s own .pi/gadhs-pi-workflow.json that sets the key gets today’s warning ("a repository sets only coAuthorEmail - ignored") and no effect. withRepositoryConfig (packages/pi-workflow/repo-config.ts) spreads the operator’s config, so the operator’s value passes through it.

Which of a commit’s changes are data

New module packages/pi-workflow/data-paths.ts:

  • dataPatternsFor(config: Pick<WorkflowConfig, "reviewDataPaths">, origin: string | undefined): readonly string[] - pure. The patterns under the key equal to origin (compared exactly, after trim() of the origin), found with Object.hasOwn; [] for an undefined or unlisted origin.

  • dataPathspecs(patterns: readonly string[], exclude: boolean): string[] - pure. Each pattern as :(top,glob)<p>, or :(top,exclude,glob)<p> when exclude.

  • interface DataChange { patterns: readonly string[]; added: number; modified: number; deleted: number; listing: string }.

  • stagedDataChange(ws: Workspace, cwd: string, allTracked: boolean, config: Pick<WorkflowConfig, "reviewDataPaths">): Promise<DataChange | undefined>, in this order:

    1. No key in config.reviewDataPaths, or allTracked (git commit -a): undefined, with no git call. Under -a git’s listing carries no blob id for a file changed only in the worktree, so changed data could not be told from unchanged; such a commit is handled as today.

    2. ws.git(["remote", "get-url", "origin"], ws.resolve(cwd), { timeoutMs: 10_000 }). A throw, a non-zero code, truncated or timedOut: undefined.

    3. dataPatternsFor(config, stdout) empty: undefined.

    4. ws.git(["diff", "--cached", "--raw", "--no-renames", "--no-abbrev", "-z", "--", …​dataPathspecs(patterns, false)], ws.resolve(cwd), { timeoutMs: 10_000, maxBytes: 64 * 1024 * 1024 }). A throw, a non-zero code, truncated or timedOut: undefined.

    5. The output is NUL-separated pairs: :<old mode> <new mode> <old id> <new id> <status>, then the path. Status A counts as added, D as deleted, any other as modified. A new mode other than 100644 or 000000 (an executable, a symlink, a submodule) makes the whole result undefined: data is ordinary files. No pair at all: undefined.

    6. Otherwise { patterns, added, modified, deleted, listing: <the output> }.

  • dataNote(change: DataChange): string, for the reviewer - exactly: DATA PATHS, COUNTED NOT READ: this machine’s operator declared <patterns> as measured data for this repository. Under them this commit adds <added> file(s), modifies <modified> and deletes <deleted>. Their bytes and names are not in the diff above and are not in your remit. Check the message against these counts: a commit that adds, rewrites or deletes data says so. <patterns> is each pattern through JSON.stringify, joined with ", ".

  • dataNotice(change: DataChange): string, for the author and the human - exactly: Data paths: <total> file(s) under <patterns> counted, not read (<added> added, <modified> modified, <deleted> deleted).

  • dataTrailer(change: DataChange): string - exactly <total> data file(s) by count.

undefined everywhere means the commit is handled as it is today (T8).

What the commit path does with it

In pauseBashCommand (commit-pause.ts, exported, async), right after subjectRefusals returns nothing: const data = shape.isCommit ? await stagedDataChange(at.ws, at.cwd, shape.allTracked, deps.config()) : undefined; and const patterns = data?.patterns ?? [];. They are passed on as a new last parameter, optional and empty by default, of each function below. With patterns empty every git argument list is what it is today (T6).

  • excludePathspecs(paths, globs: readonly string[] = []) (packages/pi-workflow/approved-plan.ts, exported): both empty gives []; otherwise ["--", ":/", …​paths.map((p) ⇒ `:(top,exclude)${p}), …​dataPathspecs(globs, true)]`.

  • readStagedForReview(ws, cwd, allTracked = false, exclude = [], dataPatterns: readonly string[] = []) (packages/pi-workflow/git-guard.ts, exported, async) passes dataPatterns to excludePathspecs, so its stat and diff hold no data file. Its three callers pass patterns: commentDialectRefusal, oversizeRefusal and reviewStaged. The size bound therefore measures the rest of the diff, and data lines are not read for the plan’s dialect.

  • readStagedDiff(ws, cwd, allTracked = false, dataPatterns: readonly string[] = []) (git-guard.ts, private today) is exported and appends "--", ":/", …​dataPathspecs(dataPatterns, true) when dataPatterns is not empty.

  • reviewKeyOf(at, shape, declared, data?) (commit-pause.ts, private): with data, it calls stagedDiffKey with (ws, cwd, all) ⇒ readStagedDiff(ws, cwd, all, data.patterns) as readDiff and appends data\0${data.listing} to also. The listing holds every data file’s old and new blob id, so a commit whose data changed has another key, and a 212 MB commit has a readable one. Without data the call is today’s.

  • splitApprovedPlan(ws, cwd, allTracked, approval, dataPatterns: readonly string[] = []) (approved-plan.ts, exported, async) appends dataPathspecs(dataPatterns, true) to its --name-only listing, so no data file is fetched or classed. approvedPlanIn passes patterns. In pauseBashCommand the no-pause shortcut’s condition becomes plan?.others.length === 0 && data === undefined && plainCommit(shape): a plan committed beside data is reviewed, with both notes.

  • reviewCommit(…​, data?) passes data through reviewWithFallback to reviewStaged, and before the review, once: ctx.ui.notify(`commit guard: ${dataNotice(data)}, "info")` and bridge.debugLog("git_guard.data_paths", { mode: bridge.modeId(), added, modified, deleted, patterns: data.patterns.length }).

  • reviewStaged(…​, data?) adds dataNote: dataNote(data) to the review’s input and dataNotice(data) to the notes it already passes (after the rules shortfall, when both exist).

  • ReviewInput (reflection-review.ts) gains dataNote?: string; buildReviewPrompt appends \n${input.dataNote} after the approved-plan line. Without it the prompt is today’s string (T6).

  • The trailer: in reviewCommit, reviewTrailer(…​)’s value, when defined and `data is defined, gains ; ${dataTrailer(data)} before it is kept in deps.cycle.verdicts. reviewTrailer itself is unchanged. Example: Reflection-Review: CLEAN (vertex-gemini/gemini-4-carbon); 35209 data file(s) by count.

A commit with only data staged reaches the reviewer with an empty STAT and DIFF, the message and the note: one review of the message against the counts.

Not in this plan

  • A staged diff past 64 MiB, which no data path excuses, is unreadable to the guard and by reading falls to "unreviewed, self-review" after MAX_UNREVIEWED_ATTEMPTS; filed as its own fix after approval.

  • Hardening the shell routes to the operator’s file beyond the existing rules.

  • A declaration inside the repository (.gitattributes): ruled out by the operator.

  • The plan review: a plan is prose and is read whole.

Scope

  • packages/pi-workflow/data-paths.ts - new.

  • packages/pi-workflow/workflow-config.ts - the key, its validation, isDataPattern.

  • packages/pi-workflow/git-guard.ts - readStagedForReview, readStagedDiff (exported).

  • packages/pi-workflow/approved-plan.ts - excludePathspecs, splitApprovedPlan.

  • packages/pi-workflow/commit-pause.ts - pauseBashCommand, commentDialectRefusal, oversizeRefusal, reviewKeyOf, approvedPlanIn, reviewCommit, reviewWithFallback, reviewStaged.

  • packages/pi-workflow/reflection-review.ts - ReviewInput, buildReviewPrompt.

  • Tests: new packages/pi-workflow/test/data-paths.test.ts; added cases in test/workflow-config.test.ts, test/repo-config.test.ts and test/extension-wiring.test.ts, whose harness gains two options: origin?: string (runs git remote add origin <url>) and planApproval?: { sha256: string; at: number; text?: string } (published on its bridge). Every new parameter is optional, so no existing caller or test changes; a full WorkflowConfig literal without the new field fails typecheck, and the one grep finds is in test/workflow-config.test.ts.

  • Docs: docs/modules/ROOT/pages/modes.adoc ("What the reviewer reads", and the Reflection-Review row of the trailer table); docs/modules/ROOT/pages/tuning.adoc (a new section under "The workflow guards": "Commit measured data without sending it to the reviewer"); docs/modules/ROOT/pages/public-surface.adoc (the key list of gadhs-pi-workflow.json); CHANGELOG.adoc; this plan as docs/modules/ROOT/pages/plans/review-data-paths.adoc with its entry in docs/modules/ROOT/nav.adoc.

  • Not touched: packages/pi-modes (its rules on the operator’s files stand), the plan review, tools/model-battery.

Risks

  • A secret or other harm inside data bytes is not seen by the reviewer - fail-open, by design. Mitigation: the project’s Secret-Detection job on push (.gitlab-ci.yml); patterns that name file types; the notice and the trailer on each such commit.

  • A pattern broader than data (packages/*/.ts) hides code - fail-open. Mitigation: only the operator’s file sets it; the grammar refuses a pattern with no named top directory (T2); the trailer makes each such commit findable (git log --grep 'data file(s) by count'); the tuning page says to name file types.

  • An agent writes the operator’s file through the shell - fail-open. Mitigation: the existing deny rules for the write tool, the edit tool and a redirect, pinned in packages/pi-modes/test/credentials.test.ts; any other route is the judge’s. Not hardened here.

  • An agent points another repository’s origin at a listed URL - fail-open, for that repository’s files under the listed patterns only. Mitigation: git remote set-url is a shell command the mode’s judge sees; the trailer.

  • git cannot answer (no origin, a lost link, a listing cut or timed out), or the commit is -a - fail-closed: no data treatment, the commit handled as today (T8).

  • The same origin spelled another way (https for ssh) - fail-closed: not listed, handled as today. The tuning page says to list each spelling used.

  • A malformed key - fail-closed: the file is reported at session start and the defaults run, with no data paths (T1). Silent only in that the other tunables fall to defaults with it, as for any malformed key today; the notice names the file and the problem.

  • An older release reads a file with the new key - fail-closed for data; it refuses the whole file as an unknown key and runs on defaults, with its error notice. Mitigation: the tuning page says to add the key on a box running the release that carries it.

  • The message misstates what the data change is - fail-open in part: the reviewer is given git’s counts and told to check the message against them; it cannot check contents.

  • A plan committed beside data skips its review - would be fail-open; the shortcut’s condition excludes it (T12).

  • Something parses the trailer’s value - silent if so. By grep nothing does: REFLECTION_REVIEW_LINE (git-guard.ts) tests only that the line exists.

Tests

Contract and unit, test/workflow-config.test.ts and test/data-paths.test.ts:

  • T1 "reviewDataPaths loads as given, defaults to none, and a malformed one is refused by name": a non-object, an empty array, 17 patterns and a non-string pattern each throw WorkflowConfigError naming reviewDataPaths.

  • T2 "a pattern names a top directory and stays inside the repository": the refused and accepted lists above, one row each.

  • T3 (property, fast-check) "any JSON value under reviewDataPaths loads to patterns that all pass isDataPattern, or throws WorkflowConfigError": no other error and no other outcome.

  • T4 "patterns are found by the exact origin, through own keys only": unlisted, undefined, proto and constructor give [].

  • T5 "the listing counts added, modified and deleted; an executable, a symlink or a submodule under a pattern voids it": parsing of fixed --raw -z text.

  • T6 "the reviewer’s note, the author’s line and the trailer, to the letter; with no data nothing moves": the three texts; buildReviewPrompt without dataNote equals a pinned literal of today’s prompt and with it ends in the note; excludePathspecs(paths) and excludePathspecs([]) return what they return today, and excludePathspecs([], ["store/"]) is ["--", ":/", ":(top,exclude,glob)store/"].

Regression and contract with real git, test/extension-wiring.test.ts (run locally and, by validate’s second run of this suite, through the SSH workspace):

  • T7 (regression) "data past the size bound is committed, counted and not sent": 1,600,000 characters of JSON under store/ beside a small .ts change, the origin listed with store//.json. Not refused; one reviewer call whose prompt holds the .ts change and DATA PATHS, COUNTED NOT READ with adds 1 file(s), modifies 0 and deletes 0, and holds neither the JSON’s marker string nor the data file’s name; the command ends --trailer 'Reflection-Review: CLEAN (<reviewer>); 1 data file(s) by count'; the notice info: commit guard: Data paths: 1 file(s) under "store//.json" counted, not read (1 added, 0 modified, 0 deleted). appears once.

  • T8 (control) "the same commit with no listed origin, or under -a, is refused as before": once with no key, once with another origin’s key, once with the key and no origin remote, once listed but committed with git commit -a - each the #878 refusal by length, with no reviewer call.

  • T9 "a file of another type under a data directory is read whole": a .ts under store/ is in the prompt.

  • T10 "deleted data is counted": three committed data files removed give deletes 3.

  • T11 "changed data is another commit, not the identical retry": with a FLAGS review, re-staging different data is reviewed again (two reviewer calls); unchanged data meets the disposition refusal (one call).

  • T12 "an approved plan beside data is reviewed, with both notes": the prompt holds APPROVED PLAN, NOT IN YOUR REMIT and DATA PATHS, COUNTED NOT READ; no "no pause" notice.

  • T13 "an executable under a data path voids the data treatment": after git update-index --chmod=+x, the file is in the prompt and there is no note.

  • T14 "a move across the boundary shows its code side": code moved to a data name is shown as a deletion and counted as one added; data moved to a code path is shown whole as an addition.

  • T15 "a data file’s lines are not read for the plan’s dialect": pattern store/*/.diff, a staged store/p.diff with the line // U3: per the plan; refused without the key, not refused with it.

  • T16, test/repo-config.test.ts, "a repository that sets reviewDataPaths is told it is ignored".

Negative controls: a mutants script over data-paths.ts and the changed lines of commit-pause.ts (the note dropped, the suffix dropped, the shortcut’s data === undefined dropped, the mode rule dropped, the listing left out of the key, exclude inverted); each caught, or a test added.

Delivery

  1. This plan committed as docs/modules/ROOT/pages/plans/review-data-paths.adoc, with its nav.adoc entry after the last Active plan, before any code; Status moved to In progress at the first code commit.

  2. Code, tests, the three doc pages and the CHANGELOG.adoc entry under == Unreleased, Added, on the branch; mutants; validate (both runs) and the full consumer-sim as a job; the patch to pi-win for the Windows suite.

  3. MR with Closes #916, merged with squash off; the merge SHA noted on the issue.

  4. The operator adds the key for this repository to gadhs-pi-workflow.json on luchs (the tuning page’s example, to the letter); an agent cannot.

  5. The real row, recorded on #902: its prune commit, about 35,000 deleted data files, passes the guard with the note and the trailer suffix, and its .ts and doc changes are read whole.

  6. Status to Done (date); anything deferred named on the issue.

Edit this page · latest