Skip to content

The pre-edit block names a decision and its source - #162

Merged
zlareb1 merged 17 commits into
mainfrom
feat/for-file-decision-line
Nov 2, 2026
Merged

zlareb1 merged 17 commits into
mainfrom
feat/for-file-decision-line

Conversation

@zlareb1

@zlareb1 zlareb1 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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 pre-edit block from memory.for_file heads a decision row Decision (by <author>, <age>), prints its value as text, ends it with — source: <source_resource_id>, and marks a decision not pinned or attested (unconfirmed) and one whose recorded outcome failed (outcome: failed). Each hit carries source_resource_id, its verification state (as on memory.get), value_truncated (as on memory.list) and, for a superseding hit, the kind (rule or decision) it supersedes.

Why

A design decision in a repository's code namespace reached the pre-edit hook as Team rule (by …) [decision]: <stored JSON>: an agent about to edit the file could not tell a pinned decision from a draft, see that its outcome failed, or cite the document it came from.

Scope and risk

  • Lines. A decision is a row typed or tagged decision (decision_schema.is_decision, which the refusal below uses too); (outcome: failed) applies to decisions only. A team decision is headed Decision; in the caller's own namespace it is marked [decision]. Its source follows the value with its own 120-character cap, so the value's 220-character cut never reaches it, and a line that does not fit the budget is still left out whole. (unconfirmed) means not pinned and not attested against the row's current hash (memory.verify); a stale attestation does not count. Rows that are not decisions get none of these marks (their values are printed as text, below).
  • Values as text. memory.set stores a value as JSON, which the block used to print as is (quotes, \uXXXX escapes). The block now decodes it for display, for every row: a string value the select cut at 600 bytes (the hit's new value_truncated) is decoded from its opening quote up to the cut, without an escape or half a surrogate pair the cut split, and ends in … (escaped non-ASCII decodes to far fewer characters than the line holds), and a lone surrogate a value holds prints as ?. The hit's value field stays the stored JSON text.
  • Superseding. A newer team row the conflict check linked to an older one of its type is placed above it and names the older row's kind. Two typed decisions are never paired: since the decision-record change, the conflict check links close decisions under different keys as conflicts, and each key is its own decision. A rule may supersede a row tagged decision.
  • Verification state. trust.row_verification (shared with memory.list) derives the state from the stored hash, or from the value's hash when the selected value was not cut.
  • A pin is the row's flag. (pinned) shows the row's pin. A code-namespace member can set it on a row they write there (memory.set with pinned=true is stored as given), so a pinned team row is not on its own proof a maintainer confirmed it; the docs say so. Refusing a member's pin is left out of this change: it is an access change of its own, since a maintainer's memory.pin re-records the row under the maintainer (taking it from its author, with the fields the pin passes) and memory.update keeps a pin over a changed value, and both need settling with it.
  • Refusal hint. A code-namespace member may call only memory.set, memory.update and memory.delete there, and a newer rule is never shown above a typed decision. So a member refused on someone else's typed decision is sent to its author (who can delete it) or a maintainer (who can record the corrected decision with decision.record and delete the old row): memory.update would change the row and not the decision's record, which the next decision.outcome writes back, and the block's footer names the steps for what it holds: a corrected rule for rules and tagged decisions, and asking a maintainer to record the corrected decision with decision.record for typed decisions (the footer of a block of typed decisions only reads A team decision wrong or outdated?). The hint carries the row's kind (decision for a row typed or tagged decision, as the block calls it), which the 403 message names; a row only tagged decision keeps the rule steps, since a newer rule supersedes it.
  • Not in this change. The loom-memory skill still describes team rules only; how an agent writes a design decision is left to the change that extracts decisions, which bumps the plugin manifests. The hook change here is a comment, so no manifest bump.
  • Read path, plus the refusal wording for a member's write on someone else's decision: no write, auth or tenant-isolation change; the extra namespaces are still gated by row_in_scope.

Compatibility, rollout and rollback

  • Wire: four additive output fields on each hit: source_resource_id, supersedes_kind (rule, decision or empty), verification (as on memory.get) and value_truncated. The rendered text changes: decision lines as above, every value printed as text, and the removal footer names the steps for the rows it holds and says maintainer (it said admin). A refused member write's hint gains kind, and on a typed decision has a one-step next.
  • Operator steps: none; both builds read the same schema.
  • Rollback: revert; nothing stored.

Tests

  • tests/unit/test_memory_for_file.py and tests/unit/test_file_rules_shared.py (decision and rule fixtures of the new tests in the stored JSON form): the head, source and its cap, (unconfirmed) with pins, attestations and stale ones, (outcome: failed), non-ASCII values printed as text, a value the select cut decoded through the handler (fails without passing the cut flag), cuts inside a surrogate pair (fail without the guard), two linked typed decisions not paired, a rule superseding a tagged decision, the footer, the budget. tests/unit/test_code_member_writes.py: the decision refusal hint names the author and not an op a member cannot call (code_member_may_write refuses decision.record), the 403 message names the decision and its one step, and a row only tagged decision is named a decision with the rule steps. A CJK value cut by the read ends in … (fails without it); a rule tagged decision:failure gets no failed-outcome note. A lone surrogate in a whole value prints encodable.
  • tests/integration/test_memory_for_file_decisions.py, test_memory_code_links.py and test_decision_record_source.py against a server from source on a private ClickHouse at 049f3821: 198 passed, and the long recorded-decision case failed its new value_truncated assertion (its statement was under 600 bytes); with that statement lengthened, the file passes against the same server (3 passed). Since then only the footer wording, helper signatures, comments and unit tests changed. The cases include decisions written through memory.pin / memory.set and attested through memory.verify, a decision.record row whose whole rendered line is compared, and one whose statement is past the 600-byte cut (value_truncated true), printed with no quotes or escapes and ending in ….
  • Rebased onto main c0340084 (adds mentor.brief's graded-run report; clean rebase, generated files current): at the head ed0f4816, the for-file, member-write, file-rules, mentor, SDK, package-contract and doc tests and tests/analyzer, 826 passed, 2 skipped; the head 7a6aa15a rewords the footer's decision step, and the for-file, file-rules and member-write tests pass there (80).
  • At dadbcecf: test_memory_for_file.py, test_code_member_writes.py, test_file_rules_shared.py, the package-contract, doc and copy checks, 284 passed; the head 87f6f102 changes one footer condition, and test_memory_for_file.py with test_file_rules_shared.py pass there (59); node --test integrations/claude-code-plugin/tests/file-rules-team.test.mjs and agent_plugin_sync --check pass. Full tests/unit at dadbcecf: 24,498 passed, 20 skipped, 1 xfailed.

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; the rendered lines were checked against a live server.

  • 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 (see Tests); 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 force-pushed the feat/for-file-decision-line branch from b0977ad to 800e2cd Compare November 2, 2026 00:15
zlareb1 and others added 16 commits November 2, 2026 03:01
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t block

The conflict check links close decisions under different keys as
conflicts; each key is its own decision, so _supersede_order pairs no
two typed decisions. A rule may still supersede a decision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
memory.for_file decodes the stored JSON for display (a cut string from its
opening quote), and a decision tagged decision:failure carries
(outcome: failed). live_sha256 takes the value's JSON text. The footer
reads 'a corrected one' for rules and decisions; the docs say what
(unconfirmed) counts and that two linked decisions do not supersede.
An integration case reads a decision.record row back through
memory.for_file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…hint says decision.record

The handler passes each row's cut flag to the renderer, which drops half a
surrogate pair a cut leaves. The decision tag names live in
decision_schema. A member refused on another's decision is told to record
it again. Integration cases read decision.record rows, short and past the
600-byte cut, back through memory.for_file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… value was cut

A code-namespace member cannot call decision.record, so the refusal hint
and the footer send them to the decision's author or a maintainer, and
the 403 message names the row's kind. Each for_file hit carries
value_truncated, as memory.list does, which the renderer reads. A lone
surrogate in a whole value prints as '?'.

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

The hint carries the row's kind, which the 403 message reads, and calls a
row tagged decision a decision as the pre-edit block does. The decision
step and the footer both say 'record the corrected decision'. A test
pins the 403 message; a duplicate cut-value test goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A value the read cut can decode to fewer characters than the line holds
(escaped non-ASCII), so the decoded text ends in '…'. is_decision lives
beside DECISION_TAG and both the pre-edit block and the refusal use it;
(outcome: failed) applies to decisions only. Tests cover a CJK cut and a
refusal on a row only tagged decision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A pin is how a team decision reads as confirmed in the pre-edit block,
and the member rule already promised members no pin; memory.set now
refuses pinned=true for a write the member rule admitted. The fallback
and back-off in the value decode say why they are there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Refusing a member's pinned memory.set is an access change of its own (a
maintainer's memory.pin takes over the row, and memory.update keeps a pin
over a changed value), so it is left to a change that settles both. The
docs say a pinned team row is not on its own proof a maintainer confirmed it.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… is_decision once per line

memory.update changes a decision's row and not its record, which the next
decision.outcome writes back, so the hint names memory.delete for the
author and decision.record for a maintainer. The block computes whether a
row is a decision once per line; is_decision takes any collection; the
supersede skip trusts the conflict check's one-type links; update.py uses
CONFIRMED_STATES.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A block's removal footer names the rule step for rules and tagged
decisions and the maintainer step for typed decisions, and says
maintainer as the refusal hint does. The typed-decision test is one
spelling (memory_type == decision) in the block and the refusal; the
long recorded-decision test asserts the cut happened.

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

A block holding only typed decisions is headed 'A team decision' and its
step names the author too, as the refusal hint does. The supersede skip
reads KEY_IDENTIFIED_TYPES, the rule the conflict check applies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…are keyword-only

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]>
@zlareb1
zlareb1 force-pushed the feat/for-file-decision-line branch from 87f6f10 to ed0f481 Compare November 2, 2026 03:04
@zlareb1
zlareb1 merged commit 2bcfd9d into main Nov 2, 2026
17 of 18 checks passed
@zlareb1
zlareb1 deleted the feat/for-file-decision-line branch November 2, 2026 03:10
@pufit pufit mentioned this pull request Nov 2, 2026
9 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