Repository navigation
Merge the production line: core pin, refusal hardening, attach checks - #32
Merged
Merged
Conversation
The snapshot rule refused any path with a directory named u-boot, atf or qemu. Those names came from one umbrella checkout where vendored copies sat beside the live sources; applied to every write path, the rule refused an attached u-boot/ tree and a build/meta-qemu/recipes-qemu/qemu/ recipe in projects whose own source they are. A benchmark task that edits a qemu recipe could not be done, and u-boot patches were pushed off the documented workflow. A snapshot is now a .back or .pristine tree wherever it sits, or a .0 tree beside the live tree it copies (rootfs.0 next to rootfs, not zynq-rev1.0), plus build/tmp as before. The refusal says "snapshot copy".
The project's own validation ran, and its failure earned the one repair pass, only when a file tool (patch, write_file, delete_file) had changed something: its trigger and its cache key were the working state's mutation generation, which terminal commands never advance. A turn that changed source only through `sed -i` or `git apply` was never validated by the project's command, could end VERIFIED on the model's own passing check while that command would fail, and a repair made through the terminal was judged on the stale failure of the state it had fixed. judge() already computes the final source epoch from every tool's evidence; it now keeps that epoch and the files it changed on the context, and the project validation runs when they are non-empty and is cached per (generation, epoch). No new loop: a genuine failure on the final state makes the existing single repair eligible. In the FT-0 baseline no run had a configured validation, so the defect did not change those verdicts; ib-recipe-edit run 2 changed a tracked recipe through git apply alone and ended NO_CHANGE.
The sidebar used the plain mark, without the line of text cut into the specification, so it did not match the logo on the landing page. That line was left out below about 48 px, where it is sub-pixel; the sidebar shows the mark at 48 px, where it is 3 px tall. gen_identity.py now also writes spear-mark-detailed.svg, the landing mark on its own, for html_logo; the favicon keeps the plain mark.
Nothing kept git's own state out of reach. target_policy had no git class, the legacy append_file and write_file asked no policy at all and delete_file asked only about snapshots, and any program the command policy does not model ran with the whole tree bound read-write. write_file, patch, delete_file, a redirection, a script, a make rule or `git add 2>&1` could all change .git/index, HEAD or config, a submodule's .git file and the git directory it names. SPEAR itself never writes there; the only git commands the policy means to let write are clone, fetch and pull. target_policy now refuses git metadata: a .git component, file or directory, and anything inside a git directory reached another way (the one a .git file names, a bare repository), judged on the path as written and on its realpath. The legacy native tools (edit_file, write_file, append_file, delete_file, fetch_url's save_as) ask the same policy as the core's ports; a link to delete is judged as itself. The boundary that holds whatever the program is the kernel's: for a command granted workspace write, the sandbox binds every .git and the git directories .git files name back read-only over the writable tree, at the path the tree has inside. write_protection.py finds them with a walk that reads directories only, skips build/tmp, downloads and sstate-cache, and is cached per root until the root changes or a clone ran. git status, log, diff and show still run; clone, fetch and pull keep git writable.
target_policy was consulted only at the core's write and delete ports and on the shell destinations a static parser found, while any program the command policy does not model ran with the whole tree writable. A marker file, a generated tree, build/tmp or a snapshot copy refused to patch and write_file was still reached by `patch -p1 < x.diff`, `git apply x 2>&1`, a heredoc then `python3 /tmp/x.py`, a unittest helper, an executed script, a make rule, `echo P>>t`, `F=t; echo >> $F` and `cp src dir/`. The boundary is now the kernel's. For a command granted workspace write, the sandbox also binds read-only the protected files the command reaches: those its words name, those named in the files it runs or feeds (the diff, the script, the tests a runner discovers, a heredoc) and every file refused earlier in the session. Unless the command builds or tests (make, cmake, ninja, bitbake, a build.sh, a compiler, a test runner, as the command policy now tells them apart), the generated and snapshot trees found by the cached directory walk are bound read-only too. A build keeps writing its output, which is how generated files legitimately change; only the files its own words name stay protected. No file is read for markers beyond those the command names: on a 37k-directory tree the walk takes about half a second warm and the argv gains about twenty mounts. The parser refuses earlier and more clearly: a newline ends a stage, `x>>t` is read without its spaces, `2>&1` and `>&2` are not file writes (they had granted `git apply` a writable tree), a `$VAR` destination is the literal value assigned before it or earns no write, and `cp src dir/` is judged on dir/src. Markers no longer push legitimate edits into those bypasses: one counts only in a comment within a file's first ten lines, not in prose such as the help text in Linux's init/Kconfig, and a saved Kconfig configuration (defconfig, *_defconfig) is a source despite its "Automatically generated file; DO NOT EDIT." header. A patch's added lines still never count.
A build lost the generated trees it writes when it was not recognised as one: `updiff.sh` was not a build driver, and `timeout 600 bitbake`, `nice make` or `bash -c '. ./env.sh && updiff.sh linux'` read as an unknown program. The sandbox then bound build/tmp read-only under them, and BitBake died on "Read-only file system" in 15 of 69 benchmark runs, updiff.sh in most of them. The classifier had the opposite hole: `timeout 5 rm -rf x` was one unknown program granted workspace write, the rm never seen. timeout, nice, env, nohup, exec, command and time are now read through their options to the command they run, and `bash -c` / `sh -c` through their script, recursively, before anything is judged: the danger scan, the capabilities, whether the command builds. A launcher this cannot read is refused rather than trusted: an option it does not know, `env -S`, words after a -c script (its $0, $1...), a script the outer shell expands (`bash -c "$(cat x)"`; single quotes pass it as written) and, inside a script, a program that is an expansion. updiff.sh joins build.sh, configure and autogen.sh as a project build driver. A build's authority over the generated trees is now its own: every other stage must write nothing (builtins, readers, `tee` to a file outside those trees) and no redirection may write into them, so a write beside a build or inside the same wrapper gains nothing from it. The new tests run a synthetic updiff.sh and build.sh through ten launch forms in the sandbox, writing build/tmp, a generated directory and the recipe patch, and twenty wrapped or piggybacked writes to the same trees, which stay refused. Run against the previous policy, eleven of the launch forms fail as the benchmark runs did.
`git add`, `checkout`, `restore`, `stash` and `clean` had no write of any kind: as a simple command they were refused, and in a pipeline they got a read-only tree, so every one of them died on "Unable to create '.git/index.lock': Read-only file system". The benchmark hit it in ten runs; the earlier diagnostic run already had in five. Opening .git to any command whose text starts with git would have let a hook, an alias, a redirection or a `--work-tree=.git` write git's state too. A git command now keeps its own repository's records, and only those. The repository is the one holding the directory the command runs in, followed through its cd and -C steps, and through a .git file to the git directory it names and that one's common directory, all canonically, never outside the declared roots or from inside git's own state. Those git directories alone are left writable for that command; another repository's stays read-only, a nested one included, and one under a read-only one is bound writable again after it. Only when the command is git's alone and run as itself: every other stage reads, nothing writes a file, substitutes, defines a function or sources a script, no -c, --git-dir, --work-tree or interactive form, no GIT_, HOME, PATH, LD_ or editor variable in the command or exported by the session, and no writable directory ahead of the system's git on PATH that holds a git (or could before a second git command runs). What git changes in the worktree stays under the target policy: a protected file it names and the generated trees are read-only under it. Clone, fetch and pull no longer open every repository: clone needs none, fetch and pull get their own. The `-C` and global options are now read before the subcommand, so `git -C dir log` is read-only rather than refused. `reset`, `commit` and `config` keep no records. The new tests run real git in a disposable repository through the coding core's terminal: add, stash and pop, checkout, restore and clean succeed; a submodule and a linked worktree whose .git file names its git directory the long way keep their own index and leave the superproject's untouched; a generated file and a marked file stay as they were under checkout and restore, and clean -ffdx removes neither a generated file nor a nested repository; fourteen escape routes (--git-dir/--work-tree, GIT_DIR and GIT_WORK_TREE inline, through env or exported, -c core.hooksPath and its exported GIT_CONFIG_PARAMETERS, a git shadowing the real one on PATH, HOME, cd .git, -C .git, -C and cd outside the roots, a bash -c wrapper, a second git stage) leave .git and the outside repository unchanged. With the steering checks disabled, thirteen of them change .git.
The Hermes matching chain falls back to strategies that strip leading whitespace or accept merely similar lines. In a unified diff the first column is a marker: '+' lines sent without their '+', or a ' ' context line sent empty, still matched, and the replacement dropped or grafted the markers -- a corrupt patch reported as a successful edit. The same similarity let diff-prefixed text match plain C and write the '+' into the source. patch_guard wraps the unmodified chain: when it matched through a non-exact strategy, diff content is refused (exact matches only), and so is any match whose aligned lines differ by a leading '+' or '-'. Behaviour change: editing a .patch file now needs the lines verbatim.
The Hermes streak guard only appends a note, and its hard stop is reserved for non-interactive platforms; the core runs as "cli", so a model wrote the same one-line file 486 times, each call succeeding with a byte-identical result, until the round budget ended the turn. RepeatBreaker sits beside RefusalBreaker: four consecutive calls with the same tool, canonical arguments and identical successful result end the turn as halted (stalled), with a repeated_success_stopped trace event carrying reason repeated_success_loop. Failed and refused calls, any other call in between, a changed result and pollers reset the count. The answer says it is a safety stop, never a completion; the verdict stays the evidence's. Over 242 frozen benchmark runs the limit would have stopped 9, all loops, and no run that had not already done its work.
`. ./env.sh && build.sh linux` on an edgem1 virt64 tree peaks at 2.9 GiB and 111 tasks (bitbake plus a parallel kernel make). Under the 2 GiB cap the OOM killer took the whole sandbox after about 70 s; the session wrapper's output went with it, and the model read exit -1, no output and "bubblewrap sandbox command failed". The memory cap is now 6 GiB, twice that build; swap stays 0, the task and CPU caps are unchanged, and the docker launcher mirrors the new value. A sandbox killed by SIGKILL under an active contract now reports the limits instead of a bare failure, so the model can run less in parallel rather than retry blind.
The watchdog cancels a turn after 300 s without a token, a notice or a printed result, and nothing in between counted a running command: a `build.sh linux` the sandbox was allowed to run for 600 s was interrupted at 300 s with exit 130, its output lost. A command now holds the heartbeat until its own timeout plus 30 s; past that the silence counts again, and the sandbox's own timeout still ends an overrun.
A sandbox the cgroup kills takes the session wrapper with it, so the command's output never reaches the trailer. The wrapper writes it to a file under /tmp, which is a host directory bound for the session and survives the kill: the sandbox now returns that file's tail with the kill reason, instead of no output at all.
…e refusals Control-plane metadata. A tree's fingerprint beside the directory it describes (name.sha256, name.<tag>.sha256 and the like) is refused to every mutation tool, to a shell write naming it, and is bound read-only under any command that does not build. A build, which owns it, still writes it. Interpreters and wrappers judge the effective operation: - dash, ash, ksh and the other shells, perl, ruby, node, php, lua, tclsh and versioned pythons are refused as python and bash are; - every shell's -c script is judged as its commands; - a shell given a script file stays refused, but `sh -n script` (a syntax check) runs; - xargs is a launcher: the command it runs is judged; - find -exec/-ok judge their command, -delete and -fprint* are refused on the session-script path too; - an awk program that starts a command is refused; - a test module written since SPEAR started that runs processes or removes or renames files is refused to the test runner. False refusals: - a write whose destination is only known at run time no longer counts every file under a mentioned directory (or the directory a stage cd's into) as a target; only a writer fed from a walk reaches inside; - a process substitution is a stage, and the words after it are operands; - a relative `..` redirection is refused as the unverifiable path it is, not as a write it may not be. Each refusal the coding core sees now ends with its policy class.
Interpreter and script indirection, control-plane metadata mutation, an alternate working directory after a refusal, and the false refusals, each as policy semantics on a disposable tree; the end-to-end cases run in the sandbox. The protected-target matrix gains the fingerprint class and a build that writes its own. Every case fails on 62c1c6a except the working-directory one, which was already guarded.
A session takes the inventory of its trees when it binds its workspace: every path and every (device, inode). An object absent from both was created in this session, and the session may delete it as cleanup, by any route with the same authority: delete_file (a directory only when it and everything under it are the session's), rm, rmdir, unlink, find -delete, find -exec rm and a shell's -c script holding them. A start object never becomes the session's: recreated at its path, hard-linked, entered by a link, touched by a build. Git state, snapshot copies and control-plane metadata stay refused whoever made them. A removal this cannot read literally (a variable, a glob, a substitution, xargs, another program in the command) stays refused. A test run that imports a module written or changed in this session gets the trees read-only: whatever the module does, it reaches nothing the model could not reach directly. The source-pattern check it replaces let a wrapped script's writes through.
The inventory semantics, the A-G cases of session cleanup through every route, links, `..` and another working directory, removals that cannot be read, and the wrapped-script defeat of the LOW arm through unittest, discover -p and a module by name, against a harmless test and the project's own. A test session now takes its inventory when it starts, as a session does.
The stage splitter honours a backslash inside double quotes and a comment at the start of a word, judges command substitutions inside quotes and backquotes, and refuses quoting it cannot read: python3 -c "..." with escaped quotes no longer reads as shell syntax. A guard's override switch (IB_FORCE_ATTACH) is the operator's, set by no command, export or written configuration line. The walk up to the root ends on "//". git clean removes only what delete_file would, listed first with -n; a script written this session is not sourced. An editor run from the shell is refused like sed -i; a file of the start state is overwritten only through write_file or patch; a program the session built or rewrote runs with the trees read-only. A refused deletion names the object that decided it.
Every spelling of an inline program, the override switch, the walk from "//", git clean by provenance, sourcing, shell editors, start-state overwrites and session-built programs, each with the routes that must keep working. The build-driver fixtures date the project's scripts before the session, as a checkout's are; the controls of the shell writers are files the session made.
Every <tree>.attach.* beside an attached tree is control-plane metadata, recognised by the tree beside it, not by suffix: the owner marker the V3 screen saw deleted is one. A command that changes the family is undone, whatever route it took; a build may write it, never remove it. After a successful updiff of exactly one attached tree, with a series whose patches all hold together, SPEAR records the tree as the state the series reproduces, the manifest the attach task itself writes: the guard then lets the next attach rebuild from the series, and the model still neither writes the manifest nor throws the override. What a build removes from the start state must be its own output -- build/tmp, generated/, ignored by the project, or absent from the attach's manifest; anything else is reported as a policy violation, and the attach state is put back.
The attach family by location (manifest, owner, a future suffix), by every route including git apply; attach, edit, updiff, trusted refresh, rebuild, the edit surviving, with no refresh after a failed or malformed updiff and the guard kept for an edit never updiffed and for another tree; distclean of build output, a source and the attach state removed by a build. The look-alike that is no longer one, and the session-made attach files the older tests now make as an attach would.
U-Boot ships its tools/lib and tools/common wrappers in the release archive, so the attach writes them and its manifest lists them, and ignores them as build output: make distclean removes them. An attached tree's object is the build's when the manifest does not list it or the tree's own .gitignore files, read without the project's, ignore it.
The task class was read from the request's words alone. A request that
named no subject the vocabulary knows ("Enable CONFIG_SCHEDSTATS in the
virt64 kernel configuration", "make U-Boot print ... before it loads
uEnv.txt") ran as GENERAL, and GENERAL is given no project rule, skill
or metadata: in an Infrabase tree, 8 of the 23 benchmark tasks never saw
the Infrabase rules.
The workspace already says what such a request is about. A registered
project that declares a family in projects.json now binds a request
that names no subject to its tree, as a bound standard binds one to the
document; a bound standard still wins. Rules and skills are then
selected by their declared scopes as before, deterministically and with
no model: an unregistered tree or a project without a family stays
GENERAL, and OpenCN keeps its own corpus rules apart from the generic
Infrabase tree's.
Both places that decide the class use it: the client's context
selection and the task controller's toolset record.
A successful updiff says what it captured, not that the series reproduces the tree. It skips a file with a patch chain and still succeeds, and SPEAR then recorded the attached tree as the state the series reproduces, which disarmed the attach guard for an edit no series held. The refresh now needs PERSISTENCE_VERIFIED: the recipe's pristine copy and its series, rebuilt in a disposable directory with the patch tool as do_patch drives it, compared with the attached tree. Anything that keeps the result from being established refuses the refresh, and the guard stays. Model input cannot steer the check. The pristine copy and the build-output rules are pinned when the session binds its workspace, only a build that rewrites a copy moves its pin, and ignore rules come from the pristine copy. A file both trees hold must be identical whatever its name, because the exclude list also hides real sources from an updiff. An empty file in the reconstruction and none in the tree are one state, the way diff -N writes a deletion; the reverse is not. Also record the context routing test in the public boundary's list, which its commit left failing.
A copy that appeared outside a build counted as new at the next build and was adopted. Now the state before the build decides, so such a copy stays unpinned and the check fails.
The pin looked for the project through build/tmp/work, which a start state does not have yet, so the rules stayed unread and every later refresh was refused on a real tree. The class file itself names the project.
The deployed checkout carried 28 commits main never got: the coding core pinned to core-v0.3.1, the hardening rounds V2 to V4 (substitutions judged, redirection targets resolved, git metadata read-only, git keeping its own records), the persistence check after an updiff and the attach-state refresh. Where the two lines met, both are kept: main's loop keywords and its rule that a mutating git subcommand needs write inside a script too, production's stricter git option parsing and redirect resolution. A redirection to a variable with no literal value earns no write, so main's loop test now writes to a named file; git apply is a write, so the descriptor test reads with git diff instead. The documentation keeps main's structure and gains the git-metadata paragraphs. The logo stays main's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The deployed checkout carried 28 commits main never got: the coding core
pinned to core-v0.3.1, the hardening rounds V2 to V4 (substitutions judged,
redirection targets resolved, git metadata read-only, git keeping its own
records), the persistence check after an updiff and the attach-state refresh.
Where the two lines met, both are kept: main's loop keywords and its rule
that a mutating git subcommand needs write inside a script too, production's
stricter git option parsing and redirect resolution. A redirection to a
variable with no literal value earns no write, so main's loop test now
writes to a named file; git apply is a write, so the descriptor test reads
with git diff instead. The documentation keeps main's structure and gains
the git-metadata paragraphs. The logo stays main's.