Skip to content

Context assembly: Conventions and Architecture Decisions read from the Utopia mirror - #2794

Merged
gedaiu merged 1 commit into
mainfrom
utopia/context-arm-search
Oct 16, 2026
Merged

gedaiu merged 1 commit into
mainfrom
utopia/context-arm-search

Conversation

@gedaiu

@gedaiu gedaiu commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

The first real Utopia arm for the Lore-vs-Utopia experiment (#2787, #2792): under backend utopia, and in the Utopia half of both, the context's Conventions (repo) and Architecture Decisions (adrs) sections come from Utopia instead of answering "no Utopia reader yet". It needs no new writes: it reads the spec and ADR statements the mirror (ADR-052) already pushed, through the read client from #2791.

What changed

  • One shared section pipeline. context-assembly-pipeline.ts (moved out of context-assembly.ts): budget, fetching per section through a reader, packing, the debug trace. Lore and Utopia both go through it, so an eval's found grades Utopia's assembly the same way as Lore's. The Lore path is unchanged; the existing context-assembly tests pass without edits.
  • context-assembly-utopia.ts.
    • One search per assembly (topK 50), a second page only when a section is short and the first page says hasMore.
    • Keeps statements-source hits whose pushed id is a doc: or stmt: item (other sources are dropped, since search has no source filter yet), sorts each path into repo or adrs with Lore's classifyFile, and groups by path in first-rank order.
    • Each item is the document's title then its statement texts in order, under the Lore path, with Utopia's score; same item limits as Lore.
    • Every other section still answers "no Utopia reader yet", as all do when the deployment has no reader or the repo has no settings.utopia.
  • Wiring. repoContextSettings also reads settings.utopia {kb_id, source_id} in the same query. /api/context and the evals pass utopiaReadsFrom(env) and those ids. Under both, the two halves now assemble in parallel; the debug trace stays Lore's.

Caveats, recorded in the ADR-052 amendment: a tombstoned document can still match until Utopia's search can exclude missing documents; post-filtering by source id until search takes a source filter; code items carry no text yet; typed graph reads wait for the release that types Lore's relations.

Spec: specs/utopia-graph-mirror "The Utopia arm" FR12.1–FR12.6, specs/context-assembly FR-1.5. (FR12 may need renumbering if #2790 lands first.)

Tests

Pure and reader tests (libs/shared): one item per spec from three statement chunks in order; another source's hits dropped; a second page only when short; code has no reader. End-to-end with the real templates (server-core): the ADR under Architecture Decisions with its statement texts; the trace lists the kept paths; no settings falls back to no-reader sections. Fixtures are built from the real docStatementItems output with a hand-written fake UtopiaReads. repoContextSettings reads the mirror ids.

tsc clean in libs/shared, server-core, lore-api; vitest libs/shared knowledge + utopia 143 passed (2 skipped), server-core context 27, lore-api context + context-evals + utopia 95; eslint clean on changed files and specs adrs.

Generated with Claude Code

@lore-agent

lore-agent Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Lore is reviewing this PR — 36cf006f-b2c1-490d-a3f7-69a3203a186d.

Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🔍 Lore Spec Impact — advisory

This PR touches 58 statement(s) across 3 spec(s), and 43 of them have validating tests this PR does not change.

Feature Specification: Context Assembly Templates · 14 statement(s)

specs/context-assembly/spec.md

Scenario 3: Token Budget Enforcement
✓ this PR also changes the tests that validate it

Output never exceeds max_tokens.

validated by libs/server-core/src/work/context/context-assembly.test.ts:282

Scenario 4: Traceable Assembly (Prompt Debug View)
✓ this PR also changes the tests that validate it

A debug=1 assembly returns a per-section trace carrying each source's status and, when omitted, the reason (no result…

validated by libs/server-core/src/work/context/context-assembly.test.ts:282

FR-1: lore_assemble_context MCP Tool
✓ this PR also changes the tests that validate it

FR-1.5: (added 2026-10-16, ADR-052 amendment "reads choose a backend") backend names the store the assembly reads: …

validated by libs/server-core/src/work/context/context-assembly.test.ts:282, libs/shared/src/outbound/project/knowledge/context-assembly-backends.test.ts:41

FR-1: lore_assemble_context MCP Tool
✓ this PR also changes the tests that validate it

FR-1.6: Under both the Lore assembly comes first and the Utopia assembly second, each wrapped in a `<backend name="…"…

validated by libs/server-core/src/work/context/context-assembly.test.ts:282, libs/shared/src/outbound/project/knowledge/context-assembly-backends.test.ts:41

FR-2: Context Sources
✓ this PR also changes the tests that validate it

FR-2.7: Hybrid relevance ranking. The local repo, code, and adrs sources rank by a Reciprocal-Rank-Fusion of …

validated by libs/server-core/src/work/context/context-assembly.test.ts:282, libs/shared/src/outbound/project/knowledge/context-assembly.test.ts:388

FR-2: Context Sources
✓ this PR also changes the tests that validate it

FR-2.8: No cross-section duplication. The repo/Conventions source pulls only doc/spec (never adr, which is …

validated by libs/server-core/src/work/context/context-assembly.test.ts:282, libs/shared/src/outbound/project/knowledge/context-assembly.test.ts:388, libs/shared/src/outbound/project/knowledge/context-assembly-format.test.ts:179

FR-2: Context Sources
✓ this PR also changes the tests that validate it

FR-2.9: Code retrieval. A dedicated code source retrieves content_type='code' chunks via the same hybrid rankin…

validated by libs/server-core/src/work/context/context-assembly.test.ts:282, libs/shared/src/outbound/project/knowledge/context-assembly.test.ts:388

FR-2: Context Sources
✓ this PR also changes the tests that validate it

FR-2.17: Linked repos reach the context. The default, implementation and review templates each carry a `Linked Repo…

validated by libs/server-core/src/work/context/context-assembly.test.ts:282, libs/shared/src/outbound/project/knowledge/context-assembly.test.ts:388

FR-2: Context Sources
✓ this PR also changes the tests that validate it

FR-2.18: No linked repos, no cross-repo search. With no repo linked in settings the cross_repo section is `disabl…

validated by libs/server-core/src/work/context/context-assembly.test.ts:282

FR-3: Template System
✓ this PR also changes the tests that validate it

FR-3.1: Templates are YAML files in a configurable directory (default: mcp-server/templates/).

validated by libs/server-core/src/work/context/context-assembly.test.ts:282

…and 48 more statement(s).

4 changed statement(s) had no validating test, so no coverage broke. 191 new statement(s) have no test link yet.

Deterministic · graph @ 54e00aa (projected 2026-10-07) · 14 file(s) skipped: changed since the graph last saw them, so their line numbers no longer line up · no tests run by this check

@lore-agent lore-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lore review — Approved

Clean implementation of the Utopia context-assembly reader for the repo and adrs sections with shared budget/trace pipeline and thorough unit tests.

Must fix (0) · Consider (0) · Nits (0)

Reviewed by gemini-4-argon

Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.

Posted by floor, visit e13155e9-377d-4258-b0f5-9f5e7a9abee8.

…e Utopia mirror

Under backend utopia (and the Utopia half of both), the repo and adrs
sections are read from one search of the repository's knowledge base:
the statements source's doc and statement chunks, grouped into one item
per document (title, then statement texts in order) under the path Lore
uses. A second page is asked for only when a section is short. Every
other section still answers "no Utopia reader yet", as all do when the
deployment has no reader or the repo no settings.utopia.

Lore and Utopia now share one section pipeline (budget, serialization,
debug trace), so a context eval's `found` grades Utopia's assembly the
way it grades Lore's. /api/context and the evals pass the reader and the
repo's mirror ids, read with the rest of its context settings.

Spec: utopia-graph-mirror FR12, context-assembly FR-1.5.
ADR-052 amendment 2026-10-16: the first Utopia reader is search over the
mirrored statements.
@gedaiu

gedaiu commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased on main after #2790: both PRs claimed FR12 in specs/utopia-graph-mirror, so this one's section is now FR13.1–FR13.6, and ADR-052 keeps both amendments in order. Tests and lint re-run green.

@gedaiu
gedaiu force-pushed the utopia/context-arm-search branch from d5ffb2d to 589c8c8 Compare October 16, 2026 21:16

@lore-agent lore-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lore review — Approved

Utopia context assembly reader for repo and adrs sections is clean, well-tested, and matches ADR-052 and spec requirements.

Must fix (0) · Consider (0) · Nits (0)

Reviewed by gemini-4-argon

Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.

Posted by floor, visit ab4a017e-cfa6-447d-940d-b7500af35036.

@gedaiu
gedaiu merged commit 6ab4f8f into main Oct 16, 2026
30 checks passed
@gedaiu
gedaiu deleted the utopia/context-arm-search branch October 16, 2026 21:23
gedaiu added a commit that referenced this pull request Oct 16, 2026
…from (#2797)

Records the first side-by-side measurement of Lore's own stores against
Utopia as the source of an agent's context, in the shape of
`decompose-model-comparison.md`.

The comparison ran locally (the eval runner on a developer machine,
against the deployed lore-api at #2794 and Utopia `0.1.0-re.7`), with
the side-by-side grading from #2792: one question per document, context
assembled once from each store at the full budget, answered and judged
the same way.

Headline: no store should switch yet.

- Where Utopia has a knowledge base it often finds the right spec. On
bowman-ui it found 18 of 20 documents against Lore's 15.
- Less of what it returns gets used (about half Lore's useful share).
The likely cause is that its reader returns whole documents' statements,
not matching sections. That is not verified yet; the doc says how to
check.
- Utopia answered 1 question Lore missed; Lore answered 56 that Utopia
missed.
- Five repositories have no Utopia base, so they compare one store, not
two.

The doc lists the next steps in order: set up the missing bases, return
only matched statements, push whole files, then run again.

Docs only.

Generated with [Claude Code](https://claude.com/claude-code)
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