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"
] } }
-
WorkflowConfiggainsreviewDataPaths: Readonly<Record<string, readonly string[]>>;DEFAULT_WORKFLOW_CONFIGgives it a frozen{};KNOWN_KEYSgains the name. -
A new private
readDataPaths(v: unknown, path: string)in the same file validates it and throwsWorkflowConfigErrornaming 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]andstoreare each refused;store/andtools/model-battery/store//.jsonare 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_KEYSis unchanged, so a repository’s own.pi/gadhs-pi-workflow.jsonthat 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 toorigin(compared exactly, aftertrim()of the origin), found withObject.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>whenexclude. -
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:-
No key in
config.reviewDataPaths, orallTracked(git commit -a):undefined, with no git call. Under-agit’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. -
ws.git(["remote", "get-url", "origin"], ws.resolve(cwd), { timeoutMs: 10_000 }). A throw, a non-zero code,truncatedortimedOut:undefined. -
dataPatternsFor(config, stdout)empty:undefined. -
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,truncatedortimedOut:undefined. -
The output is NUL-separated pairs:
:<old mode> <new mode> <old id> <new id> <status>, then the path. StatusAcounts as added,Das deleted, any other as modified. A new mode other than100644or000000(an executable, a symlink, a submodule) makes the whole resultundefined: data is ordinary files. No pair at all:undefined. -
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 throughJSON.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) passesdataPatternstoexcludePathspecs, so itsstatanddiffhold no data file. Its three callers passpatterns:commentDialectRefusal,oversizeRefusalandreviewStaged. 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)whendataPatternsis not empty. -
reviewKeyOf(at, shape, declared, data?)(commit-pause.ts, private): withdata, it callsstagedDiffKeywith(ws, cwd, all) ⇒ readStagedDiff(ws, cwd, all, data.patterns)asreadDiffand appendstodata\0${data.listing}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. Withoutdatathe call is today’s. -
splitApprovedPlan(ws, cwd, allTracked, approval, dataPatterns: readonly string[] = [])(approved-plan.ts, exported, async) appendsdataPathspecs(dataPatterns, true)to its--name-onlylisting, so no data file is fetched or classed.approvedPlanInpassespatterns. InpauseBashCommandthe no-pause shortcut’s condition becomesplan?.others.length === 0 && data === undefined && plainCommit(shape): a plan committed beside data is reviewed, with both notes. -
reviewCommit(…, data?)passesdatathroughreviewWithFallbacktoreviewStaged, and before the review, once:ctx.ui.notify(`commit guard: ${dataNotice(data)}, "info")` andbridge.debugLog("git_guard.data_paths", { mode: bridge.modeId(), added, modified, deleted, patterns: data.patterns.length }). -
reviewStaged(…, data?)addsdataNote: dataNote(data)to the review’s input anddataNotice(data)to thenotesit already passes (after the rules shortfall, when both exist). -
ReviewInput(reflection-review.ts) gainsdataNote?: string;buildReviewPromptappendsafter the approved-plan line. Without it the prompt is today’s string (T6).\n${input.dataNote} -
The trailer: in
reviewCommit,reviewTrailer(…)’s value, when defined and `datais defined, gainsbefore it is kept in; ${dataTrailer(data)}deps.cycle.verdicts.reviewTraileritself 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 intest/workflow-config.test.ts,test/repo-config.test.tsandtest/extension-wiring.test.ts, whoseharnessgains two options:origin?: string(runsgit remote add origin <url>) andplanApproval?: { sha256: string; at: number; text?: string }(published on its bridge). Every new parameter is optional, so no existing caller or test changes; a fullWorkflowConfigliteral without the new field fails typecheck, and the one grep finds is intest/workflow-config.test.ts. -
Docs:
docs/modules/ROOT/pages/modes.adoc("What the reviewer reads", and theReflection-Reviewrow 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 ofgadhs-pi-workflow.json);CHANGELOG.adoc; this plan asdocs/modules/ROOT/pages/plans/review-data-paths.adocwith its entry indocs/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
originat a listed URL - fail-open, for that repository’s files under the listed patterns only. Mitigation:git remote set-urlis 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
WorkflowConfigErrornamingreviewDataPaths. -
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,
protoandconstructorgive[]. -
T5 "the listing counts added, modified and deleted; an executable, a symlink or a submodule under a pattern voids it": parsing of fixed
--raw -ztext. -
T6 "the reviewer’s note, the author’s line and the trailer, to the letter; with no data nothing moves": the three texts;
buildReviewPromptwithoutdataNoteequals a pinned literal of today’s prompt and with it ends in the note;excludePathspecs(paths)andexcludePathspecs([])return what they return today, andexcludePathspecs([], ["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.tschange, the origin listed withstore//.json. Not refused; one reviewer call whose prompt holds the.tschange andDATA PATHS, COUNTED NOT READwithadds 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 noticeinfo: 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
originremote, once listed but committed withgit 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
.tsunderstore/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 REMITandDATA 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 stagedstore/p.diffwith 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
-
This plan committed as
docs/modules/ROOT/pages/plans/review-data-paths.adoc, with itsnav.adocentry after the last Active plan, before any code; Status moved to In progress at the first code commit. -
Code, tests, the three doc pages and the
CHANGELOG.adocentry 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. -
MR with
Closes #916, merged with squash off; the merge SHA noted on the issue. -
The operator adds the key for this repository to
gadhs-pi-workflow.jsonon luchs (the tuning page’s example, to the letter); an agent cannot. -
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
.tsand doc changes are read whole. -
Status to
Done (date); anything deferred named on the issue.