Files
loki/docs/architecture/cross-project-reference.md
CatoandClaude Opus 5 baa8e2e6fb chore(aoz): follow bitbaum/aoz-housing -> bitbaum/aoz-begleitung (#732)
The repo was renamed today. It was the last place the product was still called
Housing: the name row in fleet's registers/retired.json retired "AOZ Housing" as
the PRODUCT name on 2026-09-10, but the repo kept it, and the repo is public.

The deploy name `aoz-wohnen` is deliberately NOT renamed with it. It is an
infrastructure identifier — systemd unit, /opt path, database — nothing on the
box keys on the repo name, and moving it would touch a live site for no visible
gain. apps.conf's comment block already said as much and still does.

The load-bearing change is apps.conf's fourth field. repo-metadata-audit.mjs
keys the register on that path's BASENAME, so while it read /home/g/dev/
aoz-housing the join against GitHub missed and every metadata check for this
repo was silently skipped — the audit went green by not looking at it. The local
checkout was moved to match and its three worktrees repaired (`git worktree
repair`), not pruned: they hold branches.

Two test failures worth keeping, because both were the rename telling the truth:

  - project-mention asserted that "the AOZ housing rebuild" resolves to the
    project. With the slug renamed it does not, and should not. The case exists
    to prove "a slug with a hyphen, typed with a space" matches, so the INPUT
    moved to the current name rather than the expectation being loosened.
  - tab-match asserted a terminal tab literally named "AOZ Housing" matches the
    slug. Same thing: the fixture now uses the name the tab would actually have.

Consequence worth naming: someone who types "aoz housing" at Loki will no longer
be understood. There is an alias mechanism for exactly this shape
(register/build.ts maps the deploy name to the repo), but wiring the retired
name into mention-matching is a product decision, not a rename chore.

Left alone on purpose: scripts/db/retire-stale-projects.ts, whose data row
records the project names the database actually held when that migration ran;
and content/thoughts/*.md, published essays — one of which quotes a filesystem
path observed during a debugging session, so rewriting it would falsify the
anecdote.

The production user_projects row was updated too (name and git_url), because the
database is a second copy of the repo identity and a past rename left 21 rows
pointing at a dead account. New URL proven to resolve: 431bae7.

Tests green: fleet-register 44, project-mention 28, tab-match 10, fleet-map 7,
loki-project-ranking all.


Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 12:17:25 -07:00

5.2 KiB

Cross-Project Reference — spec

Status: proposed · Date: 2026-06-25 Thesis fit: This is the one context feature single-project tools structurally cannot have. Loki's edge is that you run many projects; cross-project reference is where that edge becomes a feature.

The problem with what exists today

Loki's composer has a project rail where you can tick multiple projects. But the wiring tells the real story:

  • The API accepts selectedProjects: string[] (max 50).
  • resolveCommand uses only selectedProjects[0]. Projects 2..N are silently ignored.

So the multi-select is an affordance that lies: it implies "act across these projects," does nothing of the sort, and gives no feedback that it didn't. That's worse than no multi-select. The instinct to rethink it is right.

The core insight: two intents are fused into one control

Selecting multiple projects can mean two completely different things, and the current UI can't tell them apart:

  1. Target — where the work lands. "Dispatch this task to kivvi." Inherently singular per dispatch (an agent runs in one project's session).
  2. Reference — what informs the work. "Do kivvi's auth the way aoz-begleitung does it." Inherently plural — pull other projects in as context.

selectedProjects[0] accidentally implements Target and throws away Reference. The fix is not "use all N as targets" — it's to split the two intents into two distinct mechanics:

1 Target · N References.

A. Reference-as-context — lead with this

In the composer, @-mention other projects: @aoz-begleitung. Each mention pulls that project's profile (mission, stack, architecture, conventions, definition-of-done — the block we already inject for the target) into the prompt as a clearly-delimited "Referenced projects" section, ahead of the task. Optionally pin specific files (@aoz-begleitung/src/auth/*) later.

Why @-mentions over a checkbox rail:

  • Disambiguated by construction. The target stays the selected/named project; references are explicit, inline, visible in the text you wrote. No silent dropping.
  • Composable + precise. "Do X here, like @a, but the data model from @b." A rail can't express that.
  • Familiar. GitHub #issue, Notion @page, Claude's project reference — the gesture is learned.
  • Cheap to build. Reuses getProjectContext() (the existing profile injector). Add references: string[] to the dispatch/ask payload; for each, inject the summary-level profile (not the full thing — token budget).

This is the uniquely-ours, on-thesis feature, and it's small.

B. Fan-out dispatch — power feature, defer

"Run this on every project that uses Drizzle" → the same task dispatched to N targets. This is the legitimate multi-target case the old rail gestured at. It's a different, heavier feature (N sessions, N results to track, partial-failure UX) and should come later, as an explicit "Run on N projects" action — never the silent default of a multi-select.

What changes in the UI

  • The project rail becomes a single-select Target (radio, not checkbox) — honest about where the dispatch goes.
  • References live inline in the composer via @, rendered as chips, removable.
  • A future "broadcast" affordance (B) is a separate, explicit button — not the rail.

Engineering

Composer: parse @mentions → references: string[]   (client)
   ↓
POST /conversations/:id/messages  { text, selectedProjects:[target], references:[...] , ... }
   ↓
messages route: resolveCommand(target) for routing (unchanged)
   ↓ build prompt:
   referenceBlock = (await Promise.all(references.map(getProjectContext)))
       .map(summarize).join() ;  prompt = referenceBlock + task
   ↓
injectPrompt / askLoki (reference block already folded into the prompt)
  • Reuse: getProjectContext() already produces the profile block; add a summary mode (mission + stack + DoD only) so N references don't blow the context window.
  • Budget guard: cap references (e.g. ≤4) and inject summaries, not full profiles. Log when truncated (no silent caps).
  • Authz: only reference projects the caller owns / is a member of (same gate as the target).
  • Fan-out (B): later — a loop enqueuing one dispatch per target, with a combined result view.

Why this is the right stepping stone

The harness essay named memory as our weakest strut: a fleet should remember more than any one agent. Manual @-reference is the v1 of that — the operator hand-picks relevant cross-project context. The v2 is the harness suggesting references ("kivvi's auth resembles aoz-begleitung's — include it?") from similarity over the project profiles. Build the manual rail-to-mention path now; it's the substrate the automatic version grows on.

Phasing

  1. Reference-as-context — @-mentions → summary-profile injection; rail → single-select Target. (Small, high-value, on-thesis.)
  2. File-level references — @project/path pins specific files into context.
  3. Suggested references — similarity over profiles surfaces likely-relevant projects.
  4. Fan-out dispatch — explicit broadcast to N targets with a combined result view.