Skip to content

Recalled memory, tracker titles and brief goals reach the agent in id-closed data blocks, and the plugin's temp files refuse planted links - #321

Merged
zlareb1 merged 20 commits into
mainfrom
sec/plugin-file-rules-fenced
Nov 7, 2026
Merged

zlareb1 merged 20 commits into
mainfrom
sec/plugin-file-rules-fenced

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The Claude Code and Codex plugins hand the file rules recalled before an edit, the issue titles the code shunt quotes and the saved-brief list to the agent inside recalled-data blocks whose closing tag carries an id only the install can compute, so stored text cannot end them, and the conversation flusher and the code-shunt hook no longer follow or read a symlink, hard link or another user's file planted at their temp files. The code shunt's decision log moves to $TMPDIR/loom-shunt-log-<hash of the uid>.log, and a shunt denial whose budget cannot be recorded now lets the call through. Plugins 1.2.9.

Why

  • Before each Edit or Write, the file-context hook emitted the server's memory.for_file text as raw PreToolUse context. That text includes the repository's team file rules, which every member of the code namespace may write, so a member's stored rule reached every teammate's agent as an unmarked directive right before an edit.
  • When the tracker record answered a gh issue list --search, the code shunt's deny text copied issue titles, which anyone who can file an issue writes, into the agent's context unfenced. The SessionStart primer's saved-brief line did the same with brief keys and goals, which in a shared namespace include other members' briefs.
  • recalledDataBlock closed every block with the same fixed tag and escaped only its ASCII spelling inside the text, so a stored </ loom-recalled-data>, or one spelled with lookalike brackets, letters or separators, could read as the block's end.
  • The code-shunt hook wrote its decision log ($TMPDIR/loom-shunt.log) and pending batch ($TMPDIR/loom-shunt-pending.log), each one name for every user, and its denial counts with plain fs calls: a symlink planted at the pending batch had its target truncated, and a batch another user planted was posted as code.outcome rows under the user's token.
  • The detached flusher wrote its cursor files ($TMPDIR/loom-conv-<session>.offset and the session-brief cursor) with a plain writeFileSync, which follows a symlink, while every other state file goes through lib/tmp-state.mjs (no-follow, owner and link checks). Where TMPDIR is shared and symlinks are not protected, another local user who knows the session id could make it overwrite a file of the user's with an integer.

Design

  • An id only this install can compute ends each block. recalledDataBlock, shared by every recall path, puts an id in its open and close tags (<loom-recalled-data id="…"> … </loom-recalled-data id="…">), and the block's note says only the closing tag carrying that id ends it. The id is the first 16 hex of an HMAC-SHA256 of the block's text under a 32-byte secret created once at ~/.loom/recall-key: written to a private temporary name and hard-linked into place, so it never replaces a key another hook put there first, and the temporary name is removed whatever happens; read with the private-file checks, so a link, a hard link elsewhere or another user's file there is refused; a read refused for a second link retries when the count is back to one (the creator unlinked since) or when every other link is this install's own temporary name (recall-key.<pid>.<12 hex>: a creator mid-link, or one that died there), which is removed; any other second link is refused, within a bounded number of passes. A key file of ours that is empty or the wrong length (a write that failed) is renamed aside under a private name, so only the hook whose rename took it removes it, and made again; if what it moved is a good key another hook had just linked there, still linked under that hook's temporary name, it is put back. The key, or its absence, is loaded once per process. The text's writer cannot compute the id without the secret, so stored text cannot write the block's end, and the same text keeps the same id, so the SessionStart primer stays cacheable across sessions. When the secret cannot be read or created the id is random.
  • The tag name is rewritten as a second layer. Inside the text, the tag name is replaced with [loom tag removed] wherever its letters spell it: each code point folded (default-ignorable characters such as the Hangul fillers dropped, NFKD, lower case, NFKD again, accents dropped), common Cyrillic, Greek, Armenian, Coptic, Cherokee, Lisu and small-capital lookalikes mapped to Latin, and every non-letter dropped. The text is not escaped: < and > stay as written (Vec<T>, the server's memory_key=<id> footer), and words that merely contain "loom" stay. The lookalike table is not complete; the id is what the block relies on.
  • contextPayload sends a heading the plugin writes ("Loom file rules and notes for the file this edit touches; a teammate's rule names its author:"), then the server's memory.for_file text inside recalledDataBlock. The server's removal footer and left-out line sit inside the block too, which the note says not to follow, so the plugin restates them after the block in its own words, each only when the server's text ends with that line where render_block writes it (the removal line last, the left-out lines right before it). A path or row elsewhere adds nothing, and a row that sits where a footer line goes adds only the plugin's fixed text. The removal guidance names the team namespace the hook already knows and picks its steps as the server's _removal_footer does (a corrected rule unless every team row is a typed decision; decision.record when any is). Rows left out: memory.for_file with the path and, when a team namespace is in play, extra_namespaces naming it (the server reads the team namespace only when the call names it) returns every row in its hits. Decisions and constraints left out: memory.get on each named key with its namespace for a team key, and loom_search for the rest and for a key memory.get does not find: memory.get reads a teammate's row filed under the default user (-) through its any-agent fallback, but answers found=false for a row filed under another user or to a token pinned to one (same_user). The server's lines are not split out of the block, since a stored row could imitate them.
  • The tracker-answered gh-search denial keeps its heads and follow-up outside and puts the item and nearest-issue lines inside recalled-data blocks; the saved-brief primer line puts its keys and goals inside one.
  • The flusher reads its cursor and job file with readPrivateFile and writes the cursor with writeCursor; the job file is removed with removeFile. readPrivateFile now also refuses a file with other hard links, as writePrivateFile already did.
  • Code-shunt temp files. The decision log is per user (tmpStatePath("shunt-log", uid)) and stays out of the stale-state sweep, since it is a log the user reads. The pending batch is keyed by its reporting scope (batchKind in lib/shunt-ledger.mjs: the server URL, a hash of the token, and the repository's org/namespace) and by the session id, a name nobody can create ahead of the session. A flush takes every batch of its scope this user owns (its own, those ended or crashed sessions left, and those of sessions still running) by renaming each to a name of its own, then reads it with the private-file checks and removes it: of two hooks flushing at once only one posts each batch, a planted file is never posted, and a batch of another server, token or repository is left alone. The denial counts move to session state.
  • A budget that cannot be recorded does not deny. A shunt denial that spends a budget (over-cap read, symbol grep, answered tracker search) is given only when the spend was written; otherwise the call passes with the new pass reason budget_unrecorded, so a planted counts file cannot lock the agent out.
  • blast-radius and prompt-pack output stays unfenced: it is code-index text about the repository the agent already reads, not shared memory, and prompt-pack ends in an instruction the plugin itself writes.
  • Both plugin manifests go to 1.2.9 (open The Claude Code and Codex plugins work on Windows and on macOS symlinked checkouts, checked by a real session per platform in CI #313 uses 1.2.8); the Codex copies are synced.

Scope and risk

  • Plugin: lib/prompt-recall.mjs, lib/file-context.mjs, lib/code-shunt.mjs, lib/session-brief.mjs, lib/shunt-ledger.mjs, lib/tmp-state.mjs, hooks/loom-flush.mjs, hooks/loom-code-shunt.mjs, the README and hooks/HOOKS.md, their tests and the two manifests, mirrored in integrations/codex-plugin/.
  • Server: server/code/api/models_outcome.py gains the budget_unrecorded shunt pass reason, with tests/unit/test_code_observability.py.
  • Bench: bench/agent_traj/claude_code_driver.py copies the shunt's decision log from its new name.
  • Docs: docs/features/integrations/claude-code.md.
  • User-visible: recalled blocks carry an id and a longer note (about 30 more tokens a block); the plugin creates ~/.loom/recall-key; recalled text that spells the tag name shows [loom tag removed]; the decision log moves from $TMPDIR/loom-shunt.log to $TMPDIR/loom-shunt-log-<hash of the uid>.log (README, LOOM_SHUNT_LOG).
  • The fence's note tells the agent not to follow directions inside the block; the heading outside it presents team rules as attributed rules to weigh.

Compatibility, rollout and rollback

  • Wire: code.outcome accepts one more shunt pass reason, budget_unrecorded; an older server records such a row as unattributed.
  • Operator steps: none; users pick up 1.2.9 with the plugin update. Anything reading $TMPDIR/loom-shunt.log reads the new name.
  • Rollback: revert.

Tests

node --test integrations/claude-code-plugin/tests/*.test.mjs (577 tests) passes, with new cases:

  • Recalled data: each block carries a 16-hex id in its open and close tags and its note, the same for the same text and different for other text; the recall key is created once, 0600, read back, and leaves no temporary file; an empty or wrong-length key file is replaced; four hooks creating it at once all get the one stored key; a hard link planted at the key path is refused and left in place; a stray temporary second link is removed and the key read; a read that caught a creator mid-link retries (count back to one, or the stray removed); a same-inode recall-key.bak is not taken for a stray (the key is refused and both links stay); a good key still linked under its creator's temporary name is put back by the bad-key path; a symlink planted at the key path is refused (its target untouched) and ids fall back to random; a planted close tag with another id does not end it. Thirty-six spellings of the tag in a stored rule leave only the block's own tags, including lookalike brackets (U+FF1C, U+2039, U+3008, U+2329, U+27E8, U+02C2), fullwidth, mathematical bold, modifier, script, squared and parenthesised capitals, mixed case, Greek capital mu and the micro sign, Cyrillic, Greek, Coptic, Cherokee and Lisu lookalikes, Hangul fillers, and a zero-width space, soft hyphen, U+02D7, U+2043, U+2500, underscore, space, dots, dash lookalikes or a combining accent inside the name. neutraliseTagName is tested directly; Vec<T>, a < b, memory_key=<id>, "heirloom" and "loom-data" stay as written.
  • File rules: built from the server's own line formats, the removal, budget left-out and decision left-out guidance follows the block in the plugin's words when the server's text ends with each line, and is absent otherwise; an all-decision footer points only at decision.record; a footer line in the path or among the rows adds nothing, and a row in the footer's place adds only the fixed text; the hook, run against a local server, passes the file's path and the team namespace through (the read-more line names extra_namespaces), and restates a left-out team decision line beside a "… more" line of ceiling-hidden rows.
  • Tracker answer and saved-brief line: the item lines and the goals sit inside recalled-data blocks, and a planted title or goal cannot close one.
  • Code shunt, run as Claude Code runs it: a deny claims, posts and removes the batch; a pass in session A is posted by session B's flush; a batch of another repository or another server is not posted and is left as it was; the read cap denies twice, then passes with cap_spent; with the counts file planted, an over-cap read, a symbol grep and an answered tracker search each pass as budget_unrecorded; symlinks planted at the log, pending batch and counts file leave their targets unchanged and the planted batch is never posted (the old hook posted it); a hard link planted at the pending batch is neither posted nor truncated.
  • Test hygiene: every plugin test file imports tests/temp-home.mjs first, which points HOME at a fresh temporary directory, so no test writes ~/.loom/recall-key into the runner's home; recall-key-home.test.mjs checks every file imports it first.
  • tmp state: a hard-linked file is not read as state; the stale-state sweep leaves the shunt's decision log.
  • Flusher, run against a local HTTP server: it advances a plain cursor and removes the job file, leaves a symlinked cursor's target untouched (the old hook wrote 42 into it), and on a failed post rolls back a plain cursor while leaving a symlinked one alone.

claude plugin validate, agent_plugin_sync.py --check, node --check, biome, prettier, ruff, and tests/unit/test_code_observability.py, test_code_plane_ablation.py, test_codex_plugin.py, test_doc_links.py and test_public_copy.py pass.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. I verified both defects by reading the hooks and read the diff and its tests.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1 zlareb1 changed the title File rules reach the agent as fenced recalled data, and the flusher refuses a planted cursor symlink Memory file rules reach the agent fenced and escaped, and the flusher and code shunt refuse planted temp-file symlinks Nov 6, 2026
@zlareb1 zlareb1 changed the title Memory file rules reach the agent fenced and escaped, and the flusher and code shunt refuse planted temp-file symlinks Recalled memory, tracker titles and brief goals reach the agent in id-closed data blocks, and the plugin's temp files refuse planted links Nov 7, 2026
zlareb1 and others added 20 commits November 7, 2026 08:20
…efuses a planted cursor symlink

The PreToolUse file-context hook now wraps the memory.for_file text in the
loom-recalled-data block under a plugin-written heading, like every other
recall path: team file rules come from a namespace every member writes, and
a closing tag inside a stored rule is escaped so it cannot end the block.

The detached flusher reads and writes its transcript cursor and job file
through the tmp-state private-file helpers (O_NOFOLLOW, owner and hard-link
checks) instead of plain fs calls, so a symlink planted at the cursor path in
a shared tmp dir is refused and its target left unchanged.

Both plugin manifests move to 1.2.9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…and file rules escape every tag

The code shunt's decision log, its pending batch and the per-session read-cap
counts were written and read with plain fs calls at fixed or session-derived
names in $TMPDIR, so a planted symlink sent appends to another file, the flush
truncated the target, and a batch another user planted was posted as
code.outcome under the caller's token. They now go through lib/tmp-state.mjs
(O_NOFOLLOW, owner and hard-link checks): the batch and the cap counts move to
tmp-state names, and the log keeps its documented name.

memory.for_file does not escape stored text, so the file-context hook escapes
`<` and `>` before fencing it; a spaced, zero-width or fullwidth closing tag
can no longer end the block. The heading says only a teammate's rule names its
author, and the Claude Code page names the file-rules hook among the fenced
paths.

Code-index text (blast radius, prompt pack) stays unfenced: it is derived from
the repository the agent already reads, not from a shared memory namespace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…pending batch is per user

The file-context hook now folds the fullwidth (U+FF1C) and small-form (U+FE64)
look-alikes of `<` into `&lt;` with the ASCII one, so no spelling of a tag can
open or close inside the block. `>` is no longer escaped: a tag needs a left
bracket, and the server's `memory_key=<id>` footer stays readable.

The code shunt's pending batch is named per user (keyed on the uid), so users
who share a TMPDIR keep their own batches. The cap-count comment now says what
a refused cap file means: every over-cap read is denied for that session.

New hook-level tests: a deny flushes the batch as a code.outcome post and
empties it, and the read cap denies a file twice and then passes it as
cap_spent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… hard links

flushPending returns without posting when it cannot truncate the pending
batch, and readPrivateFile now refuses a file with other hard links, as
writePrivateFile already did: a hard link planted at the predictable batch
path can no longer re-post its target on every deny. Tests cover the read
check and the hook with a planted hard link; the planted batch in the shunt
tests is now a line the ledger parses, so a leak would show as a post.

The README and the cap-count comment name all three budgets the counts file
holds (over-cap reads, `sym:` symbol greps, `qa:` tracker searches) and say
that while the file cannot be kept every one of them is denied for the
session. The file-context escape adds U+226E, and its comment names each
spelling it folds into `&lt;`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…r titles are fenced, and the shunt claims its batch

recalledDataBlock now rewrites every spelling of `loom-recalled-data` in the
text it wraps (matched on a copy folded by case, compatibility form and
accents, with zero-width characters dropped and dash lookalikes read as `-`)
to `loom-recalled_data`, so no bracket of any kind can open or close the
block and `<` stays as written (`Vec<T>`). It replaces the closing-tag escape
and the file-context hook's own `<` escape; every recall path gets it.

The tracker-answered `gh issue list --search` denial puts its item lines,
whose titles anyone who can file an issue writes, inside recalled-data blocks;
the heads and the follow-up stay outside.

The code shunt's pending batch is per session, and a flush claims it by
renaming it to a name of its own before reading it with the private-file
checks and removing it, so two hooks flushing at once post it once. A denial
is given only when its budget spend was written: a cap file that cannot be
kept lets the call pass instead of locking the agent out. The session sweep
also removes the stale shared `loom-shunt-pending.log`.

Tests: tag spellings with lookalike brackets, fullwidth letters, case, zero
width, dashes and accents; `Vec<T>` kept; a planted issue title; the claimed
batch removed; the flusher's rollback leaving a symlinked cursor alone; POSIX
skips on the symlink tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…are fenced, and a shunt flush posts every session's batch

recalledDataBlock now matches its tag name on the letters alone: each code
point folded (NFKD, lower case, NFKD, accents dropped), Cyrillic, Greek and
small-capital lookalikes mapped to Latin, every non-letter dropped, then
`loomrecalleddata` looked for. Each matching span becomes `[loom tag
removed]`, so separators, homoglyphs and mathematical or enclosed capitals
cannot spell a tag either. The SessionStart saved-brief line puts its keys
and goals, other members' in a shared namespace, inside a block too.

The code shunt's pending batch is keyed by repository scope and session id,
and a flush claims every batch of its scope this user owns, so the last
lines of an ended session are posted by the next flush. A denial whose
budget spend cannot be written passes with the new pass reason
`budget_unrecorded`, added to the server's SHUNT_PASS_REASONS. The decision
log is per user (`loom-shunt-log-<hash>.log`); the bench driver globs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…re scoped to their server and token

recalledDataBlock draws a random id per call (crypto.randomBytes) for its
open and close tags, and its note says only the closing tag carrying that
id ends the block, so stored text cannot write the block's end. The
tag-name rewrite stays as a second layer: default-ignorable characters
(the Hangul fillers among them) are dropped before the letters are
matched, Greek capitals fold through lower case, and the lookalike table
gains mu, the micro sign and a few Coptic, Cherokee and Lisu letters.
TAG_SKELETON derives from the tag name, and neutraliseTagName is tested
directly.

The code shunt's batch scope (batchKind in lib/shunt-ledger.mjs) hashes
the server URL and the token with the repository, so a flush never posts a
batch of another server or token. The budget write for an answered tracker
search sits under its answer. The stale-state sweep leaves the shunt's
decision log alone and no longer names the old shared batch file. The
bench driver takes the first decision log the glob yields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he block, and the shunt's batch rides on repo

The server's removal footer and left-out line for memory.for_file sit inside
the recalled-data block, whose note says not to follow its text. The
file-context hook now restates them after the block in the plugin's own
words (fileRulesGuidance), with the team namespace it already resolved, and
only when the server's text has the line each restates. The server's lines
are not split out, since a stored row could imitate them.

The code shunt's pending batch is one value on `repo` (pendingFor) instead
of two module-level variables, the unreachable empty-path guard is gone, and
the comment says batches and claimed batches are swept with the other state
files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ts tests use the server's formats

The guidance after the file-rules block now tells rows the token budget
left out (memory.for_file with a larger token_budget) apart from decisions
and constraints left out at the ceiling (memory.get on the named key), and
says a corrected rule supersedes a wrong rule while a typed decision is
corrected only by a maintainer's decision.record.

Its tests use the server's own line formats, a path that imitates a footer
line adds only the fixed text, and a hook-level test runs loom-file-context
against a local server to check the path and the team namespace reach the
guidance. The shunt's unflushed line count is named `unflushed`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…es the server's wording

fileRulesGuidance now reads the server's footer from the end of its text,
the way render_block writes it: the removal line last, the ceiling's
left-out line before it, the budget's left-out line before that. A row or
a path that imitates one anywhere else adds no guidance. The removal text
uses the server's wording, the left-out rows point at memory.for_file
returning every row in its hits, and left-out decisions at memory.get on
each named key with its namespace for a team key.

HOOKS.md describes the heading, the per-call-id block and the guidance
after it. The hook-level tests cover a left-out team decision line beside
a "… more" line of ceiling-hidden rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… picks removal steps as the server does

The read-more guidance names extra_namespaces with the team namespace when
one is in play, since memory.for_file reads it only when the call names it.
The removal line's subject (rule, decision, rule or decision) is captured
and the steps chosen as _removal_footer chooses them: a corrected rule
unless every team row is a typed decision, decision.record when any is.
The left-out decisions line adds loom_search for a key memory.get does not
find, a row filed under another user.

Tests cover an all-decision footer, a member's row in the footer's place
(only the fixed text), and the hook-level removal line and extra_namespaces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… secret, so the primer stays cacheable

The block id is now the first 16 hex of an HMAC-SHA256 of the block's text
under a 32-byte secret created once at ~/.loom/recall-key (O_EXCL, 0600,
read with the private-file checks, so a link or another user's file there
is refused). The same text keeps the same id, so the SessionStart primer
is cacheable across sessions again, and the text's writer still cannot
compute the id. Without a usable secret the id is random.

The saved-briefs comment describes the heading, the fenced block and the
resume line and their cost, the shunt's budget_unrecorded reason is a
plain string constant, and the docs paragraphs touched are rewrapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…l key into the runner's home

Every test file imports tests/temp-home.mjs first, which points HOME at a
fresh temporary directory (removed at exit); the recall key path reads
HOME at call time. recall-key-home.test.mjs checks that every test file
imports it first, and runs the test files that build recalled-data blocks
in their own process under a fresh HOME, asserting nothing is written
there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… short, and a missing key is cached

A new key is written to a private temporary name and hard-linked into
place, so it never replaces a key another hook made first; a key file of
ours that is empty or the wrong length is removed and made again, while a
link, a hard link or another user's file is still refused. The loaded key,
or null when there is none, is kept for the process, so a refused key is
not retried per block. recallKeyPath takes os.homedir(), which honours HOME.

Tests: empty and wrong-length key files are replaced, four concurrent
creators end with one key and no temporary file, test directories are
removed when each test ends; comments describe the derived id; the
session-start primer test compares the block exactly; the nested six-file
run in recall-key-home.test.mjs is gone, the import check covers it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…, and a bad key is moved aside before removal

A read refused because the key has a second link retries when that link is
only this install's own recall-key.* temporary name (a creator between its
link and its unlink, or one that died there), removing it; any other second
link is still refused. A bad key is renamed aside under a private name, so
only the hook whose rename took it removes it, and a good key found there is
put back. The temporary copy is removed even when its write fails. The
shunt's claim name adds random bytes.

Tests: four concurrent creators all get the stored key; a hard link planted
at the key path is refused and left in place; a stray temporary link is
removed. USERPROFILE is set beside HOME, and noIds is one shared helper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…Key's names count as strays, and a just-linked good key is put back

clearStrayLinks replaces dropStrayLinks: after a read refused for a second
link it answers "retry" when the count is back to one or the key is gone,
removes only same-inode names of besideKey's shape (recall-key.<pid>.<12
hex>), then looks again, so a creator unlinking between the two looks is a
retry too; any other second link is refused. Reads go through readKeyText,
which clears those strays within KEY_PASSES. replaceBadKey reads the copy it
moved aside the same way, so a good key another hook had just linked there,
still linked under its temporary name, is put back.

Tests: the post-race states retry deterministically, a same-inode
recall-key.bak is not a stray (the key is refused, both links stay), and the
rescue of a just-linked key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…Links takes the key path explicitly

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…file-context footer

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the sec/plugin-file-rules-fenced branch from 69cee2e to 19621a5 Compare November 7, 2026 08:36
@zlareb1
zlareb1 merged commit db34392 into main Nov 7, 2026
37 checks passed
@zlareb1
zlareb1 deleted the sec/plugin-file-rules-fenced branch November 7, 2026 08:38
@zlareb1 zlareb1 mentioned this pull request Nov 12, 2026
3 tasks done
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