Substrate Brief — the HQ project

F 273 · id 12 · 2026-10-15 · BRIEF ONLY — no substrate was built, and no existing record model was touched

The boundary as the operator corrected it: lanes are projects — the F lane is the FreshCards project, and HQ is a project too, the fleet project. VC owns every surface (canvas, panel, Dashboard, HQ itself). The F lane owns the substrate — FCr, FCC, the EntityKind union, the adapter, the query layer, the federation contract, the storage schema.

FVC writes the HQ surface plan. This document is the substrate brief — what the HQ project runs on. It is the artefact that lets both proceed. It names shapes; it changes nothing.

The single most important sentence in this brief, for FVC:

Nothing in the substrate needs to be invented, except one field on one model. project already exists as a required field on Conversation, Turn and Agent. ListOptions.project already exists in the query layer. ListOptions.limit and offset already exist. 'project' is already a member of the EntityKind union. The two record models share id, createdAt, updatedAt and — decisively — thread_id, which is HQ's field name for what the substrate calls project.

So the real work is a rename plus one query route, not a new data model. That is a much smaller ask than the boundary sounds like.

0. Inputs, measured

InputMeasured
FreshCards main96138b1 — "F 269: document that fc-deploy runs from the seat, not the VPS"
Live production2.21.3 / edba719 (deployed 1792009682749), root HTTP 200
EntityKind unionsrc/core/adapters/filesystem/types.ts:42 — includes 'project' already (line 51, file-classifiable)
Query layersrc/core/query/query-layer.ts — ListOptions { project?, after?, before?, limit?, offset? }; QueryLayer { list, resolve, traverse }
AdapterStorageAdapter in src/core/storage/types.ts — key/value (save/load/delete/list/clear), not entity-shaped
Federation contractsrc/modules/extracted/BundleManifest.ts carries moduleFederation; no cross-project read/write contract exists
VC mainf1fd3f0 locally; origin/main 5c7f57c; ExtractedNode has no projectId
FVC 740STOPPED at Stage 2, Job 1 (b015115, id 46) — 0 commits, 0 pushes
F 272shipped — artifact 1150, the dashboard canvas plan

1. What a lane-project is

a. A project is a first-class record. It already is, in the substrate: 'project' is a member of the EntityKind union at types.ts:51, one of only eight file-classifiable kinds. A project node carries id, fcid, parentId, order and properties like any other entity.

b. A lane is a project with one extra field — call it lane. Not laneName: the value is an integer lane id, and it must be named so the fleet's own vocabulary survives. HQ already calls it thread_id in six tables; the substrate calls the same idea project (a string). The field is lane: number on the project record, and it is the join key between the two worlds. A project with no lane is the fleet project itself (HQ) — which is precisely the operator's ruling, expressed as a nullable field rather than a special case.

c. Relation to the tree: projectId, stamped from a real source. FVC 740 established the important asymmetry and it holds. In the substrate, WorkspaceState already carries projectId?: string and project is a required field on Conversation, Turn and Agent — so a source exists and is stampable today. In VC, projectId is reachable from WorkspaceManager.activeProjectId and the project record's origin, and active-context.ts:165 already derives a rootPath from it. Recommendation: add projectId to ExtractedNode and to the nine-field toWireNode allowlist, and defer appId and view entirely — see §7.

d. Relation to its apps: appId, deferred. FVC 740 searched for appId, currentApp, setActiveApp, activeApp, appRegistry and found no app identity anywhere — the only appId hits are an edge-panel string naming a panel, and a build-result type. In the substrate the equivalent is surfaceId? on WorkspaceState: a surface exists as a concept, an app does not.

e. Does a project get its own EntityKind member, or is it a node of an existing kind? It already has its own member — 'project'. Nothing to add. The design question is settled by the code, not by this brief.

Where the operator's four-tier shape meets reality: three of four tiers exist, and they are not the same three.

TierSubstrate (FC)VC
projectEXISTS EntityKind 'project', WorkspaceState.projectIdEXISTS WorkspaceManager.activeProjectId
appPARTIAL WorkspaceState.surfaceId? — a surface, not an appABSENT no app identity
viewABSENT no view concept; QueryLayer.list(kind, opts) is kind+filter, not viewABSENT FVC 740: viewId/activeView return nothing
surfaceEXISTS surfaceId + VC's app-surfaces/*.yamlEXISTS surface YAML with canonical_source

2. What a record is, in the fleet's two models

2a. The HQ model (measured from the live panel schema, read-only)

TableFields
hq_bulletinsid, thread_id, ts, level, message
hq_reportsid, thread_id, ts, summary, files_touched, decisions
hq_docsid, thread_id, ts, type, title, project, body, summary, tags, ref_plan, parent_doc_id, display_id
hq_promptsid, thread_id, ts, prompt
hq_decisionsid, thread_id, ts, title, decision, rationale, alternatives, consequences, status, superseded_by, decided_at, decided_by, ref_plan, ref_prompt
artifactsid, thread_id, type, name, path (UNIQUE), url, title, description, tags, project, chain_key, version_label, version_seq, superseded_by_id
hq_threadsid, name, token, session_id, last_heartbeat_at, last_seen_workspace, last_seen_branch, last_seen_commit, status, trust_score

The HQ model is flat, append-only, and keyed on thread_id. It has no fcid, no parentId, no order, and no tree. hq_threads is the closest thing to a project record and it is really a session — it holds a token and a heartbeat.

2b. The VC-shape model (measured from the substrate's models)

ModelFields
Conversationid, fcid, project, title, participants[], messages[], createdAt, updatedAt, closedAt
ConversationMessageid, author, text, ts, meta?
Turnid, fcid, project, title, conversationId, agentId, parentTurnId, spawnedAgentId, initiatedBy, sequence, startedAt, endedAt, duration, input, output
Agentid, fcid, project, label, kind, liveness, interactive, spawnedByTurn, spawnedInThread, dailyTheme, sandbox, version, createdAt, updatedAt

The VC model is tree-shaped, reference-dense and time-ordered, and it already carries project on every one of the three record kinds.

2c. Common, model-specific, and how a record declares its model

Fields
Commonid (HQ integer autoincrement / substrate string), ts≡createdAt, updatedAt (HQ: absent), and the scoping field — thread_id≡project
VC-specificfcid, parentId, order, edge, participants, messages, conversationId, agentId, sequence, initiatedBy, status, liveness
HQ-specificlevel, summary, body, tags, ref_plan, parent_doc_id, display_id, path/url, chain_key, version_seq, superseded_by, decided_by, alternatives, consequences

How a record declares its model: it does not, and that is the finding. The substrate's models carry a kind ('conversation', 'turn', 'agent'). HQ's carry a type on some tables (report, plan, doc) and nothing at all on hq_bulletins and hq_prompts — a bulletin is identifiable only by which table it is in.

Recommendation: the substrate's kind is the model key, and it already exists. The query route takes it as a parameter (Item 3j). HQ's records are not a second model to be tagged — they are a set of tables, and the honest mapping is that a table maps to a kind by a registry the substrate owns, not a field each record carries.

3. The query shape, named once

This is the read route every surface reads through. FVC should be able to say, from this section alone, "the Dashboard reads through this" or "it does not."

GET /api/agent/query
  ?model=<kind>          conversation | turn | agent | bulletin | report | doc | plan | decision | prompt | artifact
  &project=<string>      the scoping key. REQUIRED — see §5c
  &view=<string>         named projection, resolved against the substrate's view manifest
  &filter=<json>        {"field": "value"} | {"field": {"op": "gte", "value": ...}}, AND only
  &limit=<int>         1..200, default 50
  &cursor=<string>      opaque. Absent = first page. Present = next page

a. Route path — GET /api/agent/query. One route, not two. /api/agent/* is the existing bridge prefix that fs-bridge-client.ts already documents as owned by id 8.

b. Parameters — exactly the five named above, and no others at v1. A sixth parameter is a schema change.

c. What app resolves to. The dispatch's parameter list says app; this brief's boundary says project. The parameter is project, not app. Reason: appId has no source in either repo (§1d), while project is a required field on three models and a filter that already exists in ListOptions. A parameter with no source cannot be a v1 parameter. app is deferred to v2, and the surface YAML layer gets it for free because surfaces are already first-class.

d. What view resolves to — a named projection declared by the substrate, not a stored object. A view is a saved {model, filter, fields, order, limit} tuple, resolvable to a filter over one model. A view does not exist today in either repo (FVC 740 searched; nothing). It is new, and it is the substrate's to define, because only the substrate knows what a model contains.

e. What filter accepts — JSON, AND-only at v1, on top-level fields only. Operators eq, neq, gt, gte, lt, lte, in. No OR, no nested objects, no dotted paths — query-layer.ts's own comment already says dotted paths with [] segments are "NOT supported in v1". A filter language that outruns the query layer is a filter language that cannot be honoured.

f. What limit bounds — 1..200, default 50. Hard cap, not advisory; a Dashboard widget must not be able to ask for the fleet.

g. What cursor is — opaque, server-generated, and derived from the ordering field plus the id. Not an offset. ListOptions has offset today and the brief should say plainly that it is not what a cursor is: an offset breaks the moment a record is inserted, and a fleet feed inserts constantly. Existing offset stays for compatibility; the route does not expose it.

h. Response body — one shape for both models, so no surface branches on model:

{
  "data":  [ { "id", "model", "project", "fcid"?, "createdAt", "updatedAt"?, ...modelFields } ],
  "next":  "<cursor>" | null,
  "total": <int, optional — omit when the count is unbounded>
}

i. How it queries both models in one shape. Two backends behind one contract, chosen by model. Substrate models (conversation, turn, agent) resolve through QueryLayer.list(kind, {project, after, before, limit}) — the call already exists. HQ tables map through a table→model registry that translates filter to SQL. The unification is at the response shape, not at the storage layer. That is the cheapest honest answer: HQ is SQLite, the substrate is an adapter-keyed store, and pretending otherwise costs more than it buys.

j. Model key as a first parameter, or a second route? First parameter. One route, one response shape, one place to add a capability check. Two routes would double every auth and pagination change, and would let the two models drift in exactly the way that makes a Dashboard unbuildable. Exception: if a model needs a fundamentally different contract (bulk write, delete-by-query), give it its own route — but reads stay unified.

What FVC needs from this section: a Dashboard widget binds to model + project + optional view, and gets the same envelope whatever it bound to. If FVC's surface needs a seventh parameter, that is the signal the shape is wrong — say so before building, not after.

4. relatedProject

a. The field on a conversation record. relatedProject: string on Conversation, optional, alongside the existing required project. The distinction matters and must survive: project is where the conversation lives (scoping, mandatory); relatedProject is who else is party to it (routing, optional). Naming it project again would be wrong, and putting it on Turn would be wrong — a turn is inside a conversation and inherits its parties.

b. The read route by relatedProject. Not a separate route. The same /api/agent/query with model=conversation and one addition to filter: {"relatedProject": "X"}. A second route for a second field on the same model is how a query layer becomes a maze.

c. The write route for a cross-project conversation. POST /api/agent/query is the substrate's read-and-create path, with relatedProject accepted in the body. Creating in project A while addressed to project B is a normal write, not an escalation — the receiving lane's dashboard does the reading, under its own project's scope. The substrate's obligation is to create it truthfully; the permission decision is the surface's.

d. The notification path into the receiving project's Dashboard. Deliberately not specified here, and this brief will not guess it. The substrate provides exactly two things and no more: the field, and the route that can list by it. Whether notification is a live socket, a poll of the query route, or a per-project unread counter is a VC surface decision — FVC's, under "VC owns every surface." Stating this precisely is the point: the substrate owes a listability, not a delivery mechanism.

5. What HQ needs from the substrate

a. How HQ's aggregation reads from every lane-project. HQ is a project whose project is the fleet. Its dashboard aggregates by iterating lane-project ids and querying each — GET /api/agent/query?model=bulletin&project=freshcards, then …&project=vibecoder-standalone, and so on — and merging client-side by ts. There is no fleet-wide query. That is a deliberate refusal, and Item 5c is why.

b. Does HQ's read cross project boundaries, and how does the scope rule handle it? Yes, and this is the sharp edge of the whole brief. Every other project reads exactly one project. HQ reads many. A scope rule that says "a session may read only its own project" would forbid HQ from existing; one that says "any session may read anything" would make relatedProject meaningless. Recommended rule, two sentences: a read is scoped to the projects the caller's session declares, and a session declares more than one only by holding a fleet-scope capability. HQ holds it because the fleet project is what it is. Scope is declared, not inferred from the URL — so the same route serves both, and the surface that renders a lane's dashboard is structurally incapable of widening its own scope.

c. What HQ's dashboard needs that a lane-project's does not. Three things, and only one is new machinery: (i) cross-project read, per (b) — the capability, not a new route; (ii) lane-awareness — grouping by the lane field from §1b, so the operator sees "12: F 267 …" rather than an undifferentiated feed; (iii) the HQ-specific record types — bulletin, report, plan, decision, prompt, artifact — which have no substrate model but have tables. (iii) is the only genuinely new read work, and the table→model registry from §3i is where it lands.

d. What the substrate must provide that it does not yet. Exactly four items, in dependency order: (1) the lane: number field on the project record; (2) the /api/agent/query read route; (3) the view manifest, without which view cannot resolve; (4) the table→model registry, so HQ's six table families answer in the substrate's envelope. Plus one field on one model that is not on that list: relatedProject on Conversation (§4a), which is additive and needs no migration.

6. The convergence plan

a. What HQ adopts from VC's shape. The tree-and-reference record shape: fcid for stable addressing, parentId/order for containment, and kind as the model key. HQ's records are currently flat and integer-keyed; adopting fcid is what lets a bulletin be referenced by a plan, a decision and an artifact without any of them knowing the other's table. The vocabulary — turn, conversation, agent — is the vocabulary the substrate already ships and the query layer already walks (LINK_FIELDS is a per-kind declaration).

b. What HQ keeps that VC does not have. The lane-aware view (grouping and filtering by lane, which has no analogue in a single-project substrate), and the bulletin and plan namespaces — HQ's artifacts carry path UNIQUE, chain_key, version_seq and superseded_by_id, a lineage model the substrate has no equivalent of and no immediate need for. Adoption is not replacement. HQ is a fleet surface; the substrate is a substrate.

c. What HQ drops. Nothing, and this is the load-bearing decision of Item 6. HQ does not migrate hq_bulletins into Conversation and it does not stop using thread_id. The tables stay exactly where they are; the query route's registry makes them readable in the substrate's envelope. A fleet with 1,500+ bulletins and a decision lineage does not earn a rewrite for a uniform read shape — and a rewrite here would put every lane's history at risk for a cosmetic gain. One envelope, two storage models, no migration.

d. What the substrate has to add. Four things, restated as work: the lane field; the /api/agent/query route; the view manifest; the table→model registry. Plus relatedProject on Conversation. None of these is a new data model. All of them are additive, and none requires rewriting a single existing record.

7. The relationship to F 272 and the query path

Depends onParallel?
This brief (F 273, id 12)nothing — it is a specificationAlready done
The query path (substrate build)this brief's §3 shape, and id 8's agreement on /api/agent/*Must wait for the brief — it is the shape being built against
FVC's HQ surface (FVC)§3 (does it read through this route?) and §4d (its own notification choice)Can start after reading §3 and §5; does not need the route built
F 272's canvas (shipped, artifact 1150)the same route — its Stage 1 was "read-only FC query route"Same work. See below

Order: brief → query path → surface. FVC may scope in parallel with the query path, once §3 is read. What it must not do is build against a guessed route shape — that is the failure the brief exists to prevent.

One convergence worth stating plainly: F 272's Stage 1 and this brief's query path are the same work. F 272 (id 12, same lane) scoped "a read-only FC query route: app → view → filter/limit/cursor → entities" as the thing that unblocks the whole dashboard. This brief names the same route, and differs in three places — and the differences are corrections, not additions:

F 272 saidthis brief sayswhy
app as a parameterprojectappId has no source in either repo; project is a required field on three models and already a query filter
cursor, unspecifiedopaque, from order key + idan offset breaks under a fleet feed's insert rate
one modelmodel as first parameter, one envelopeHQ is a project too, and its records must answer in the same shape

Recommend FVC scope against §3, and treat F 272's Stage 1 as superseded by it — same route, better name, wider contract.

8. Where this brief lives

HQ plans namespace, artifact type plan, project freshcards, thread 12 — steps, handover, verification steps and targeting in meta. A bulletin points here. Not mirrored to Notion: this dispatch's scope forbids touching Notion, and §1 permits an HQ plan URL in place of a Notion one.

Two decisions this brief does NOT make, because the operator has not. It names shapes; it does not settle:

(1) the app tier. FVC 740 stopped because appId has a field but no source, and inventing a holder was forbidden. This brief takes the same position: defer appId and view as identity; ship projectId + project now. The operator should confirm a project-only boundary is acceptable for v1, in which case FVC 740 becomes Jobs 2 and 3 and its ~47 call sites become their own migration with their own regression budget.

(2) who may read across projects. §5b recommends a declared fleet-scope capability. The alternative — that any lane's session may read any project — makes relatedProject decorative. This one is the operator's, not the lanes', and it is the decision that most changes what the substrate must build.


F 273 · id 12 · 2026-10-15 · BRIEF ONLY — the substrate was not built, and nothing in FCr, FCC, VC or HQ was modified.
The panel schema, VC tree and substrate were read only. No tag cut or moved. panel.db and the turn store untouched.
Native usage: 0 — every claim came from reading source over SSH, or from git and curl.