From 9c077137ee10afff6c0742183568bdddaeb9695c Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 3 Oct 2026 21:14:47 +0000 Subject: [PATCH 1/5] W6 T1 (eng), T1 (DX): shared transcript consent policy and value grammar lib/transcript-consent.ts reads transcript_ingest_mode and transcript_repos together from every merged state root and returns one policy: off in any root is off, cutoffs and 90-day windows stack, allowlists intersect (EMPTY denies), and a +repos marker without a readable allowlist denies. It also owns the per-session and per-page scope checks, the staged-page purge and the unpublished-range guard, with a --check/--describe/--purge/ --guard-unpublished CLI for gstack-brain-sync. state-root exports its per-root key reader; transcript_ingest_mode stays out of MERGED_CONFIG_KEYS. --- lib/state-root.ts | 2 +- lib/transcript-consent.ts | 425 ++++++++++++++++++++++++++++++++ test/transcript-consent.test.ts | 285 +++++++++++++++++++++ 3 files changed, 711 insertions(+), 1 deletion(-) create mode 100644 lib/transcript-consent.ts create mode 100644 test/transcript-consent.test.ts diff --git a/lib/state-root.ts b/lib/state-root.ts index a0b178060..34a0fa756 100644 --- a/lib/state-root.ts +++ b/lib/state-root.ts @@ -55,7 +55,7 @@ export const MERGED_CONFIG_KEYS: Record = { }; /** Same parse as `gstack-config get`: last `^key:` line wins, value trimmed, empty = unset. */ -function readKeyFromRoot(root: string, key: string): string | null { +export function readKeyFromRoot(root: string, key: string): string | null { let yaml: string; try { yaml = fs.readFileSync(`${root}/config.yaml`, 'utf-8'); diff --git a/lib/transcript-consent.ts b/lib/transcript-consent.ts new file mode 100644 index 000000000..8f39dd3c5 --- /dev/null +++ b/lib/transcript-consent.ts @@ -0,0 +1,425 @@ +/** + * transcript-consent — the one reader of transcript consent. Reads + * `transcript_ingest_mode` and `transcript_repos` together from every root in + * mergedStateRoots() and returns one policy that gstack-memory-ingest, + * gstack-gbrain-sync and gstack-brain-sync (through this file's CLI) share. + * + * Value grammar: `[@][+repos]`, base recent | all | + * off | new. `@