Repository navigation
Commit 7b393a2
authored
📥 Stage exactly the paths a document names (#477)
* 📥 Stage exactly the paths a document names
The second slice of #294. `<Git.Add>` stages the pathspecs a document writes, in
the checkout it writes them in, as one durable Workspace effect:
```md
<Repository name="project" url={props.repository}>
<File path="release/notes.md">…</File>
<Git.Add paths={["release/notes.md", "deno.lock"]} />
</Repository>
```
`paths` is a Git pathspec and nothing else. It does not choose a checkout — that
is decided the way every Git operation's place is decided, by the enclosing
`<Repository>` and the contextual working directory — and it is never optional:
omitting it does not mean everything, and `"."` is how a document says everything
*here*. "Here" is the directory the element was written in, so a staging inside
`<Dir path="nested">` reaches that directory and not the checkout above it.
What a document wrote is what Git receives. One string is the one-entry array,
and an array keeps its order, its repetitions, its spelling and its pathspec
magic, because each of those changes what is staged. The whole array is one
command and one effect: Git decides what a pathspec matches, and staging entry by
entry would be several transitions where the document wrote one. Git applies the
command or none of it, so a refused pathspec leaves the index exactly as it was.
The retained result is evidence: the checkout, the pathspecs as given, and both
readings of the checkout. Staging moves the index and nothing else, so a result
whose branch, commit or HEAD tree changed across it is damage — while its index
tree may have moved or not, because staging what is already staged changes
nothing. What Git matched is deliberately not enumerated: naming files it
discovered would put content beyond the document's own pathspecs into retained
history.
Everything the substrate already owned is reused rather than re-decided: the
whole observed Repository record is authenticated against the retained row, the
working directory selects the longest matching checkout and is proven to be a
real directory inside it, the family is materialized and imported together, and
the effect's identity uses the injective Git-operation fingerprint over every
record member, the working directory and each pathspec in turn.
Native staging failures are infrastructure for now. The conditions a document
could act on — a pathspec that matched nothing, one the repository ignores, one
outside the checkout, one whose magic is invalid — are recognizable and their
evidence is recorded in the handoff, but which of them becomes a durable refusal
is a product decision this slice does not make on an author's behalf.
* 🚫 Refuse the four pathspec conditions a document can act on
The Planner settled the classification PR B left open. A pathspec that matched no
files, one that selects an ignored path, one that leaves the checkout and one
whose Git pathspec magic is invalid are each deterministic, authored and
actionable, so each is now a `GitOperationError` outcome — one failed durable
result against a Workspace root that did not move, replayed exactly — rather than
a run-ending infrastructure failure. Any other native exit stays infrastructure;
the classifier matches the exit status and the message together, so a later Git
version's unrelated failure cannot wear a word this run does not mean.
The review's atomicity premise is correct and my earlier claim was not. Verified
against real Git: `git add -- added.txt ignored.txt` stages `added.txt` and
*then* exits 1, while the three exit-128 conditions stage nothing. So native Git
does not give all-or-none semantics, and the comment saying it did is replaced by
what actually provides them — the refusal is thrown before anything is imported,
the disposable materialization goes with the scope, and the attempt is rolled
back, so the Workspace never holds a partial staging.
Nothing a refusal carries comes from Git. Each sentence names its condition and
neither quotes stderr nor reports a path, a host directory, or a file Git
discovered.
Five new rows drive the four conditions through real Git and assert their exact
public reasons; two more prove the mixed ignored-path case retains none of the
partial staging, that its failed result stands against the unchanged root, and
that replaying it reproduces the same sentence with no Git, no second event and
no new root. The ignored-path classification is mutation-checked.
* 🎯 Classify an Add refusal by Git's frame, not by a phrase in it
Git puts the pathspec it is complaining about inside its own diagnostic, so the
message this reads contains a document's own text. Searching that message for a
phrase let the text answer the question: `paths="../did not match any files"`
produced an outside-repository diagnostic that contains the unmatched phrase and
was reported as `unmatched-pathspec`, and `:(did not match any files)which.txt`
did the same through the invalid-magic diagnostic. Both are confirmed against
real Git.
Nothing searches now. Each condition has a fixed frame Git builds around the
pathspec, and the pathspecs are what this provider just sent, so the frame is
reconstructed for each of them and compared:
fatal: pathspec '<sent>' did not match any files
fatal: <sent>: '<sent>' is outside repository at '<root>'
fatal: Invalid pathspec magic '<magic>' in '<sent>'
plus the ignored advisory, which names no path at all. A document may put any
text it likes inside a frame; it cannot make one condition's diagnostic take
another condition's shape around its own text. The exit status is still part of
the match, only the line Git led with is read, and a diagnostic that fits no
frame remains infrastructure.
Both reproducers are regressions, and restoring the substring classifier fails
exactly those two.
* 📏 Read a Git diagnostic as a message, not as a line
A pathspec is any non-empty string, newlines included, and Git embeds it
verbatim — so the frame comparison read only as far as the pathspec's own first
newline. Confirmed against real Git: `git add -- $'missing\nfile'` exits 128 and
writes
fatal: pathspec 'missing
file' did not match any files
which truncation reduced to `fatal: pathspec 'missing`. That fits no frame, so a
known refusal became an infrastructure failure: the run ended, and no failed
durable result was published or replayable.
The whole of what Git wrote is now compared, less the single newline it ends
with — trimming further would take characters a pathspec is allowed to end with.
The ignored advisory keeps its own rule: it leads the message and the paths Git
found follow it, so what is matched is that first line and nothing after it,
none of which is Git's own words.
Nothing about the component changes. A newline-bearing pathspec is accepted,
passed to Git unchanged, retained in the result exactly as written, and refused
under the word its condition earns.
The regression drives it through real Git, and restoring first-line truncation
fails exactly that row while every other refusal keeps passing.
* 🔤 Refuse a pathspec this host cannot hand to Git as written
A JavaScript string is UTF-16 code units and need not be well-formed text, but
the way to Git is UTF-8: an unpaired surrogate becomes U+FFFD in the argument
list. Confirmed directly — `"\ud800"` reaches a child process as `ef bf bd`. So a
document asking for `"\ud800"` had a checkout's U+FFFD-named file staged, while
the effect identity and the retained result still said `"\ud800"`: one history,
another index.
The settled contract is that an accepted pathspec's spelling is exactly what Git
receives, and this host cannot keep that promise for ill-formed UTF-16. Such a
pathspec is therefore malformed input, refused before an identity is built and
before anything is spawned. `admitPathspecs()` is applied where a document writes
a request *and* inside the provider, because the composition Api is public and a
caller reaching it directly is subject to the same boundary. Nothing is
normalized, respelled or dropped: every well-formed string — U+FFFD included,
along with newlines, separators, repetitions and pathspec magic — still reaches
Git exactly as written.
Four regressions, with the checkout really holding a U+FFFD-named file so the
substitution would have been observable: a leading surrogate and a trailing one
each refused with no Git, no journal entry and nothing staged; the same refusal
through a direct Api call; and a positive control staging that file for an actual
U+FFFD pathspec. Disabling the check fails the three refusals and leaves the
control passing.
`stagedPaths()` now reads `-z` output, because Git quotes a path holding anything
outside ASCII and a suite has to compare the name the Workspace holds.
* 🧊 Run a staging on the request it admitted, not on the caller's objects
`admitPathspecs()` returned a frozen snapshot and the operation threw it away,
carrying on with the caller's own array. A `string[]` is assignable to
`readonly string[]`, and this operation suspends several times before Git is
spawned — a command, a transaction, an import — so whoever handed the array over
could still change it. The effect could then identify one pathspec sequence, hand
Git a second and retain a third, and a pathspec mutated to an unpaired surrogate
would walk straight back into the substitution that was refused a commit ago.
`createGitAdd()` now builds one admitted request and everything runs on it: the
description, the effect, the Git arguments, the result and its parse, and the
placement check. The Repository record is snapshotted with it, for the same
reason and against the same hazard — a caller's record could otherwise change
between the identity that names an effect and the authentication that admits it.
`describeAdd()` and `performGitAdd()` are no longer exported, so `createGitAdd()`
is the only door and nothing downstream can be handed values that still move.
The regression drives the direct Api with a mutable array and mutates it from the
host at the point Git reads the index tree — the last command before staging,
long after the identity was built — with a U+FFFD-named file present so a
substitution would stage something. Git receives `original.txt`, only that file
is staged, and the retained result and the effect's own configuration fingerprint
both say `original.txt`. Returning to validation-only fails exactly that test.
---------
Co-authored-by: Taras Mankovski <[email protected]>1 parent de3068e commit 7b393a2
23 files changed
Lines changed: 2666 additions & 67 deletions
File tree
- packages/workflow
- src
- composition
- components
- deno/composition
- tests
- support
- scripts
- specs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2108 | 2108 | | |
2109 | 2109 | | |
2110 | 2110 | | |
2111 | | - | |
| 2111 | + | |
2112 | 2112 | | |
2113 | 2113 | | |
2114 | 2114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
86 | 92 | | |
87 | 93 | | |
| 94 | + | |
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| |||
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
31 | 45 | | |
32 | 46 | | |
33 | 47 | | |
| |||
37 | 51 | | |
38 | 52 | | |
39 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
40 | 58 | | |
41 | 59 | | |
0 commit comments