Skip to content

Reconcile corrective S016 branch content - #231

Open
dbowm91 wants to merge 164 commits into
mainfrom
feat/auto-20261109-f8abad0d-artifact-safe
Open

dbowm91 wants to merge 164 commits into
mainfrom
feat/auto-20261109-f8abad0d-artifact-safe

Conversation

@dbowm91

@dbowm91 dbowm91 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

This separate PR carries the artifact-safe reconciliation at 1d2e6ee976c5d53c6ed7c2e40b6f8d28346c1469 from feat/auto-20261109-f8abad0d-artifact-safe to main, leaving the existing PR branch untouched and excluding the upstream-only monitor-summary history.

Validation:

  • cargo build --bin codegg passed.
  • scripts/verify.sh quick ran with CODEGG_H006_CODEGG_BINARY configured and exited 1; output was suppressed, so the failing step is unknown.
  • Focused formatting, Rust tests, harness tests, Python compilation, assertion-quality, and duplication checks passed earlier.
  • Hosted CI is expected to run for this PR; no CI outcome is claimed yet.

…stones

A second read-only audit of the TUI render path found five recurring cost
shapes, all paid 12.5-62 times per second because the event loop redraws on
every pump tick while streaming, Working, or showing a toast. This registers
the workstream and its six mutually independent milestones; the registry
rows read ready for handoff and close as each lands.
The retained frame buffer was deep-cloned on every frame for a reader that
returns early unless a selection is live; the sidebar's projection was
re-materialized once per occupied panel; its line model was built four
times; an open subagent tab was cloned; the composer hint was built twice;
the tasks overlay's rows were built twice with an allocating lookup; and the
watermark scan allocated on every frame.

Measured before -> after: buffer clones 1 -> 0 with no selection; sidebar
populations 2 -> 1 with two panels and 1 -> 0 unchanged; line builds 3 -> 1;
tab clones 1 -> 0; hint builds 2 -> 1; task-list builds 2 -> 1; watermark
scans 2 -> 0 unchanged.

render_cost.rs lands whole here rather than accumulating one counter group
per milestone: the counters are one registry, and splitting the registry
across six commits would make five of them carry unused producers. The
status-bar summary cache is deferred under the plan's own stop condition.
rows() was two full clones (a tree walk cloning two strings per node, then
filter_rows cloning the vector again), and /files called it three to four
times per frame. It now returns a borrow from a RowCache keyed on
(revision, filter) and rebuilt inside bump(), the single mutation choke
point.

The stale-path proof is the milestone: removed, renamed, collapsed,
re-scoped, replaced-listing, project-switch and teardown each have a test,
and dropping revision from the key fails 38 of 62 state tests and 5 of 12
family tests. This discharges the finding C006's closure carried over.

Measured unchanged-frame: pane 1 build + 1 pass -> 0/0; /files modal 4
passes -> 0; /files panel 3 -> 0.
…view's hunks

The chat surface had no cache anywhere: every draw flattened the whole
retained window into fresh rows, and the 500-byte display cap is applied
only on the command-line projection, so bodies were wrapped in full at
panel width. The change review deep-cloned the parsed patch per frame.

ChatBrowser now caches the row model against (sequence, unread, channel,
width, cursor, theme); the two surfaces keep separate caches; the unread
count is memoized; and DiffViewer gained a borrowed render path.

Measured unchanged-frame: panel 1 build + N wraps + 1 scan -> 0/0/0 at 1,
10 and 100 messages; box N wraps -> 0; review 237 hunk copies -> 0.
Dropping sequence from the key fails the redaction and edit tests.

MAX_CHAT_BODY_DISPLAY_LEN on the render path is deferred: it is a
product-visible truncation, and the record says so.
…yload parse

The streaming tail's fast path re-assembled and therefore re-cloned every
block's rows on the branch whose comment says they are already rendered; a
part cache hit returned an owned clone the caller copied again; a collapsed
tool call parsed its JSON before the expanded gate, so the disclosure
default was the expensive case; and the code-block wrapper emitted one span
and one heap string per character.

Measured: tail copies 1 -> 0 unchanged; part copies 6 -> 3 (7 -> 3 under
search); collapsed body builds 1 -> 0; code-block spans 8000 -> 100 for a
100x80 block.

render_md_line_wrapped is deferred: routing it through the styled wrap would
keep styling the current path drops, which is a rendered-output change.
…check

A visible row was read whole and walked past the column window with no early
exit; the viewport resolver read the same window a second time for the
horizontal clamp; the semantic-token scan was linear over all tokens per
row; the style lookup restarted from index 0 per segment; and
first_changed_line re-read and re-hashed the whole scanned prefix per
keystroke.

Measured warm frame: row reads 80 -> 40; row bytes 320000 -> 19520 over long
lines and 40000 -> 492 over a minified line; token scan steps 40000 -> 480;
highlight prefix 4900 -> 0 for an edit below the scan.

ADR-0011 holds: no second buffer, no materialized rows, and the clamp memo
holds one integer. All five editor guards are green with no allowlist edit.
codegg-document gains two additive read accessors; read_bytes is unchanged.
The span lookup rescanned its span list from the front for every word, so
the cost was words x spans and it allocated a Vec per word; every word was
also measured twice. A monotone SpanCursor replaces both, and the plain
engine chunks a word by byte range instead of allocating per word.

Measured: span rescans 10000 -> 298 for 100 spans; width measures 2 per word
-> 1, and 4 -> 1 for a hard-broken word.

The contract is unchanged - no signature, no visibility, no output, no
escape rule - and a boundary perturbation is shown making the comparison
fail. The plain engine's recorded escape-atomicity defect is neither fixed
nor moved.
A block's meaning can depend on the block before it: a table's delimiter row
reinterprets the paragraph above it as the header, and a setext underline
reinterprets the paragraph above it as a heading. Both arrive as a block of
their own first, so re-parsing only the last block left the earlier one
committed to the wrong shape and a streamed table never formed.

reparse_start_line now backs up one block, which costs one extra block
re-parse per tick - bounded by a block, not by the response. The defect test
became a positive test and the table joined INCREMENTAL_FIXTURES, so the
every-three-character-prefix comparison covers it.
chunk_word added every character's width as it walked, then added the run's
width again at the flush. A word spanning two or more spans therefore
measured wider than it draws and broke earlier than its true width, which is
why such a word broke differently from the plain engine.

This changes where rows break, so it could not ride on a cost milestone.
The reference model is corrected with it - a reference that reproduced the
defect would have asserted it - and the comparison tests are renamed off the
pre-M006 framing. a_word_split_across_spans_breaks_at_its_true_width derives
the expectation from the width arithmetic and cross-checks both widths
against the plain engine, which never had the bug: 13 columns fits a
13-column word, 12 hard-breaks it.
prev_was_reasoning was reset inside `if matched.is_none()`, so a text part
that was the searched part left the flag set and the reasoning block after
it drew no header - one row fewer than the same transcript without a search.

The reset is now unconditional: a search recolours rows, it never adds or
drops one. The test pins that invariant three ways rather than flipping an
assertion - the plain transcript draws both headers, the searched one draws
both, and the two total row counts are equal.
The (rN) marker is appended to a message's last row, and that row was
already padded to the full width for the selection bar, so the marker landed
past the drawn columns and ratatui clipped it - an edited message looked
unedited in the side panel.

Two halves: the body wraps at the width minus the marker, and the selection
padding reserves the marker's columns on the row it lands on. The trade-off
is the owner's choice - every row of a revised message is narrower than the
same message unrevised - and only a revised message pays it.
FileTreeState's row inputs stay pub, but a direct write through
file_tree_state. from outside the authority bypasses bump and serves the
previous listing - the one defect M002 exists to prevent. The new
file-tree-row-input-write check rejects an assignment or an in-place mutator
and walks src/tui and tests/tui_render rather than a fixed file list. The
retargeted tasks-whole-list-clone injection is a genuine deep clone again.

a_message_parts_markdown_is_parsed_once now really builds five parts - the
tag form yielded one - and the composer-hint test covers resize mode.

The guard, the architecture rows, the comment-budget bank and the line's
records land here because they are properties of the tree rather than of one
milestone. The bank is a single snapshot, so it can only land once: the
earlier commits do not individually satisfy check_comment_budget.py.
TUI modularity (M001-M010 plus the Halloy mapping and hint-convergence
correctives), Helix capability parity (M001-M009), harness practice
adoption (M001-M007), the sandbox containment audit (C001-C006) and the
advertised-keys corrective (C001-C002) - each milestone implemented and
each with a closure record, plus the cross-line corrective that makes
those records' remaining conditions true.

The load-bearing changes:

- the render-invariant harness (I1-I6) and its ratchets: `[contrast]` is
  0 across the 50 bundled themes, reached by fixing the Halloy
  *projection* (five legibility gates) rather than the third-party
  palettes, which are byte-identical to before. ADR-0062 was accepted
  and then amended: the authority rule is "translated vs named".
- one hint vocabulary. Every advertised key is read from the producer's
  structured items; the I4 residue is 4 reasoned rows; the footers that
  painted no advertisement row at all now paint, and the tasks overlay
  reserves the row its painter draws.
- one dialog frame (`Section`), one panel chrome, content-sized modals,
  a pure `plan_frame`, `ListCursor`, and the slash dispatch split into
  45 family modules - with the guards that went vacuous during that
  split re-pointed and proved non-vacuous.
- the sandbox audit's evidence integrity: the helper reports the ABI its
  own `apply_process_scopes()` returned before `exec`, and the parent
  names it.
- `Diff`'s `End` no longer blanks a two-hunk pane: five per-hunk offset
  applications became one continuous walk, with two mutation-proven
  tests.
- keybind's dead 131-line `Widget` impl is deleted; its comment ceiling
  moved deliberately in the same diff.
- Export's `Esc` gains the app-level dispatch test it was missing.

What this commit does NOT contain, and why: the sandbox Linux narrowing
(`/proc`, `/var/run`) and the CI qualification marker are WP B and WP C
of `five-line-closure-corrective/001`, which the plan gates on this
commit - `#[cfg(target_os = "linux")]` code cannot be observed on the
authoring host. They follow in their own commit, verified by a hosted
run.

Verified on this tree: `scripts/verify.sh full` - 17,380 workspace tests
and 8,444 feature-pass tests, 0 failures; `cargo fmt --all --check`
clean; clippy `-D warnings` clean; render corpus 1237/0.

Plans: 83 files under `plans/`, including ADR-0062 and its amendment,
five closure records sets, and the cross-line corrective's plan and
closure record.
C002's two open items, the residue the closure corrective called a live
control gap rather than evidence debt.

A tree grant on `/proc` made `/proc/<other-pid>/environ` readable for a
same-uid process, and a tree grant on `/var/run` exposed whatever a
distribution keeps under `/run` - including secrets mounted there.
Landlock cannot subtract from a granted tree, so both are now named
narrowly: the self-scoped `/proc` entries, the kernel's informational
files, the read-only sysctl view, and the resolver file that exists.

`/proc/self` resolves to this process's pid directory when the rule is
added and `exec` keeps the pid, so the command keeps its own
`/proc/self/exe`. A *child* of the command has its own pid and does not
inherit it - recorded as a residue, not implied as a guarantee.

Evidence, on real launches:

- `the_default_grant_set_denies_another_processes_proc_entry`: another
  process's `/proc/<pid>/stat` and `/proc/<pid>/environ` are out of
  reach, the command's own `/proc/self/exe` still reads, and the same
  entry reads once the `/proc` tree is restored - so the denial is the
  grant, not the kernel.
- `the_narrowed_grant_set_runs_the_toolchain_and_its_proc_entries_are_load_bearing`:
  the committed matrix. Shell, git, python, resolver and self-proc
  probes pass under the production grant set, and removing the narrow
  `/proc` entries breaks at least one of them, so they are load-bearing
  rather than decorative. Reduced from the plan's three arms to two:
  `/var/run` is no longer granted at all, so a third arm has nothing
  left to remove.
- `the_qualification_lane_obtains_landlock_abi_six`: `ci.yml` sets
  `CODEGG_SANDBOX_QUALIFICATION=1` on the workspace sweep, so a runner
  without a Landlock backend fails instead of skipping and a pre-6.12
  kernel fails the ABI-6 probe instead of passing silently. The marker's
  own spelling is asserted on every host, so a typo cannot disable it.

A unit test pins the grant set itself: no `/proc`, `/var/run` or `/run`
tree, the self-scoped entry present, and nothing naming `environ`.

Verified locally: `scripts/verify.sh quick` (QUICK_RC=0), the policy
suite 22/22, `cargo fmt --all --check`. The Linux fixtures cannot run on
the authoring host; the hosted run is their evidence.
… lane

The first CI run and its A/B baseline agree on one thing and disagree on
another, and both matter.

The narrowing's `/proc/self` entry was wrong as written. The parent
canonicalizes every read root, so `/proc/self` became the *daemon's* pid
directory and was sent to the helper - granting the wrong process and
leaving the command without its own. The per-process aliases now travel
unresolved and the helper resolves them at the pid `exec` preserves,
which is the target's own.

`ci.yml` is red on this branch for a reason that predates the narrowing:
`test_h006_real_background_job_is_observed_by_exact_id_while_work_continues`
fails on Linux on both `a976f7f3c` and its A/B baseline `fe98d86ef`,
identically, before the workspace sweep runs. The sweep's evidence
therefore cannot come from that job until H006 is fixed, so the grants
get a lane of their own: `linux-sandbox-grants-native.yml` builds the
helper and runs only the sandbox fixtures, with the qualification marker
set. That is also the more honest home for the matrix - a failure there
names the grant instead of hiding inside a sweep.

The fixture's self-probe is an *open* by the shell now, not a `stat`:
Landlock does not gate `stat`, so `[ -e ... ]` proved nothing, and a
child's `/proc/self` names the child. `read ... < /proc/self/stat` is
opened at the pid the helper exec'd into.

The descriptor's `/proc` limit is corrected with it: it said the default
grant includes `/proc` and a same-uid environment can be read. That was
true before this change and is false after it; it now states the residue
- a child of the command cannot read its own `/proc/self`.

Also adds `plans/closure/five-line-closure-corrective/002-owner-decisions.md`:
the seven open decisions with their options, costs and recommendations.

Verified locally: `scripts/verify.sh quick` (QUICK_RC=0), fmt, the policy
and sandbox suites, and the comment ratchet with its ceilings moved.
The grant lane builds only the helper, so `target/debug/deps` does not
exist yet and the belt-and-braces copy fails the step before any fixture
runs. `test_helper_path` resolves the helper beside the profile
directory, so the copy is redundant for the plain `cargo test` path -
but it is what the workspace sweep does, and keeping the two lanes
identical is worth one `mkdir`.
… snapshot

The protected mount view snapshots every read root's device and inode and
re-checks them before it builds mounts. A per-process alias cannot pass
that check by construction: canonicalizing `/proc/self` yields
`/proc/<pid>`, so the snapshot would either reject the symlink or report
"sandbox grant path changed its canonical identity" - which is exactly
what the C006 lane reported on the alias-fixed head.

They are names, not replaceable objects, so they are skipped there. The
grant itself is unaffected: the helper still resolves them at the pid
`exec` preserves.
`check_test_filter_execution.py` refuses an unregistered filtered
security run, because a filter that matches nothing is a green step that
qualified nothing. The lane's three tests are named in the entry, so the
guard now asserts they were actually executed and that no self-skip
marker was emitted - which is also what makes the qualification marker
load-bearing rather than decorative.
The registry is an input to the lane - an unregistered step is refused
and a drifted entry is a failure - so a change to it must re-run the
lane that depends on it.
Five fixtures failed on the lane with a bare `Os { code: 2 }` from
`Command::output()`, which says a sidecar is missing without saying
which path was tried. The panic names it now, and the lane prints what
it built. That is a diagnostic for the lane, not a change to any
assertion.
Two errors from the diagnostic run, both real:

- the binding was inserted after its use, which is a compile error the
  Linux-only path hid from the local check - the hosted compiler is the
  oracle for this file, which is exactly why the lane exists;
- the step ran the fixtures multi-threaded. Every other security filter
  in `docs/security-test-filters.toml` runs `--test-threads=1`: these
  fixtures fork a helper and pass it a status pipe, and a concurrently
  forked child inherits another test's descriptors.
…ayout

The hosted grant lane resolved the helper to
`target/debug/build/codegg/<hash>/codegg-sandbox-helper`, which does not
exist, while `target/debug/codegg-sandbox-helper` did. A fixture that
asserts a launch must not depend on where cargo decided to put the test
executable, so the path is now the first existing candidate: the profile
directory, the deps directory, then the workspace target directory. A
missing sidecar still fails the test, and the panic lists what it tried.
The previous commit recorded the measured ratio rather than its
ceiling-rounded value, so the guard read 0.1327 against 0.1327 and
failed. Recorded as 0.1328, which is what `--bank` would write.
Both new fixtures failed on the same thing and it was not the narrowing:
`> /dev/null` was denied because the fixture built a read-only spec from
the read allowances alone. Device nodes are writable under every profile
- `/dev/null` is how a shell discards output - so the spec now carries
`device_write_allowances()` exactly as the product does. The failures
that remain, if any, are about `/proc`.
…CI red

WP B and WP C are done and the property is proved by hosted run
43532152355: 6/6 grant fixtures, including the /proc denial with its
positive control, the toolchain matrix under the narrowed set, and the
ABI-6 assertion. The closure record's criteria 5, 6 and 7 move to met,
and the security section states the two residues the mechanism leaves -
a child's own /proc/self, and pathname AF_UNIX sockets.

The record also carries the finding the A/B produced: ci.yml is red on
this branch on Linux because test_h006 fails identically on a976f7f
and on its pre-narrowing baseline fe98d86, before the sweep runs. That
is the harness line's, not the narrowing's.
Each decision is recorded in the record that needed it, with the options
weighed in `plans/closure/five-line-closure-corrective/002-owner-decisions.md`.

- **001 -> closed.** Criterion 6 accepted structurally and amended to "no
  production rendering file changed as a consequence of M001": no M001-only
  diff ever existed and the tree is one commit, so the original wording
  cannot be read.
- **008 -> closed.** Criterion 4 accepted at 8 of 10 and amended in the plan
  and the roadmap; `dialog_area` and `sidebar_area` are a registered
  follow-up, not a condition. The characterisation matrix's before/after
  claim is accepted on the same structural ground.
- **003 -> closed.** Criterion 1 amended for the `permission.rs` title-badge
  exception, with a `Section` title adjunct registered as a follow-up; the
  corpus diff-note substitute accepted in writing.
- **002 stays conditionally closed**, and that is the decision working: the
  substitute's third leg was accepted in prose, and implementing it -
  `the_minimum_hosted_size_keeps_a_readable_content_row` - showed that
  `HelpDialog::render_into` reserves 3+3+Min(1)+3 rows and paints no content
  at a 20x6 host rect. The assertion is committed `#[ignore]`d with the
  record named, because it measures a defect rather than passing over one.
- **helix 001 and 002 -> closed.** The `space ?` box now reads
  `d / Alt-d / y` and carries `_ - trim the selection to whole lines`, so the
  two verbs a Helix user reaches for are discoverable where they look.
- **helix 009 -> closed.** The single-chain prune is ratified as implemented,
  and it is now disclosed: `history_trimmed` paints
  `- history trimmed at its bound` while the last edit pruned. Derived, not
  latched - an edit that does not prune clears it, and `clear_history` clears
  it with the fallback flag.

Three follow-ups registered in the registry's deferred section: the last two
frame-geometry fields, a `Section` title adjunct, and Help's degradation at
small hosted sizes.

Verified: `scripts/verify.sh quick` (QUICK_RC=0), the editor and help suites
423 passed / 1 ignored, and the render corpus 1237/0 - the keymap edit moved
no recorded frame.
FULL_RC=0 on the decision tree: 17,382 workspace tests (11 skipped) and
8,446 feature-pass tests (6 skipped), 0 failures. The two extra tests are
the ones the decisions added, one of them the ignored Help 20x6
measurement that keeps tui-modularity/002's condition honest.
H006 hashes the workspace while a background job atomically replaces a
manifest under job-check/.codegg. That temp file is product bookkeeping,
not candidate source, and a path that vanishes mid-read is omitted. The
error path also no longer reads tool_updates before the prompt returns.
The hosted H006 job dies 134ms into a sandboxed `cargo test` with
`filesystem_write_failure` under `job-check/.cargo-target`, and the
sanitized receipt could not say more than that. Two gaps made it
undecidable:

`_H006_OS_ERROR_KINDS` is a closed map of eight errno values, so an
error number outside it was dropped and left "a write failed" as the
whole finding. The number is a syscall code, not file content, so an
unrecognised value is now recorded instead of discarded.

`cargo_build_script_artifact` reads as a build-script write, but Cargo
1.100 compiles every target under
`<target-dir>/debug/build/<pkg>/<META>/out/`, so that component is the
artifact layout and the fixture crates have no `build.rs`. The artifact
kind is now classified by the final component's extension alone, so a
random rustc suffix or a hash never reaches the projection.

The observation count had no margin either: `job wait` reports a status
only when the job reaches a terminal state inside its window, so a
bounded wait that times out contributes no `running` sample and the
assertion had exactly two chances. A third write and a third
observation give it one, with a write between every adjacent pair so the
intervening-write check holds for whichever pair reports `running`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant