Skip to content

loom decisions extract links a document in any namespace to a named repository - #189

Merged
zlareb1 merged 28 commits into
mainfrom
feat/decision-extract-repo
Nov 3, 2026
Merged

zlareb1 merged 28 commits into
mainfrom
feat/decision-extract-repo

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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

loom decisions extract --repo OWNER/NAME links a design document kept in a person's or a team's namespace to a repository: its code names resolve in the repository's trunk index, and --into source (rows beside the document, tagged repo:<id>) or --into repo (rows in the repository's trunk namespace) chooses where its decisions go, so the pre-edit block serves them.

Why

The extractor looked code names up with code.symbol in the document's own namespace. A design document added with knowledge.add to a person's or a team's namespace has no code index there, so every decision was written with files: [] and never reached memory.for_file, the pre-edit path.

Extraction now takes the repository separately from the document's namespace (Target in server/memory/app/decision_extract.py: the document's namespace, the code namespace, the namespace rows go to and the tag they carry):

  • --repo is matched the way code.repos matches a checkout's remote (repo_slug), in the run's org, to the repository's trunk code namespace (trunk_namespace_of) and its repo:<id> tag (repo_tag, the tag the plugins compute, from whichever entry names the remote). Rows written into the trunk itself carry no tag. The new helper is repo_trunk in server/code/app/repo_scope.py.
  • --into source (the default when the document is outside a code namespace) writes beside the document with the repo:<id> tag; memory.for_file matches the caller's namespace with hasAny(tags, …), so the hook's [project:<p>, repo:<id>] body serves the row to whoever reads that namespace.
  • --into repo (the default for a document in a code namespace) writes to the trunk, where every repository reader gets it as a foreign row. source_resource_id still cites the document in its home namespace. There is no per-document access, so a repository reader who cannot read the document's namespace sees the quote but is refused the cited document; the CLI help and the feature page say so.
  • Every reconcile read (the key's live record, the row by identity, the restatement search, the extractor's own rows) and the retire step run in the namespace the rows go to; cites_document reads the document's namespace.
  • _same_row compares repo: tags as it compares the constraint tag, so the extractor's own unconfirmed row extracted before it had a repository is revised once to carry it. A row the run keeps as it is (pinned, attested or with a recorded outcome, or kept by the retire step because its reasoning is still in the document) gains the tag by the tags-only write that already sets or clears source-changed (_keep_tags, _flag, one write per row).
  • Reconcile and retire read one namespace, so before any model call the run refuses (exit 1) when this document's rows from an earlier run are in the other namespace a run may write them to (the trunk or the document's namespace; for a document in a release branch's code namespace run without --repo, its trunk), or when they carry another repository's repo:<id> tag (any, for a run without --repo). Going on would leave the document's decisions in two places, or linked to the wrong repository. The feature page names the two cases the check cannot see (rows an --into repo run wrote, when a later run on a document outside any code namespace drops or changes --repo; two concurrent runs with different --into). Moving rows between namespaces is left to the operator (memory.delete there, then a re-run).
  • No --repo: unchanged; the document's namespace is all three.

Scope and risk

  • Access: the run reads the document's namespace and the repository's trunk (viewer) and writes where rows go (writer; viewer for a dry run), through row_in_scope, which fails closed (_may turns a failing check into a refusal). The CLI runs in-process with no auth context, so as before the operator passes every gate; the checks bind as soon as a caller with an auth context runs the function. There is no op for extraction today, so no wire surface changes.
  • --into repo copies a decision's quote into the trunk namespace; it widens who reads that quote to the repository's readers, by the operator's choice. It never widens who can read the document.
  • --into without --repo, an unknown repository, or a repository with no remote to tag rows with (--into source only) exits 1 before any model call.
  • --into repo rows belong to the trunk: erasing the document's namespace leaves them (the feature page says so).
  • Left alone: the decision schema, memory.for_file, the plugins.

Compatibility, rollout and rollback

  • Wire: none (CLI flags --repo and --into only).
  • Operator steps: none.
  • Rollback: rows written with --repo stay as they are; a later run without --repo revises them to drop the tag.

Tests

  • tests/unit/test_decision_extract.py: symbol lookups go to the trunk, rows go to the document's namespace with the tag (--into source) or to the trunk citing the document's home (--into repo), the code-namespace default, reconcile reads in the target namespace, a row revised to gain the tag, refusals without read on the repository or the document's namespace and without write where rows go, a failing access check refusing, unknown repository and --into without --repo, unchanged behaviour with no --repo, a pinned row and a row with a recorded outcome gaining the tag by a tag write (dry run reports it), a contradicted pinned row flagged and tagged in one write, the refusals when the document's rows are in the other namespace, and a run without --repo over tagged rows. repo_trunk matches owner/name and an SSH remote, picks the trunk over a release branch, and stays in its org.
  • tests/integration/test_decision_extract_repo.py, against a local ClickHouse: a synthetic design document added with knowledge.add to a person's namespace names a class of a fixture repository indexed at its trunk; extraction with --into source and --into repo resolves the class to its file, and memory.for_file with the plugin hook's body serves the row to a reader of the namespace it went to, and not to a session tagged with another repository, a reader of another namespace, or a caller who cannot read the trunk.
  • make format lint typecheck, scripts/codegen/docs_reference.py --check, the CLI snapshots, test_public_copy.py, test_doc_links.py, test_package_contracts.py.

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 namespace each read and write goes to, and the gates, were checked against the unit and integration tests above.

  • 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 and others added 25 commits November 3, 2026 11:17
A design document added to a person's or a team's namespace has no code index
there, so every decision it yielded had no files and never reached the pre-edit
block. --repo OWNER/NAME resolves the document's code names in the
repository's trunk code namespace; --into source writes the rows beside the
document tagged repo:<id> (the tag memory.for_file matches for the coding
plugins), --into repo writes them to the trunk, citing the document in its own
namespace. Reconcile and retire reads run where the rows go. The run checks
read on the document's and the repository's namespace and write where the rows
go, and refuses on a failed check.

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

A pinned or attested row, or one with a recorded outcome, is never recorded
again, so it gains the repository's tag by the same tags-only write that sets
or clears source-changed. Reconcile and retire read one namespace, so a run
refuses before any model call when this document's rows from an earlier run
are in the other namespace a run may write them to, or when a run without
--repo finds them tagged with a repository.

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

A row whose reasoning is still in the document but that the model did not emit
again, and a kept row the retire step tags source-changed, gain the
repository's tag too, so every row of a linked document reaches the pre-edit
block. A run that cannot read the other namespace a document's rows may be in
is refused without saying whether rows are there. The feature page names the
two cases the check does not cover.

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

Rows tagged with one repository are no longer re-tagged or re-recorded for
another; the run says which repository they are linked to. The repository's
tag comes from whichever of its entries names the remote, its trunk from the
same helper the search legs use, and rows in the trunk itself carry no tag.

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

Another writer's unconfirmed row citing the document is left as it is, as the
extractor revises only its own. A repository the caller may not read gets the
same answer as one that is not configured. An --into repo record carries no
empty tag, and a flagged row that gains the repository's tag is reported
without a reason it does not have.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A run without --repo looks up the trunk of a branch namespace, which needs the
repositories added from the dashboard: the snapshot is read before any lookup.
The refusal for rows linked to another repository names it by owner/name. The
repository's tag comes from the entries spelled as the trunk's, and each
namespace's access is checked once.

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

A run that could not read the repositories added from the dashboard would see
no trunk for a branch namespace and skip its check, so it refuses
(registry_read). The refusal for rows linked to another repository names it
only when the caller may read it. Docs, help and docstrings say which rows gain
the repository's tag.

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

A document in a release branch's code namespace may have its rows in that
repository's trunk; a run naming another repository now finds them there and
refuses, naming no flag it cannot know. The access check uses the default
refusal marking: the refused run is the whole answer, so an unverifiable grant
counts as the server's failure.

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

Rows an --into repo run wrote to a repository other than the one whose code
namespace holds the document are not seen by a later run that drops or changes
--repo, whatever namespace the document is in. The help and exit_code list
--into without --repo, a repository with no remote and an unread registry. The
registry's read state is a flag, not a comparison with the start value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The pre-edit hook reads the session's own namespace and the repository's trunk,
so a row beside the document reaches a session working from that namespace;
a team's shared document goes in with --into repo. The refusal path reads each
repository's name and trunk in one pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A confirmed row another writer linked to a repository keeps that link alone
when the extractor flags or keeps it. A caller who cannot read a branch's trunk
is refused without its name. Naming a linked repository in a refusal does not
mark the request the server's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Its rows would resolve against the named repository's code and be linked and
read as the other repository's. The refusal prints a linked repository as
owner/name, and the retire step writes a kept row's tags through one helper.

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

Whether the namespace is a code namespace, or another repository's, shaped the
answer to a caller who could not read it. The report comment says which step's
tag writes `linked` holds.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ps at one row

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]>
…gged there

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…a kept row's tags

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ds the row back whole

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/decision-extract-repo branch from b3a86f9 to 65b4d3e Compare November 3, 2026 11:17
zlareb1 and others added 3 commits November 3, 2026 11:26
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 merged commit c7f3909 into main Nov 3, 2026
20 of 22 checks passed
@zlareb1
zlareb1 deleted the feat/decision-extract-repo branch November 3, 2026 12:31
@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