Add a page or projection
Two extension points cover new read surfaces in the PM stack. A new dashboard page registers in the aggregator’s page manifest and renders from the aggregator’s one state. A new projection adds a read model in the projector, or a source reader in the aggregator, and the page consumes it. This chapter gives both procedures as the code is shaped today. Adding either surface changes a chapter of this book in the same pull request; see Keeping this book current.
Add a page
The manifest is pm-stack/aggregator/src/pages.ts. Its header states the mechanism: every dashboard page is a registered entry there; the navigation bar and the home-page dropdown render from this list, never hard-coded per view; and nothing else registers the page — nav, dropdown, and manifest are the same list. The header calls the recipe a ~30-minute recipe. The steps:
- Add one entry to
PAGESinpages.ts. An entry is aPageDef:id,title,route,api(the page’s/api/*.jsontwin, when one exists),blurb,group, andnav. Thegroupvalue names one of the fourPAGE_GROUPSids in the same file:overview,work,ops,system. Thenavvalue isprimaryordropdown, under the #1497 curation recorded in the file: primary pages earn a top-nav slot; dropdown pages are reachable from the Pages dropdown and their drill-down parents. - Add the render function in
pm-stack/aggregator/src/render.ts. - Add the route branch in
pm-stack/aggregator/src/server.ts, plus the/apitwin route when the entry declares one. The twin serves the same assembly as the page; the health assembly behind/healthand/api/healthis the standing example of one assembly feeding both forms. - Wire the data. If the page needs data the aggregator does not already hold, add it to the
Sourceinterface inpm-stack/aggregator/src/source.ts, with a live reader and a fixture fallback. Live readers live inpm-stack/aggregator/src/sources/— one file per source (live.ts,projector.ts,ready-for-agent.ts,repo-roadmap.ts,opencode.ts). - Register any detail route. A page with a per-item detail form adds an entry to
SUBROUTE_PARENTSinpages.ts:name,prefix,parent. That entry puts the detail renders inside the #1147 render registry that/api/healthreports. A detail page missing from the map renders outside the registry — the decision-set detail page is the standing example of that gap (D8):/decisions/<setId>exists, its parent is/decisionsby navigation, andSUBROUTE_PARENTSdoes not list it, somanifestRouteFor("/decisions/…")returns null for it. - Test and document in the same change. Add the page’s tests under
pm-stack/aggregator/test/in the suite’s existing shape (see Building and testing), and update The aggregator website, page by page — that chapter is a 1:1 census of the manifest, so a new page without a new entry there leaves the book wrong.
Three manifest facts bound the recipe:
- The
apifield is not automatic. Three surveyed pages declare no twin. Thedecisionsentry is one of them, and the server nevertheless implements a decisions API —/api/decisions/<setId>/submit,/defer,/request-info,/events, and/api/decision-sets(D7). A manifest entry records the page’s declared twin; it is not the server’s route table. Checkserver.tsbefore stating that a page has no API. - A redirect is a manifest outcome, not a page.
/projectsis not a page: its manifest comment and its route branch redirect to the projects-pool section of/program, preserving the view parameters, while/api/projects.jsonstill serves. A merged page follows that shape — redirect entry in the manifest, machine twin kept. - The All pages page is the manifest rendered.
/pagesshows every registered view in one place. A correct entry appears there with no further work; an entry that does not appear there is not registered.
The console is a separate surface
A console view is not a manifest entry. Console views are the VIEWS map in pm-stack/console/public/app.js, served by pm-stack/console/src/server.ts under /console, with server-side data in pm-stack/console/src/ (work.ts, ops.ts, plan.ts). The surveyed console has 21 hash views. Adding one is a console change — view function in app.js, data and actions on the server side, tests in pm-stack/console/test/ — and it updates The console, view by view in the same change. Do not register a console view in pages.ts, and do not register an aggregator page in VIEWS.
Add a projection
A projection is a derived read model: data reshaped from a source of truth the projection does not own. Two homes exist, and the choice is the first step of the procedure.
In the projector
The projector (pm-stack/projector/) is the stack’s projection service. Its contract, in its own README: it links and projects; it never becomes a fifth source of truth and never writes back to GitHub, Kaneo, Pad, or Grist. To add a projection there:
- State the source event or poll that proves each field. The projector’s rule is exact: a projection writes only what the event proves; an absent field proves nothing. Webhook intake is
POST /github/webhook(HMAC-checked, deduplicated by delivery GUID); reconcile polls insrc/reconcile.tsandsrc/cli.tsself-heal the projection beyond webhook delivery. - Add the storage. Projector storage is SQL: schema in
pm-stack/projector/schema.sql(thepmp_tables), read views in the same file (the standing views arepmp_v_links_itemsandpmp_v_subject_activity). Idempotent upserts key the writes. - Expose the read. The standing read shapes are
GET /items,GET /comments,GET /subjects/<subject>, and the link registryGET|POST|DELETE /links. A new projection follows those shapes or adds a route in the same style in the projector’s server. - Classify rebuildability before writing. The shared-schema map draws the line this step applies: the projector’s item and comment projections are rebuildable from GitHub;
pmp_links— the human- and agent-written subject-to-GitHub links — is the one non-rebuildable cross-service relationship in the projector schema, and it carries the registry backup legs for that reason. A new projection that stores a non-rebuildable relationship states that fact and its backup route in the same change. See The shared schema. - Consume it from the aggregator through its source reader. The aggregator reads the projector through
pm-stack/aggregator/src/sources/projector.ts(links and latest comments per subject). A projector projection the dashboard shows is wired there, under theSourceinterface, not read from the projector’s database by the aggregator directly. - Test in the projector’s suite (
pm-stack/projector/test/, run by the stack workflow) and update The projector and projections in the same change.
In the aggregator
A projection that only the dashboard consumes, over data the aggregator already polls, lives in the aggregator as a source reader plus a derived view:
- Add the reader as a file in
pm-stack/aggregator/src/sources/, registered on theSourceinterface with a live reader and a fixture fallback (step 4 of the page recipe). - Name the subject scheme. Aggregator items join on registry subjects:
gh:…,kaneo:<slug>/<id>,grist:<docId>/Roadmap/<recId>,session:…,orch:…. A projection over a new source states its subject form in the reader. - State the merge rule. Sources disagree, and the aggregator surfaces disagreement instead of hiding it: the
/conflictspage lists every live source disagreement with both values and its age. A projection that merges two sources states which value wins and where the losing value shows. The roadmap merge is the standing example: on a title collision between a repository roadmap file and a Grist row, the repository file wins, the Grist duplicate is noted in provenance, and its links are unioned in (#1738). - Record provenance. Every aggregator surface carries a provenance string stating whether its data is live and from which source. A new projection produces one; the provenance-matrix check (
bun run provenance:check) is part of the test route.
What neither procedure does
Neither procedure creates a new source of truth inside the stack. The aggregator reads its sources; the projector links and projects; Project fields have one writer, the orchestrator, and a dashboard status change travels as a status-request action for the orchestration pass to apply. A change that needs a new durable store is a shared-schema change, not a page or projection change; it starts from The shared schema and the store record in the reference part’s data-stores chapter.
Sources. pm-stack/aggregator/src/pages.ts (file header, PageDef, PAGE_GROUPS, SUBROUTE_PARENTS, manifestRouteFor), read on the laptop clone at 44aaf73; survey files ~/workspace/pm-book/survey/website-pages.md (§A, §B), ~/workspace/pm-book/survey/apps.md (§5, §7), ~/workspace/pm-book/survey/roadmap.md (§2), ~/workspace/pm-book/survey/disagreements.md (D7, D8); repo paths pm-stack/projector/README.md, pm-stack/projector/schema.sql, pm-stack/aggregator/src/source.ts, pm-stack/aggregator/src/sources/projector.ts.