Skip to content

A decision's statement opens with its scenario, without a category slug or Scenario label - #180

Merged
zlareb1 merged 8 commits into
mainfrom
feat/decision-statement-plain
Nov 2, 2026
Merged

zlareb1 merged 8 commits into
mainfrom
feat/decision-statement-plain

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

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):

A decision's memory row now reads <scenario>. Decided <outcome> because <reasoning>. …, without the Category: sentence or the Scenario: label; the category stays on the record, in the key and in the decision:category:<category> tag.

Why

The statement decision.record writes to the memory row is what search embeds and excerpts and what memory.for_file prints before an edit. It opened with Category: <slug>. Scenario: <scenario>.: a slug and two field labels that say nothing about the decision and take the first characters of the pre-edit line. The scenario's own words are what a question about the decision shares with it, so the statement now opens with them.

Scope and risk

  • server/memory/domain/decision_statement.py::memory_value drops the category sentence and the Scenario: label; the scenario is its own first sentence. The outcome, reasoning, no-reason form, Rejected: and Realized: parts, their caps and their endings are unchanged.
  • STATEMENT_CATEGORY_CHARS and the slug cut points (_SLUG_BOUNDARIES) had no other use and are deleted; _clip no longer cuts at a slug separator; it cuts at a space or between two wide characters.
  • Budgets: the other caps are left as they are. The freed room is not given to another part, because each cap is sized for memory.for_file's 220-character line and the embedded excerpt; the statement is simply shorter, so that line now reaches further into the reasoning.
  • Category: unchanged on the record, in the key (decision_key(category, scenario)) and in the decision:category:<slug> tag that decision.precedents filters on. File detection reads the stored fields, never the statement, so it is unchanged.
  • Conflict check: two decisions whose fields other than the category match now have the same statement. A decision is key-identified, so such a pair is a conflict, never a merge or duplicate (unchanged rule, tests/unit/test_decision_ops.py::test_decisions_under_other_keys_only_ever_conflict).
  • Extractor restatement check: loom decisions extract searches the namespace with the candidate's statement for a confirmed (pinned or attested) decision under another key. A candidate whose scenario, outcome and reasoning match a confirmed decision filed under another category now reads the same and is skipped as already_recorded, nothing written (tests/unit/test_decision_extract.py::test_a_confirmed_decision_in_another_category_is_a_restatement); the category no longer goes into that query.
  • Stored data: existing decision rows keep their old statement until the decision is recorded again or given an outcome (decision.outcome rebuilds the statement too); nothing else rewrites them. Old and new statements sit side by side in search, which reads both as plain text. Re-recording such a row, or repeating its outcome, is not a restatement (see the break below). loom decisions extract searches with the new statement form, while a confirmed decision stored in the old form still embeds its Category: … Scenario: prefix, so its similarity to a candidate for the same decision can be lower: a reworded copy may then be recorded instead of reported as already_recorded, until that decision is recorded again or given an outcome.
  • Rolling upgrade: N-1 writes the old form, N the new. Nothing parses the statement, so either build reads either row. Restatement does not cross the two forms: memory.set compares the statement's bytes, so N-1 re-recording a row that N wrote, or N one that N-1 wrote, is a revision, with the effects in the break below. Either build's loom decisions extract can likewise miss a confirmed row stored in the other form and record a reworded copy, until that decision is recorded again or given an outcome.

Compatibility, rollout and rollback

  • Wire: no op or field changes. The value of the memory row a decision.record or decision.outcome writes changes shape.
  • Break: memory.set treats a write as a restatement only when the value's hash equals the stored row's (server/memory/app/write.py), and decision.record passes no pinned. Recording again, word for word, a decision whose row holds the old statement form is therefore no longer a restatement: a pinned row refuses it with 409 PINNED_CONFLICT until an admin runs memory.unpin (then memory.pin restores the pin); a row whose value is locked refuses it with 423 LOCKED until the lock ends or is released (the value lock is checked only for a write that is not a restatement); an attested row is revised and its attestation reads stale; an unpinned row gets a new version, a new embedding and the conflict check instead of a reinforcement. The same holds for decision.outcome, the statement's second writer: a word-for-word repeat of an outcome on an old-form row is a revision, refused with 423 LOCKED on a locked row and leaving an attested row's attestation stale; it passes the row's own pinned, so a pinned row takes it (no 409). No shim is added; each row moves to the new form the first time its decision is recorded again or given an outcome.
  • Operator steps: none.
  • Rollback: rows written by this build keep the new statement until the decision is recorded again or given an outcome. On the reverted build, re-recording one of them word for word (or repeating its outcome) is a revision, as in the break above: 409 PINNED_CONFLICT on a pinned row (decision.record only), 423 LOCKED on a locked row, and a stale attestation on an attested row. The reverted build's loom decisions extract can also miss a confirmed new-form row and record a reworded copy, until that decision is recorded again or given an outcome.

Tests

  • pytest tests/unit -p no:randomly on this branch rebased onto main: 25044 passed, 20 skipped, 1 xfailed.
  • make format lint typecheck: clean.
  • Against a private ClickHouse and a server from this branch (auth off, fake embedder and LLM): pytest tests/integration/test_memory_for_file_decisions.py tests/integration/test_decision_record_source.py: 5 passed (run before the rebase onto main; the rebase changed none of the code these tests reach).
  • test_decisions_that_read_alike_each_keep_a_live_row now uses a longer shared reason: with the short one, the test embedder's closeness between two such statements was decided by the key each embedded text ends with, and no pair reached the conflict threshold once the shared Category: … Scenario: prefix was gone. The test still asserts that every decision keeps a live row and that the conflict rule fired.

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 unit and integration runs above were checked.

  • 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. (The two touched integration files pass locally; the full integration suite runs in CI.)
  • Generated files are regenerated in this PR, not by hand: none are affected.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (No plugin file changed.)
  • The frontend builds and its tests pass, if frontend/ changed. (Unchanged.)
  • 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.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1 zlareb1 changed the title A decision's statement opens with its scenario, without a category or field labels A decision's statement opens with its scenario, without a category slug or Scenario label Nov 2, 2026
zlareb1 and others added 7 commits November 2, 2026 18:42
… field labels

memory_value built "Category: <slug>. Scenario: <scenario>. Decided ...".
The statement is what search embeds and what memory.for_file prints before
an edit; a category slug and the "Category:" and "Scenario:" labels are noise
to both. The statement is now "<scenario>. Decided <outcome> because
<reasoning>. Rejected: <alternatives>. Realized: <result>.", every other
part, cap and rule unchanged. The category stays on the record, in the key and in the
decision:category:<slug> tag that decision.precedents filters on.

The category cap and the slug cut points go with it, and _clip cuts at a
space only. The other caps are left as they are: the statement is shorter,
so the pre-edit line now reaches further into the reasoning.

The integration test of decisions that read alike uses a longer shared
reason, so the test embedder's closeness is decided by the statement rather
than by the key each embedded text ends with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ads from the statement tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t filed under another category

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…reason's start in the pre-edit line

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/decision-statement-plain branch from 65e3782 to 6f7396d Compare November 2, 2026 18:43
…other category

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 392df03 into main Nov 2, 2026
21 of 22 checks passed
@zlareb1
zlareb1 deleted the feat/decision-statement-plain branch November 2, 2026 19:08
@pufit pufit mentioned this pull request Nov 4, 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