Files
autocraft/src/hidden-sql.ts
T
aiongg 31b7fbba75 Dashboard readers get only what they may see of the planner's stored text, and expensive GETs are limited by the matched route
- One reader helper (src/dash/api/reader.ts) cuts queue rows, plan reasons, waits and status lines per reader: viewers get no review reason, verification text, plan note or refusal text and the reasons without their quoted part; a quiet pull request gives viewers none of it; nobody reads an item of a repo hidden from them ("another item, which blocks its review").
- The merge queue endpoints and their member lookups filter with the requester's allow-list, so batches and queued PRs of untracked repos are left out for everyone but operators.
- Decision facts name no PR of a hidden repo; the item API leaves out owner statements of hidden repos and gives viewers no excerpt or reason.
- The Needs feed blanks feedback about a quiet pull request for viewers; stopped fix reasons are staff only.
- Agent runs recorded without items are shown to operators only; duplicate comparisons are bound to the items they compare.
- The expensive-GET budget is spent by the matched route, so every spelling of a path counts.
- Limiter maps are capped: expired keys go at most once per window, then the oldest.
- /healthz/checks gives anonymous callers check names and states; signed-in operators and maintainers also get times and counts.
2026-11-14 23:21:57 +00:00

20 lines
1.4 KiB
TypeScript

// Repo filters for viewers who may not see every repo. A list from the dashboard's `hiddenRepos` carries the repos the viewer
// may see in `visible`; the filters then allow only those. A plain list of names is a denylist.
export type HiddenRepos = string[] & { visible?: string[] };
/** Whether any filter applies (operators get an empty list without `visible`). */
export const filtered = (h: HiddenRepos): boolean => !!h.visible || h.length > 0;
/** SQL true when the repo in `col` is hidden, with its `?` arguments. */
export function hiddenTest(col: string, h: HiddenRepos): { sql: string; args: string[] } {
if (h.visible) return h.visible.length ? { sql: `${col} NOT IN (${h.visible.map(() => "?").join(",")})`, args: h.visible } : { sql: "1", args: [] };
return { sql: `${col} IN (${h.map(() => "?").join(",")})`, args: [...h] };
}
export const isHiddenRepo = (h: HiddenRepos, repo: string): boolean => (h.visible ? !h.visible.includes(repo) : h.includes(repo));
/** `hiddenTest` with one JSON list argument bound at `param` (`?` or a named one), for queries that bind by name or keep one argument per filter. */
export function hiddenJsonTest(col: string, h: HiddenRepos, param = "?"): { sql: string; arg: string } {
return h.visible ? { sql: `${col} NOT IN (SELECT value FROM json_each(${param}))`, arg: JSON.stringify(h.visible) } : { sql: `${col} IN (SELECT value FROM json_each(${param}))`, arg: JSON.stringify([...h]) };
}