Commit ed575e0
fix(S2-1): canonically bind plan envelope, carry+require full identity, normalize read OSError
Closes the three S2-slice-1 blockers (arbiter). No new scope.
Blocker 1 — the validated-plan's authority envelope was only shape-checked (one type/one
file) and compared to the candidates by RAW dict equality, so a self-consistent forged
pair could smuggle a wrong type/file, wrong constraints, mismatched selected_findings, or
extra nested fields. validate_apply_inputs now builds the CANONICAL projection of
target_api / selection / source_files from the candidates' known keys and requires the
plan to EQUAL it exactly.
Blocker 2 — the code indexed c["event_identity"], but the shared candidates validator did
not require it, so a hash-bound candidate missing an identity field passed validation and
the apply gate raised a bare KeyError (violating "every violation -> ApplyError").
validate_candidates_bundle now requires the full identity set (event/source/handler +
*_identity + *_identity_kind) as strings, and the apply context carries all of them (not
just the human display) for the future span-node guard.
Blocker 3 — the preimage SHA read (_sha_file) sat AFTER `except CollectError`, so an
OSError between the root-confinement check and the read (file vanished / permission /
replaced) leaked as a traceback. The resolve + read are now under one try with an added
`except OSError -> ApplyError`.
tests/test_fix_apply.py grows to 32 checks: canonical-projection mismatches (wrong
type/file/constraints/selected_findings, unknown nested field in target/selection/source),
missing/wrong-typed candidate identity fields, the full-identity-context assertion, and a
source-read OSError (chmod-0, capability-guarded) -> ApplyError. ruff + mypy (ownlang) +
run_tests green; S1 unaffected by the stricter candidates validator.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JxKjqdGEFzq4UzZupw379G1 parent 1c577d7 commit ed575e0
3 files changed
Lines changed: 112 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 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 | + | |
121 | 143 | | |
122 | 144 | | |
123 | 145 | | |
| |||
142 | 164 | | |
143 | 165 | | |
144 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
145 | 170 | | |
146 | 171 | | |
147 | 172 | | |
| |||
150 | 175 | | |
151 | 176 | | |
152 | 177 | | |
| 178 | + | |
| 179 | + | |
153 | 180 | | |
| 181 | + | |
| 182 | + | |
154 | 183 | | |
155 | 184 | | |
156 | 185 | | |
| |||
167 | 196 | | |
168 | 197 | | |
169 | 198 | | |
170 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
171 | 202 | | |
172 | 203 | | |
173 | 204 | | |
| 205 | + | |
174 | 206 | | |
175 | 207 | | |
176 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
177 | 211 | | |
178 | 212 | | |
179 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
420 | 423 | | |
421 | 424 | | |
422 | 425 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
129 | | - | |
130 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
131 | 174 | | |
132 | 175 | | |
133 | 176 | | |
| |||
202 | 245 | | |
203 | 246 | | |
204 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
205 | 270 | | |
206 | 271 | | |
207 | 272 | | |
| |||
0 commit comments