mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-04 05:47:59 +01:00
* feat(entities): stub companies from the relation graph, and a lab entity kind Stub companies: every minted company:<slug> node a stated or corroborated relation touches (1,188 today; NAC Kazatomprom JSC, JV Inkai LLP, Uranium One Inc.) becomes an entity built from the graph at load, with evidence "stub", a page on the existing /markets/[slug] route that lists only the relations naming it (grade, quote, source), and the note that no profile is held. Rendered on demand, so the static page count is unchanged. The graph's producers resolve against the directory only (resolveInDirectory), so the stubs never change the graph they come from. Search and retrieval rank stubs at 0.6 and leave word rarity to full-weight documents, so profiled rankings do not move. Events and relations may name a stub; ownership and facility operator fields stay directory-only. Reviewed aliases redirect to the canonical page. Labs: a closed-set `lab` kind (allowEmpty until the pilot fills it), the labs candidate facet with schema and add.ts gate, a /labs/[slug] profile (what it works on, where and how to join, stated funders from finances relations), the lab dossier on lab:<id> with research fronts kept as their own science kind, and the country people_labs box counting lab rows. Seeds no lab data. Person is not added: the ADR pins it for office and board holders, not lab staff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * test(stubs): assert the summary's invariants, not its tail Main now carries the pilot's Kazatomprom relations, so its stub summary names a second source and the shipments. The test keeps what must hold: the yearbook leads, the stakes and the shipments are named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE --------- Co-authored-by: Claude <noreply@anthropic.com>
70 lines
2.6 KiB
TypeScript
70 lines
2.6 KiB
TypeScript
/**
|
|
* Print the work queue: one task per empty or thin dossier box.
|
|
*
|
|
* pnpm exec tsx scripts/research/gaps.ts [--kind country|company|resource|lab|science]
|
|
* [--entity country:kz] [--box facilities] [--limit 20] [--out tasks.json]
|
|
*
|
|
* JSON to stdout (an array of tasks, ordered by demand, then the owner's
|
|
* country order); with --out, the same bytes are also written to that file.
|
|
* Each task carries `instruction`, the text a data agent needs, and points at
|
|
* `scripts/research/add.ts`, which stays the only gate. See prompts/data-entry.md.
|
|
*
|
|
* Deterministic: the same corpus gives the same output.
|
|
*/
|
|
import { writeFile } from 'node:fs/promises';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
import { DOSSIER_KINDS, type DossierKind } from '../../lib/dossier/definitions';
|
|
import { demandLedger } from '../../lib/dossier/demand';
|
|
import { emitTasks, type EmitOptions } from '../../lib/dossier/tasks';
|
|
|
|
export interface GapsArgs extends EmitOptions {
|
|
out?: string;
|
|
}
|
|
|
|
/** Parse argv; throws with a usage line on anything it does not know. */
|
|
export function parseGapsArgs(argv: readonly string[]): GapsArgs {
|
|
const args: GapsArgs = {};
|
|
for (let i = 0; i < argv.length; i += 1) {
|
|
const flag = argv[i];
|
|
const value = argv[i + 1];
|
|
if (value === undefined || value.startsWith('--')) throw new Error(`${flag} needs a value`);
|
|
i += 1;
|
|
if (flag === '--kind') {
|
|
if (!(DOSSIER_KINDS as readonly string[]).includes(value))
|
|
throw new Error(`--kind must be one of ${DOSSIER_KINDS.join(', ')}`);
|
|
args.kind = value as DossierKind;
|
|
} else if (flag === '--entity') args.entity = value;
|
|
else if (flag === '--box') args.box = value;
|
|
else if (flag === '--out') args.out = value;
|
|
else if (flag === '--limit') {
|
|
const n = Number(value);
|
|
if (!Number.isInteger(n) || n < 0) throw new Error('--limit must be a whole number');
|
|
args.limit = n;
|
|
} else throw new Error(`unknown flag ${flag}`);
|
|
}
|
|
return args;
|
|
}
|
|
|
|
/** The output, as the script prints it. */
|
|
export function gapsJson(args: GapsArgs): string {
|
|
return `${JSON.stringify(emitTasks({ ...args, demand: demandLedger() }), null, 2)}\n`;
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
let args: GapsArgs;
|
|
try {
|
|
args = parseGapsArgs(process.argv.slice(2));
|
|
} catch (error) {
|
|
process.stderr.write(
|
|
`${(error as Error).message}\nusage: gaps.ts [--kind k] [--entity id] [--box b] [--limit n] [--out file]\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
const json = gapsJson(args);
|
|
process.stdout.write(json);
|
|
if (args.out) await writeFile(args.out, json);
|
|
}
|
|
|
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) void main();
|