Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pm-stack/aggregator/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const PAGES: PageDef[] = [
title: "Search",
route: "/search",
api: "/api/search.json",
blurb: "Search board and roadmap work by title or linked issue/PR ref.",
blurb: "Search board, roadmap, registry sessions, DNS, services, and tier items by title or linked issue/PR ref.",
group: "work",
nav: "dropdown",
},
Expand Down
29 changes: 23 additions & 6 deletions pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ import { blockedSummary, depthLayout, hasGraphEdges } from "./graph.ts";
import { EPIC_GRAPH_DEFAULT_CAP, epicGraph, epicSelector } from "./epic-graph.ts";
import { type AuthorIdentity } from "./registry.ts";
import type { SearchResult } from "./search-view.ts";
import { dnsAnchor } from "./search-view.ts";

export function esc(s: unknown): string {
return String(s ?? "")
Expand Down Expand Up @@ -492,7 +493,7 @@ function layout(
</main><script src="/assets/push-client.js?v=push-ux-2026-11-01" defer></script>${extra}${paletteHtml()}${KEYBOARD_SCRIPT}</body></html>`;
}

/** First-slice global search over board/roadmap subjects and linked refs. */
/** Global search over board/roadmap subjects, linked refs, and the slice-2 sources (#1212): registry sessions, the DNS register, services, and tier items. */
export function renderSearch(
query: string,
results: SearchResult[],
Expand All @@ -505,22 +506,38 @@ export function renderSearch(
const badges = result.refs
.map((ref) => {
const item = items.get(ref);
// Codex P1 on PR #7331 (defense in depth): a non-GitHub ref
// (tracked-goal id, orch: key) must never reach refUrl, which
// throws on it — render it as a plain-text badge instead.
return item
? itemBadge(item)
: `<a class="badge closed" href="${esc(refUrl(ref))}" title="Unresolved by the current item source">${esc(ref)} · unresolved</a>`;
: isValidRef(ref)
? `<a class="badge closed" href="${esc(refUrl(ref))}" title="Unresolved by the current item source">${esc(ref)} · unresolved</a>`
: `<span class="badge closed">${esc(ref)} · unresolved</span>`;
})
.join(" ");
return `<div class="card"><a href="/item/${encodeURIComponent(result.id)}"><strong>${esc(result.title)}</strong></a><br><span class="muted">${result.kind} · ${esc(result.summary)}</span>${badges ? `<div class="strip">${badges}</div>` : ""}</div>`;
return `<div class="card"><a href="${esc(result.href)}"><strong>${esc(result.title)}</strong></a><br><span class="muted">${result.kind} · ${esc(result.summary)}</span>${badges ? `<div class="strip">${badges}</div>` : ""}</div>`;
})
.join("");
const body = `<h1>Search</h1><p class="muted">Search board items and roadmap rows by subject, title, or linked issue/PR ref. Linked GitHub badges show their current projected state and whether the result is fixture-only.</p><form class="search-page-form" action="/search" method="get" role="search"><label for="search-query">Search work</label><input id="search-query" type="search" name="q" value="${esc(query)}" placeholder="Title or owner/repo#123"><button type="submit" class="btn btn-sm">Search</button></form>${query ? `<h2>${results.length} result${results.length === 1 ? "" : "s"} for “${esc(query)}”</h2>${cards || '<p class="muted">No matching work found.</p>'}` : '<p class="muted">Enter a title or issue/PR reference to search.</p>'}`;
const body = `<h1>Search</h1><p class="muted">Search board items, roadmap rows, registry sessions, DNS domains, services, and tier items by subject, title, or linked issue/PR ref. Every result links to its own detail view. Linked GitHub badges show their current projected state and whether the result is fixture-only.</p><form class="search-page-form" action="/search" method="get" role="search"><label for="search-query">Search work</label><input id="search-query" type="search" name="q" value="${esc(query)}" placeholder="Title or owner/repo#123"><button type="submit" class="btn btn-sm">Search</button></form>${query ? `<h2>${results.length} result${results.length === 1 ? "" : "s"} for “${esc(query)}”</h2>${cards || '<p class="muted">No matching work found.</p>'}` : '<p class="muted">Enter a title or issue/PR reference to search.</p>'}`;
// #1212 slice 2: the search page carries the same freshness facets
// as the home page of each result kind present (board/roadmap/items
// for work, registry for sessions, dns for the register, quota and
// usage for services, orchestration/attention/registry for tiers).
const chipKeys = new Set<keyof Provenance>(["board", "roadmap", "items"]);
for (const result of results) {
if (result.kind === "registry") chipKeys.add("registry");
if (result.kind === "dns") chipKeys.add("dns");
if (result.kind === "service") { chipKeys.add("quota"); chipKeys.add("usage"); }
if (result.kind === "tier") { chipKeys.add("orchestration"); chipKeys.add("attention"); chipKeys.add("registry"); }
}
return layout(
"Search",
body,
provenance,
"/search",
"",
detail ? freshnessChips(detail, ["board", "roadmap", "items"]) : "",
detail ? freshnessChips(detail, [...chipKeys]) : "",
);
}

Expand Down Expand Up @@ -3840,7 +3857,7 @@ function dnsTable(entries: DnsEntry[], renewingSoon: Set<DnsEntry>, nextRenewal?
const rows = entries
.map(
(e) =>
`<tr${e === nextRenewal ? ' id="dns-next-renewal"' : ""} data-dns-row data-dns-status="${esc(e.status)}" data-dns-renewing-soon="${renewingSoon.has(e)}"><td><strong>${esc(e.domain)}</strong></td><td>${esc(e.renewal)}</td><td>${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}</td><td>${esc(e.autoRenew)}</td><td>${esc(e.plan)}</td><td>${esc(e.review)}</td></tr>`,
`<tr${e === nextRenewal ? ' id="dns-next-renewal"' : ""} data-dns-row data-dns-status="${esc(e.status)}" data-dns-renewing-soon="${renewingSoon.has(e)}"><td><strong id="${esc(dnsAnchor(e.domain))}">${esc(e.domain)}</strong></td><td>${esc(e.renewal)}</td><td>${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}</td><td>${esc(e.autoRenew)}</td><td>${esc(e.plan)}</td><td>${esc(e.review)}</td></tr>`,
)
.join("");
return `<div class="tblwrap"><table id="dns-register-table"><caption>Domain register</caption><thead><tr><th scope="col">Domain</th><th scope="col">Next renewal</th><th scope="col">Price (list)</th><th scope="col">Auto-renew</th><th scope="col">Plan / status</th><th scope="col">Review?</th></tr></thead><tbody>${rows || '<tr><td colspan="6" class="muted">none</td></tr>'}</tbody></table></div>`;
Expand Down
130 changes: 125 additions & 5 deletions pm-stack/aggregator/src/search-view.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,68 @@
import type { BoardItem, GhItem, RefKey, RoadmapRow } from "./model.ts";
import type { BoardItem, DnsSection, GhItem, RefKey, RoadmapRow, SaasService, SessionRecord, TierItem } from "./model.ts";
import { isValidRef } from "./model.ts";

export interface SearchResult {
kind: "board" | "roadmap";
kind: "board" | "roadmap" | "registry" | "dns" | "service" | "tier";
id: string;
title: string;
summary: string;
refs: RefKey[];
/** Stable detail view for this result (#1212 slice 2): every kind
* links to its own home detail route, not /item/<id> for all. */
href: string;
}

function includesQuery(query: string, values: (string | undefined)[]): boolean {
return values.some((value) => value?.toLowerCase().includes(query));
/** The non-board/roadmap subjects slice 2 adds, all optional so
* first-slice callers and fixtures keep working unchanged. */
export interface SearchExtras {
registry?: SessionRecord[];
dns?: DnsSection | null;
services?: SaasService[];
tierItems?: TierItem[];
}

/** Search the first-slice canonical subjects and their projected GitHub refs. */
function includesQuery(query: string, values: unknown[]): boolean {
// Codex P2 on PR #7331: accepted records can carry non-string optional
// fields (an unvalidated registry `model: 7`, a DNS `registrar`, ...);
// `value?.toLowerCase()` only guards nullish values and threw on those,
// taking down /search and /api/search.json for every query that reached
// the field. Only strings are searchable.
return values.some((value) => typeof value === "string" && value.toLowerCase().includes(query));
}

/** Anchor id for a register row on /dns (dnsTable renders the same id). */
export function dnsAnchor(domain: string): string {
return `dns-${domain.toLowerCase()}`;
}

/** The stable session view: the registry page filtered to one record. */
function sessionHref(id: string): string {
return `/sessions?id=${encodeURIComponent(id)}#${encodeURIComponent(id)}`;
}

/** Mirror of render.ts tierItemObjectRef, kept local so the search
* view stays free of render imports: watchdog items key by their own
* id, ref-carrying items by their gh: ref, the rest by orch: id. */
function tierObjectRef(item: TierItem): string {
if (item.source === "watchdog") return `orch:${item.id}`;
return item.ref ? `gh:${item.ref}` : `orch:${item.id}`;
}

function tierHref(item: TierItem): string {
if (item.sessionId) return sessionHref(item.sessionId);
return `/discuss/${encodeURIComponent(tierObjectRef(item))}`;
}

/** Search the canonical subjects and their projected GitHub refs.
* Slice 2 (#1212) adds the registry/session records, the DNS register,
* the usage-hub services, and the orchestration tier items, each
* linking to its stable detail view. */
export function searchWork(
board: BoardItem[],
rows: RoadmapRow[],
items: Map<RefKey, GhItem>,
rawQuery: string,
extras: SearchExtras = {},
): SearchResult[] {
const query = rawQuery.trim().toLowerCase();
if (!query) return [];
Expand All @@ -33,6 +78,7 @@ export function searchWork(
title: item.title,
summary: `${item.repo} · ${item.status}`,
refs,
href: `/item/${encodeURIComponent(item.id)}`,
});
}
}
Expand All @@ -59,6 +105,80 @@ export function searchWork(
title: row.title,
summary: `${row.area} · ${row.status} · ${row.horizon}`,
refs,
href: `/item/${encodeURIComponent(row.subject)}`,
});
}
}

for (const record of extras.registry ?? []) {
const title = record.label || record.title || record.id;
if (
includesQuery(query, [
record.id,
record.label,
record.title,
record.agentId,
record.agentLabel,
record.status,
record.model,
record.directory,
Comment on lines +123 to +124

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard optional search fields before lowercasing them

When an accepted registry record contains a non-string optional field such as model: 7, a query that does not match an earlier field reaches this value in includesQuery and throws because value?.toLowerCase() only guards against nullish values. isSessionRecord does not validate optional model, title, or directory, so these values can survive ingestion even though the existing sessions renderer safely escapes them. The new DNS matching path has the same problem with fields such as registrar, whose type isDnsSection does not check. One such record therefore breaks both /search and /api/search.json, despite the source-fetch failure handlers. Check that searchable values are strings or sanitize these fields before matching.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 0ba2dc9 (task 12609, lane code-e): includesQuery now only matches values that are actually strings (typeof check), so a non-string optional field (registry model: 7, a numeric DNS registrar) is skipped instead of throwing on .toLowerCase(). Regression tests cover both the registry and DNS matching paths.

...record.taskRefs,
])
) {
results.push({
kind: "registry",
id: record.id,
title,
summary: `${record.agentLabel} · ${record.status}`,
refs: record.taskRefs.filter(isValidRef),
href: sessionHref(record.id),
});
}
}

for (const entry of extras.dns?.entries ?? []) {
if (
includesQuery(query, [entry.domain, entry.registrar, entry.dnsHost, entry.plan, entry.used, entry.review, entry.status])
) {
results.push({
kind: "dns",
id: entry.domain,
title: entry.domain,
summary: `${entry.registrar} · ${entry.status} · renews ${entry.renewal}`,
refs: [],
href: `/dns#${dnsAnchor(entry.domain)}`,
});
}
}

for (const svc of extras.services ?? []) {
if (includesQuery(query, [svc.id, svc.name, svc.plan, svc.status, svc.group])) {
results.push({
kind: "service",
id: svc.id,
title: svc.name,
summary: `${svc.group} · ${svc.plan}`,
refs: [],
href: `/quota/service/${encodeURIComponent(svc.id)}`,
});
}
}

for (const item of extras.tierItems ?? []) {
if (
includesQuery(query, [item.id, item.title, item.kind, item.source, item.state, item.reason, item.ref, item.sessionId])
) {
results.push({
kind: "tier",
id: item.id,
title: item.title,
summary: `${item.source} · ${item.state ?? item.kind}`,
// Codex P1 on PR #7331: a tier ref can be a tracked-goal id or
// another non-GitHub key; passing it on as a badge ref made
// renderSearch's refUrl throw and failed the whole /search
// request. Only owner/repo#N refs become GitHub badges.
refs: item.ref && isValidRef(item.ref) ? [item.ref] : [],
href: tierHref(item),
});
}
}
Expand Down
24 changes: 21 additions & 3 deletions pm-stack/aggregator/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
type RoadmapReconciliation,
} from "./roadmap-reconcile.ts";
import type { Comment, DashComment, GhItem, ProjectPoolItem, QuotaView, RefKey, UsageView } from "./model.ts";
import { isValidRef } from "./model.ts";
import { buildEpicRollups } from "./epics.ts";
import { buildProgramData, programRefs } from "./program.ts";
import {
Expand Down Expand Up @@ -556,10 +557,27 @@ async function roadmapContext() {
}

async function searchContext(query: string) {
const [board, rows] = await Promise.all([source.board(), source.roadmap()]);
const refs = [...new Set([...allRefs(board), ...allRefs(rows)])];
// #1212 slice 2: registry, DNS, services, and tier items join the
// board/roadmap subjects. Each extra source fails soft (empty on
// error) so one broken source never takes search down with it.
const [board, rows, registry, dns, usage, orchestration] = await Promise.all([
source.board(),
source.roadmap(),
source.registry().catch(() => []),
source.dns().catch(() => null),
source.usage().catch(() => null),
source.orchestration().catch(() => null),
]);
const tierItems = orchestration ? [...orchestration.tiers.needsDrew, ...orchestration.tiers.needsOrchestrator] : [];
// Codex P2 on PR #7331: refs carried only by the slice-2 sources
// (registry taskRefs, tier-item refs) join the resolution set, or
// their search badges always render unresolved even when the live
// pool/projector could resolve them.
const extraRefs = [...registry.flatMap((record) => record.taskRefs), ...tierItems.map((item) => item.ref)].filter(isValidRef);
const refs = [...new Set([...allRefs(board), ...allRefs(rows), ...extraRefs])];
const items = await source.items(refs);
return { query, results: searchWork(board, rows, items, query), items };
const extras = { registry, dns, services: usage?.services ?? [], tierItems };
return { query, results: searchWork(board, rows, items, query, extras), items };
Comment on lines +571 to +580

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve refs from the newly added search sources

When a registry session or tier item references a GitHub issue that is absent from the board and roadmap, its search badge always renders as unresolved, even if the live project pool or projector can resolve it. searchContext still requests source.items() only for board/roadmap refs, and the live implementation returns only the requested refs, so the new results never receive their projected state. Include registry taskRefs and valid tier-item refs in the resolution set before constructing the results.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 0ba2dc9 (task 12609, lane code-e): searchContext now adds registry taskRefs and valid tier-item refs to the resolution set passed to source.items(), so badges for refs carried only by the slice-2 sources resolve against the live pool/projector instead of always rendering unresolved.

}

// #3321: watchdog gap-sync passes run whole and in observation
Expand Down
Loading
Loading