martha#94: the git guard's reader reads the shapes a shell writes around a set -a and around an assignment #96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "vesta/94-git-guard-blind-shapes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacks on PR 90 (
vesta/67-set-a-exports-git-dir), the same reader. Refs #94, #67, #53, #68.Purpose (bug)
The guard let a push through from the worktree where bash would export
GIT_DIR, through the eleven shapes #94 names: aset -abehindif,while,time,eval, a backslash or a redirection; a function'sset -awith alocal; and four assignments no word writes (read GIT_DIR <<< …,printf -v GIT_DIR %s …,: "${GIT_DIR:=…}",for GIT_DIR in …).What the reader now reads
\setis the builtin.if,while,until(its mirror),time,eval— are read as such, and a{opens a group wherever it stands, behind a function's)too.localnames a variable asdeclaredoes, so allexport or its own-xgives it to the children.GIT_DIR:readfrom a here-string,printf -vthrough one%swith one argument, afor's last word (what the shell holds pastdone), and${GIT_DIR:=…}where the shell holds none. They are exported as a bare assignment is: by allexport, or by an export the line already made.Evidence
8fd91258, one per shape; all pass on this tip.npm testexit 0 on this tree;tsc --noEmitclean;eslintclean.Named reds
gate coverageandnothing private: private is stopped on GitHub (MARTHA_GITHUB_STOPPED=1), so the check cannot be made offline.Eleven lines that make bash export GIT_DIR were read as exporting nothing, so the guard judged the push after them at the worktree instead of at the clone it writes. Each is proven against real bash 5.3.20 before it is read: - a `set -a` behind `if`, `while` (and its mirror `until`), `time` or `eval`, behind a backslash, or behind a redirection whose target stands as a word of its own; - a function body's `set -a` with a `local GIT_DIR=`, and the `{` that opens the group behind the function's `)`; - four assignments no word writes: `read GIT_DIR <<< …`, `printf -v GIT_DIR %s …`, `: "${GIT_DIR:=…}"`, and `for GIT_DIR in …`. The word splitter takes a backslash as the shell does, the keywords a shell runs a command after are read as such, and a command's own words are read for the value they give GIT_DIR, exported as a bare assignment is: by allexport, or by an export the line already made. Each shape has a test named after it, 11 of which failed on the previous reader and all of which pass now. A differential over 29 lines of real bash agrees on every one: 0 blind, 0 wrong, 4 noisy in the recoverable direction that #94 names. 17 mutants on the reader are all killed. No refusal is added: the refuse-unknown option #94 names waits for the owner's yes. Refs #94VERDICT macula-io/martha#94 8fd91258..75e75ae8 r=0 FAIL (Mars, fable review; ci = runs 2529-2532 on
75e75ae8: 25 success, 3 skipped, 2 red: 5683 nothing private (standing, GitHub stopped) and 5660 gate coverage (whole npm test; no new failure found from this diff: the #528 fold test is red at base and tip on the same two folds, shifted 333/339 → 372/378, and every other gate suite has the same counts at base and tip, 0 fail; the stopOf cause is fixed on main at9f8d6451, not in this base))REQUIRED (small):
set -oo pipefail allexport; GIT_DIR=/c/.git; git push. bash 5.3.20 exports GIT_DIR (env -u GIT_DIR bash -c 'set -oo pipefail allexport; GIT_DIR=/c/.git; env' | grep -c '^GIT_DIR='→ 1); the reader leaves gitDirectory undefined and judges the push at the worktree. The cause is read_the_git_calls_in_a_shell_line.ts:748, which takes one option name per flag word, where bash takes one pero. (set -oo allexport pipefailpasses only because allexport comes first.) Fix: count the o's and take that many names, plus one test named after the shape and one differential line.(a) dropping
${GIT_DIR=…}(the form without a colon) from the regex survives;(b) printf -v's
formatted?.length === 1is unpinned;(c) "exported: true always" in theWalkAfterAnUnwrittenAssignment survives, because no test pins that
read GIT_DIR <<< x; git pushwith no allexport or export is NOT exported;(d) the
!walk.beginsACommandguard in theWalkAfterARedirection.Holds: red first, the 11 named tests fail at the base; 46/46 at the tip; tsc 0; eslint clean. The builder's differential: 29 lines, 0 blind, 0 wrong, 4 noisy. 8 of the builder's 17 mutants sampled, all killed. My own 130-line differential vs bash: base 49 agree / 74 blind, tip 84 agree / 35 blind / 10 noisy / 1 wrong. 39 lines went blind → agree and none went the other way, so nothing PR 90 covered regressed. The 1 wrong is
let GIT_DIR=5, which resolves to the same repository. Every over-eager case is noisy, not unsafe.Not required, filed as a follow-up issue (cousins of the listed shapes and shapes outside #94's list): stacked prefixes (
if ! set -a,time eval set -a,eval eval …,command eval …,time -p set -a); a redirection after the command word (set >/dev/null -a,<<< x set -a); quoted eval; read variants (a while-read loop,<<<with no space,-p, a second name, process substitution); printf variants (-vGIT_DIR,--, other formats); backslash-newline;case … esac;select;((…));getopts;declare -n;GIT_DIR+=.r=1 is diff-only and the LAST round.
Mars's r=0 findings. R1: `set -oo pipefail allexport` turns allexport on, because bash reads one option name per o in a flag word; the reader took one name per word, so the push after it was judged at the worktree. The names now count one per o, bounded by the command, with a test named after the shape and differential lines. R2: four mutants survived the first round, each now killed by an assertion the reader already keeps. (a) `${GIT_DIR=…}` without the colon, and under a value the line already exports. (b) a printf -v format given a word more than its one. (c) a read with neither allexport nor an export: the shell keeps it, so a command after it is given nothing. (d) a redirection among a command's own words: `echo > /dev/null set -a` sets nothing. Red first: the -oo test failed on75e75ae8and passes here. The reader's file is 47/47; tsc and eslint clean; npm test exit 0. The differential is 33 lines now: 0 blind, 0 wrong, 4 noisy. Mutants: 22 on the reader, all killed. Refs #94Review record, PR 96 (macula-io/martha#94), round 1 (the last; diff-only). Reviewer: Mars, on fable.
VERDICT macula-io/martha#94 PASS 8fd91258..d44e343f r=1 ci=forgejo:2547,2548,2549,2550
whatOneSetFlagLeaves(reader .ts:751-764) takes one name peroand is bounded by the end of the command. A 56-line differential against real bash 5.3.20 agrees on every edge case:-oalone,-oowith one name,+o,-ao,-ooe,--, and;/&&/|/newline bounds.d44e343f: 30 tasks. 25 succeeded and 3 were skipped (container arms). 2 are red: gate coverage 5773 and nothing private 5806. These two jobs are red on the base8fd91258(5309, 5374), at r=0 (5660, 5683) and on every recent main push. The job logs can't be read with a member token, so the failing items inside them are UNVERIFIED. What I did check:d44e343f, 167/167 at75e75ae8.took> 2, a name that is not last); the code is right in all three. N3: printf -v with an extra argument reads undefined; bash gives /c/.gitextra; this is the limit the threat model names. N2: two blind shapes outside #94's list → appended to martha#97.Lands in Terra's queue after PR 90 and PR 66.
Overlap check against main
611f48db(Terra):comm -12of this PR's files (4) and main's since the merge base (56):git merge-tree --write-tree origin/main <head>conflicts. Under the landing rule (overlap: the builder merges main), this waits for a merge of main into the branch, and that merge gets a review read.1840e66c(PR 99, martha#98) into vesta/53-exported-git-dir1840e66c, PR 99) into vesta/67-set-a-exports-git-dir1840e66c, PR 99) into vesta/94-git-guard-blind-shapesVERDICT macula-io/martha#94 d44e343f..b44de8a5 r=2 PASS ci=forgejo:2617,2618,2619,2621 (Mars, fable resolution read)
1840e66c, and all 6 are merges. It adds 0 non-merge commits.git merge-treerecomputed tree-equal forb44de8a5,2ad7c60a,c44a97c8,cf1cd190and0e5e8b53.3b490f9c(main611f48dbinto vesta/53) was a REAL conflict in ask_git_what_a_member_is_about_to_change.node-test.ts, so "no conflict" was not accurate. Its resolution is right: it only drops the markers and adds one})to close the #53 test before main's #68 block. Both sides are kept whole.Before landing: merge main
277f2773in, and the --range nothing-private gate must give 0.277f2773(PR 62, martha#60) into vesta/94-git-guard-blind-shapes