@indigoai-us/hq-cli 5.345.247 → 5.345.248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
- package/contracts/host-canary-release.json +14 -0
- package/dist/command-catalog.generated.d.ts +1113 -0
- package/dist/command-catalog.generated.js +1370 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/lanes-hold.js +7 -7
- package/dist/commands/lanes-resume.js +2 -2
- package/dist/commands/lanes-review.js +1 -1
- package/dist/commands/lanes-session-start.d.ts +1 -1
- package/dist/commands/lanes-session-start.js +3 -3
- package/dist/commands/lanes-shared.d.ts +1 -1
- package/dist/commands/lanes.d.ts +2 -2
- package/dist/commands/lanes.js +50 -50
- package/dist/commands/mesh.d.ts +25 -0
- package/dist/commands/mesh.js +48 -8
- package/dist/commands/ontology-graph.d.ts +62 -0
- package/dist/commands/ontology-graph.js +439 -0
- package/dist/index.js +1 -1
- package/dist/lanes-monitor-check-argv.d.ts +1 -1
- package/dist/lanes-monitor-check-argv.js +1 -1
- package/dist/lanes-monitor-check-fast.d.ts +1 -1
- package/dist/lanes-monitor-check-fast.js +1 -1
- package/dist/lanes-session-start-argv.d.ts +1 -1
- package/dist/lanes-session-start-argv.js +1 -1
- package/dist/lib/capacity/sign-in.d.ts +1 -1
- package/dist/lib/capacity/sign-in.js +1 -1
- package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
- package/dist/lib/daemon/lanes-monitor-state.d.ts +2 -2
- package/dist/lib/daemon/lanes-monitor-state.js +2 -2
- package/dist/lib/daemon/merge-sections.d.ts +3 -3
- package/dist/lib/daemon/merge-sections.js +7 -7
- package/dist/lib/daemon/remote-control-pools.js +1 -1
- package/dist/lib/daemon/run.js +1 -1
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.js +1 -1
- package/dist/lib/flag-snapshot-file.d.ts +2 -0
- package/dist/lib/flag-snapshot-file.js +118 -48
- package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
- package/dist/lib/hook-engine/canary-gate.js +138 -6
- package/dist/lib/hot-channels/graph-context.d.ts +105 -0
- package/dist/lib/hot-channels/graph-context.js +377 -0
- package/dist/lib/hot-channels/signals-pass.js +27 -1
- package/dist/lib/lanes/claude-credential.d.ts +1 -1
- package/dist/lib/lanes/claude-credential.js +1 -1
- package/dist/lib/lanes/delivery-core.d.ts +1 -1
- package/dist/lib/lanes/delivery-core.js +1 -1
- package/dist/lib/lanes/delivery.d.ts +10 -10
- package/dist/lib/lanes/delivery.js +8 -8
- package/dist/lib/lanes/dropbox.d.ts +1 -1
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/hooks-install.js +2 -2
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/index.js +1 -1
- package/dist/lib/lanes/monitor.js +1 -1
- package/dist/lib/lanes/quota-notice.js +1 -1
- package/dist/lib/lanes/quota.d.ts +1 -1
- package/dist/lib/lanes/quota.js +1 -1
- package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
- package/dist/lib/lanes/repo-merge-hold.js +2 -2
- package/dist/lib/lanes/spawn.d.ts +4 -4
- package/dist/lib/lanes/spawn.js +5 -5
- package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
- package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
- package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
- package/dist/lib/mesh/live/daemon/run.js +35 -2
- package/dist/lib/mesh/live/direct-drain.js +1 -1
- package/dist/lib/mesh/live/emit.d.ts +3 -0
- package/dist/lib/mesh/live/emit.js +32 -9
- package/dist/lib/mesh/live/flush.d.ts +3 -0
- package/dist/lib/mesh/live/flush.js +115 -32
- package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
- package/dist/lib/mesh/live/liveness-carry.js +1 -1
- package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
- package/dist/lib/mesh/live/reporting-privacy.js +235 -11
- package/dist/lib/mesh/live/spool.d.ts +17 -2
- package/dist/lib/mesh/live/spool.js +22 -6
- package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
- package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
- package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
- package/dist/lib/ontology-graph/legacy/index.js +1150 -0
- package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
- package/dist/lib/ontology-graph/legacy/parse.js +126 -0
- package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
- package/dist/lib/ontology-graph/legacy/report.js +254 -0
- package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
- package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
- package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
- package/dist/lib/ontology-graph/lint/checks.js +717 -0
- package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
- package/dist/lib/ontology-graph/lint/coverage.js +241 -0
- package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
- package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
- package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
- package/dist/lib/ontology-graph/lint/index.js +176 -0
- package/dist/lib/ontology-graph/model/files.d.ts +20 -0
- package/dist/lib/ontology-graph/model/files.js +89 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -0
- package/dist/lib/ontology-graph/model/index.js +100 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
- package/dist/lib/ontology-graph/model/pass.js +958 -0
- package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
- package/dist/lib/ontology-graph/model/runner.js +160 -0
- package/dist/lib/ontology-graph/model/step.d.ts +195 -0
- package/dist/lib/ontology-graph/model/step.js +523 -0
- package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
- package/dist/lib/ontology-graph/model/tasks.js +349 -0
- package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
- package/dist/lib/ontology-graph/not-implemented.js +8 -0
- package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
- package/dist/lib/ontology-graph/org/compare.js +239 -0
- package/dist/lib/ontology-graph/org/derive.d.ts +65 -0
- package/dist/lib/ontology-graph/org/derive.js +352 -0
- package/dist/lib/ontology-graph/org/index.d.ts +73 -0
- package/dist/lib/ontology-graph/org/index.js +513 -0
- package/dist/lib/ontology-graph/org/load.d.ts +31 -0
- package/dist/lib/ontology-graph/org/load.js +476 -0
- package/dist/lib/ontology-graph/org/role.d.ts +38 -0
- package/dist/lib/ontology-graph/org/role.js +268 -0
- package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
- package/dist/lib/ontology-graph/org/structure.js +437 -0
- package/dist/lib/ontology-graph/org/text.d.ts +95 -0
- package/dist/lib/ontology-graph/org/text.js +315 -0
- package/dist/lib/ontology-graph/org/types.d.ts +452 -0
- package/dist/lib/ontology-graph/org/types.js +80 -0
- package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
- package/dist/lib/ontology-graph/pages/index.js +193 -0
- package/dist/lib/ontology-graph/pages/render.d.ts +142 -0
- package/dist/lib/ontology-graph/pages/render.js +682 -0
- package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
- package/dist/lib/ontology-graph/proposals/apply.js +468 -0
- package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
- package/dist/lib/ontology-graph/proposals/group.js +232 -0
- package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
- package/dist/lib/ontology-graph/proposals/index.js +474 -0
- package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
- package/dist/lib/ontology-graph/proposals/model.js +196 -0
- package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
- package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
- package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
- package/dist/lib/ontology-graph/read/brief.js +251 -0
- package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
- package/dist/lib/ontology-graph/read/graph-index.js +198 -0
- package/dist/lib/ontology-graph/read/index.d.ts +59 -0
- package/dist/lib/ontology-graph/read/index.js +792 -0
- package/dist/lib/ontology-graph/read/member.d.ts +7 -0
- package/dist/lib/ontology-graph/read/member.js +34 -0
- package/dist/lib/ontology-graph/read/names.d.ts +44 -0
- package/dist/lib/ontology-graph/read/names.js +292 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
- package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
- package/dist/lib/ontology-graph/read/test-graph.js +150 -0
- package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
- package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
- package/dist/lib/ontology-graph/replay/config.js +105 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +100 -0
- package/dist/lib/ontology-graph/replay/engine.js +1174 -0
- package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
- package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
- package/dist/lib/ontology-graph/replay/index.d.ts +90 -0
- package/dist/lib/ontology-graph/replay/index.js +220 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
- package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
- package/dist/lib/ontology-graph/replay/member.js +65 -0
- package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
- package/dist/lib/ontology-graph/replay/mentions.js +239 -0
- package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
- package/dist/lib/ontology-graph/replay/readers.js +1251 -0
- package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
- package/dist/lib/ontology-graph/replay/rules.js +374 -0
- package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
- package/dist/lib/ontology-graph/replay/scope.js +115 -0
- package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
- package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
- package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
- package/dist/lib/ontology-graph/replay/util.js +256 -0
- package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
- package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
- package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
- package/dist/lib/ontology-graph/resolve/index.js +214 -0
- package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
- package/dist/lib/ontology-graph/resolve/machine.js +95 -0
- package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
- package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
- package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
- package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
- package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
- package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
- package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
- package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
- package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
- package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
- package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
- package/dist/lib/ontology-graph/resolve/roster.js +226 -0
- package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
- package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
- package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
- package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
- package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
- package/dist/lib/ontology-graph/resolve/writer.js +351 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +73 -0
- package/dist/lib/ontology-graph/schema/authority.js +157 -0
- package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
- package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
- package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
- package/dist/lib/ontology-graph/schema/grammar.js +409 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
- package/dist/lib/ontology-graph/schema/index.js +10 -0
- package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
- package/dist/lib/ontology-graph/schema/validate.js +132 -0
- package/dist/lib/ontology-graph/store/files.d.ts +34 -0
- package/dist/lib/ontology-graph/store/files.js +207 -0
- package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
- package/dist/lib/ontology-graph/store/fs.js +101 -0
- package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
- package/dist/lib/ontology-graph/store/graph-store.js +520 -0
- package/dist/lib/ontology-graph/store/index.d.ts +18 -0
- package/dist/lib/ontology-graph/store/index.js +15 -0
- package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
- package/dist/lib/ontology-graph/store/ingest.js +323 -0
- package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
- package/dist/lib/ontology-graph/store/paths.js +232 -0
- package/dist/lib/ontology-graph/types.d.ts +1183 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- package/dist/utils/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,1183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ontology graph: shared types (WP-A).
|
|
3
|
+
*
|
|
4
|
+
* Every package under src/lib/ontology-graph/ codes against this file. After
|
|
5
|
+
* the first publish, changes here are additive only. The on-disk layout, the
|
|
6
|
+
* row grammar and package ownership are described in CONTRACT.md beside it.
|
|
7
|
+
*
|
|
8
|
+
* Conventions:
|
|
9
|
+
* - Rows are plain serializable objects. String-typed stamps (`src`, `by`,
|
|
10
|
+
* entity refs) use the exact text that appears in the markdown file, so a
|
|
11
|
+
* row can be built with literals: `{ src: "signal:4f35becbeabe", by: "legacy" }`.
|
|
12
|
+
* - Dates are calendar days, `YYYY-MM-DD`, in UTC.
|
|
13
|
+
* - The audience key is not part of a row. It is the `facts/@{key}/` folder
|
|
14
|
+
* the row lives in, and travels beside the row as `StoredRow.audience`.
|
|
15
|
+
*/
|
|
16
|
+
/** Calendar day, `YYYY-MM-DD`. */
|
|
17
|
+
export type IsoDate = string;
|
|
18
|
+
/** ISO-8601 timestamp with time, used only in logs, ledger and proposals. */
|
|
19
|
+
export type IsoTimestamp = string;
|
|
20
|
+
/**
|
|
21
|
+
* Entity types that live in the graph folder. The four accounting types
|
|
22
|
+
* (account, journal-entry, ar-invoice, ap-bill) are not here on purpose: they
|
|
23
|
+
* stay in the old `ontology/entities/` folder and are never replayed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const GRAPH_ENTITY_TYPES: readonly ["person", "team", "role", "project", "product", "company", "meeting", "decision", "concept", "tool", "contact", "deal", "contract", "invoice"];
|
|
26
|
+
export type GraphEntityType = (typeof GRAPH_ENTITY_TYPES)[number];
|
|
27
|
+
/** `<type>/<slug>`, for example `person/corey-epstein`. This is the entity id. */
|
|
28
|
+
export type EntityRef = `${GraphEntityType}/${string}`;
|
|
29
|
+
/**
|
|
30
|
+
* Audience key of a source: `company`, or the 16 hex key of a scoped audience.
|
|
31
|
+
* A source with no audience is skipped by the replay, never defaulted.
|
|
32
|
+
*/
|
|
33
|
+
export type AudienceKey = string;
|
|
34
|
+
export declare const COMPANY_AUDIENCE: AudienceKey;
|
|
35
|
+
export declare const SOURCE_REF_KINDS: readonly ["signal", "source", "doc", "session", "record", "legacy"];
|
|
36
|
+
export type SourceRefKind = (typeof SOURCE_REF_KINDS)[number];
|
|
37
|
+
/**
|
|
38
|
+
* `signal:<12 hex>`, `source:<path>`, `doc:<path>`, `session:<thread id>`,
|
|
39
|
+
* `record:<system>:<id>` or `legacy:<old entity id 12 hex>`.
|
|
40
|
+
*/
|
|
41
|
+
export type SourceRef = `${SourceRefKind}:${string}`;
|
|
42
|
+
export interface ParsedSourceRef {
|
|
43
|
+
kind: SourceRefKind;
|
|
44
|
+
/** Everything after the first colon. */
|
|
45
|
+
value: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const ORIGIN_KINDS: readonly ["human", "record", "rule", "agent", "legacy"];
|
|
48
|
+
export type OriginKind = (typeof ORIGIN_KINDS)[number];
|
|
49
|
+
/** `human:<prs id>`, `record`, `rule:<rule id>`, `agent:<model>` or `legacy`. */
|
|
50
|
+
export type Origin = `human:${string}` | "record" | `rule:${string}` | `agent:${string}` | "legacy";
|
|
51
|
+
export interface ParsedOrigin {
|
|
52
|
+
kind: OriginKind;
|
|
53
|
+
/** prs id, rule id or model name. Empty for `record` and `legacy`. */
|
|
54
|
+
id: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Authority tier of an origin (design 2.7). 1 is highest. For one entity and
|
|
58
|
+
* field, the open row with the lowest tier number is the answer. A lower
|
|
59
|
+
* authority row never closes a higher authority row.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ORIGIN_TIER: Readonly<Record<OriginKind, 1 | 2 | 3 | 4 | 5>>;
|
|
62
|
+
/** Confidence, 0 to 1 inclusive. Written with two decimals. */
|
|
63
|
+
export type Confidence = number;
|
|
64
|
+
/** When the fact was true. An open row has no `to`. */
|
|
65
|
+
export interface Validity {
|
|
66
|
+
/** valid_from */
|
|
67
|
+
from: IsoDate;
|
|
68
|
+
/** valid_to. Absent while the row is open. */
|
|
69
|
+
to?: IsoDate;
|
|
70
|
+
}
|
|
71
|
+
/** Set when a row is closed. Rows are never deleted. */
|
|
72
|
+
export interface RowClosure {
|
|
73
|
+
on: IsoDate;
|
|
74
|
+
by: SourceRef;
|
|
75
|
+
}
|
|
76
|
+
/** The stamps every F and E row carries. All are required to write a row. */
|
|
77
|
+
export interface RowStamps {
|
|
78
|
+
valid: Validity;
|
|
79
|
+
/** Citation. A row with an empty `src` is refused by the store. */
|
|
80
|
+
src: SourceRef;
|
|
81
|
+
/** learned_at: the day the graph recorded the row. */
|
|
82
|
+
learned: IsoDate;
|
|
83
|
+
by: Origin;
|
|
84
|
+
conf: Confidence;
|
|
85
|
+
closed?: RowClosure;
|
|
86
|
+
}
|
|
87
|
+
/** `- F <field> = <value> | valid .. | src .. | learned .. | by .. | conf ..` */
|
|
88
|
+
export interface FactRow extends RowStamps {
|
|
89
|
+
kind: "F";
|
|
90
|
+
/** Must be listed for the entity's type in schema.yaml. */
|
|
91
|
+
field: string;
|
|
92
|
+
/** Single line. May not be empty. */
|
|
93
|
+
value: string;
|
|
94
|
+
}
|
|
95
|
+
/** `- E <verb> -> <type>/<slug> | valid .. | src .. | learned .. | by .. | conf ..` */
|
|
96
|
+
export interface EdgeRow extends RowStamps {
|
|
97
|
+
kind: "E";
|
|
98
|
+
verb: Verb;
|
|
99
|
+
target: EntityRef;
|
|
100
|
+
/**
|
|
101
|
+
* Old free-text label kept by the legacy import on a `related_to` edge,
|
|
102
|
+
* written as a trailing ` | was "<label>"` field.
|
|
103
|
+
*/
|
|
104
|
+
was?: string;
|
|
105
|
+
}
|
|
106
|
+
/** `- T <date> | <signal type> | <one line> | src <ref>[ | by <origin>]` */
|
|
107
|
+
export interface TimelineRow {
|
|
108
|
+
kind: "T";
|
|
109
|
+
date: IsoDate;
|
|
110
|
+
/** Signal type or other lower-case token (`decision`, `meeting`, `doc`). */
|
|
111
|
+
signalType: string;
|
|
112
|
+
/** One line of text. */
|
|
113
|
+
text: string;
|
|
114
|
+
src: SourceRef;
|
|
115
|
+
/**
|
|
116
|
+
* Who wrote the line, when it was not copied from the source by a rule: a
|
|
117
|
+
* model (`agent:<model>`) or a person (`human:<prs id>`). Absent on a line a
|
|
118
|
+
* reader took from the source as it stands. Not part of the row id.
|
|
119
|
+
*/
|
|
120
|
+
by?: Origin;
|
|
121
|
+
}
|
|
122
|
+
export type GraphRow = FactRow | EdgeRow | TimelineRow;
|
|
123
|
+
export type RowKind = GraphRow["kind"];
|
|
124
|
+
/**
|
|
125
|
+
* Stable id of a row: 12 hex from a hash of the row's identity fields (not of
|
|
126
|
+
* `valid.to`, `conf` or `closed`), so closing a row keeps its id. See
|
|
127
|
+
* `rowId` in schema/grammar.ts.
|
|
128
|
+
*/
|
|
129
|
+
export type RowId = string;
|
|
130
|
+
/** A row as read back from disk, with where it lives. */
|
|
131
|
+
export interface StoredRow<R extends GraphRow = GraphRow> {
|
|
132
|
+
id: RowId;
|
|
133
|
+
entity: EntityRef;
|
|
134
|
+
audience: AudienceKey;
|
|
135
|
+
row: R;
|
|
136
|
+
}
|
|
137
|
+
export interface EntityKeys {
|
|
138
|
+
email: string[];
|
|
139
|
+
slack_id: string[];
|
|
140
|
+
/** `<system>:<id>`, for example `attio:abc123`, `linear:XYZ`. */
|
|
141
|
+
external_ids: string[];
|
|
142
|
+
web_domains: string[];
|
|
143
|
+
}
|
|
144
|
+
/** Frontmatter of `entities/{type}/{slug}.md`. Facts never live here. */
|
|
145
|
+
export interface GraphEntity {
|
|
146
|
+
/** Equals `${type}/${slug}`. */
|
|
147
|
+
id: EntityRef;
|
|
148
|
+
type: GraphEntityType;
|
|
149
|
+
canonical_name: string;
|
|
150
|
+
slug: string;
|
|
151
|
+
aliases: string[];
|
|
152
|
+
keys: EntityKeys;
|
|
153
|
+
first_seen: IsoDate;
|
|
154
|
+
last_updated: IsoDate;
|
|
155
|
+
/** Old 12 hex entity ids this entity was imported or merged from. */
|
|
156
|
+
legacy_ids: string[];
|
|
157
|
+
}
|
|
158
|
+
/** Input to `GraphStore.upsertEntity`. Lists are merged, not replaced. */
|
|
159
|
+
export interface EntityUpsert {
|
|
160
|
+
type: GraphEntityType;
|
|
161
|
+
slug: string;
|
|
162
|
+
canonical_name: string;
|
|
163
|
+
aliases?: string[];
|
|
164
|
+
keys?: Partial<EntityKeys>;
|
|
165
|
+
/** Day of the input that produced this upsert. Moves first_seen back and last_updated forward. */
|
|
166
|
+
seen: IsoDate;
|
|
167
|
+
legacy_ids?: string[];
|
|
168
|
+
}
|
|
169
|
+
export type VerbClass = "state" | "event" | "reference";
|
|
170
|
+
export interface VerbSpec {
|
|
171
|
+
inverse: string;
|
|
172
|
+
class: VerbClass;
|
|
173
|
+
/** Allowed subject types. `"*"` means any. */
|
|
174
|
+
subjects: readonly (GraphEntityType | "*")[];
|
|
175
|
+
/** Allowed object types. `"*"` means any. */
|
|
176
|
+
objects: readonly (GraphEntityType | "*")[];
|
|
177
|
+
/**
|
|
178
|
+
* `single`: at most one open row per subject for this verb; a newer row
|
|
179
|
+
* closes the older one (reports_to, owned_by). `multi`: never closed by a
|
|
180
|
+
* newer row. Event and reference verbs are always `multi`.
|
|
181
|
+
*/
|
|
182
|
+
cardinality: "single" | "multi";
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The closed vocabulary (design 2.4). Each verb names its inverse; symmetric
|
|
186
|
+
* verbs (partner_of, related_to) are their own inverse. schema.yaml
|
|
187
|
+
* `link_types` is generated from this table and may narrow it, never widen it.
|
|
188
|
+
*/
|
|
189
|
+
export declare const VERBS: {
|
|
190
|
+
readonly reports_to: {
|
|
191
|
+
readonly inverse: "manages";
|
|
192
|
+
readonly class: "state";
|
|
193
|
+
readonly subjects: readonly ["person"];
|
|
194
|
+
readonly objects: readonly ["person"];
|
|
195
|
+
readonly cardinality: "single";
|
|
196
|
+
};
|
|
197
|
+
readonly manages: {
|
|
198
|
+
readonly inverse: "reports_to";
|
|
199
|
+
readonly class: "state";
|
|
200
|
+
readonly subjects: readonly ["person"];
|
|
201
|
+
readonly objects: readonly ["person"];
|
|
202
|
+
readonly cardinality: "multi";
|
|
203
|
+
};
|
|
204
|
+
readonly speaks_for: {
|
|
205
|
+
readonly inverse: "spoken_for_by";
|
|
206
|
+
readonly class: "state";
|
|
207
|
+
readonly subjects: readonly ["person"];
|
|
208
|
+
readonly objects: readonly ["person"];
|
|
209
|
+
readonly cardinality: "multi";
|
|
210
|
+
};
|
|
211
|
+
readonly spoken_for_by: {
|
|
212
|
+
readonly inverse: "speaks_for";
|
|
213
|
+
readonly class: "state";
|
|
214
|
+
readonly subjects: readonly ["person"];
|
|
215
|
+
readonly objects: readonly ["person"];
|
|
216
|
+
readonly cardinality: "multi";
|
|
217
|
+
};
|
|
218
|
+
readonly member_of: {
|
|
219
|
+
readonly inverse: "has_member";
|
|
220
|
+
readonly class: "state";
|
|
221
|
+
readonly subjects: readonly ["person"];
|
|
222
|
+
readonly objects: readonly ["team"];
|
|
223
|
+
readonly cardinality: "multi";
|
|
224
|
+
};
|
|
225
|
+
readonly has_member: {
|
|
226
|
+
readonly inverse: "member_of";
|
|
227
|
+
readonly class: "state";
|
|
228
|
+
readonly subjects: readonly ["team"];
|
|
229
|
+
readonly objects: readonly ["person"];
|
|
230
|
+
readonly cardinality: "multi";
|
|
231
|
+
};
|
|
232
|
+
readonly holds_role: {
|
|
233
|
+
readonly inverse: "held_by";
|
|
234
|
+
readonly class: "state";
|
|
235
|
+
readonly subjects: readonly ["person"];
|
|
236
|
+
readonly objects: readonly ["role"];
|
|
237
|
+
readonly cardinality: "multi";
|
|
238
|
+
};
|
|
239
|
+
readonly held_by: {
|
|
240
|
+
readonly inverse: "holds_role";
|
|
241
|
+
readonly class: "state";
|
|
242
|
+
readonly subjects: readonly ["role"];
|
|
243
|
+
readonly objects: readonly ["person"];
|
|
244
|
+
readonly cardinality: "multi";
|
|
245
|
+
};
|
|
246
|
+
readonly leads: {
|
|
247
|
+
readonly inverse: "led_by";
|
|
248
|
+
readonly class: "state";
|
|
249
|
+
readonly subjects: readonly ["person"];
|
|
250
|
+
readonly objects: readonly ["team", "project"];
|
|
251
|
+
readonly cardinality: "multi";
|
|
252
|
+
};
|
|
253
|
+
readonly led_by: {
|
|
254
|
+
readonly inverse: "leads";
|
|
255
|
+
readonly class: "state";
|
|
256
|
+
readonly subjects: readonly ["team", "project"];
|
|
257
|
+
readonly objects: readonly ["person"];
|
|
258
|
+
readonly cardinality: "multi";
|
|
259
|
+
};
|
|
260
|
+
readonly works_on: {
|
|
261
|
+
readonly inverse: "has_contributor";
|
|
262
|
+
readonly class: "state";
|
|
263
|
+
readonly subjects: readonly ["person"];
|
|
264
|
+
readonly objects: readonly ["project", "product"];
|
|
265
|
+
readonly cardinality: "multi";
|
|
266
|
+
};
|
|
267
|
+
readonly has_contributor: {
|
|
268
|
+
readonly inverse: "works_on";
|
|
269
|
+
readonly class: "state";
|
|
270
|
+
readonly subjects: readonly ["project", "product"];
|
|
271
|
+
readonly objects: readonly ["person"];
|
|
272
|
+
readonly cardinality: "multi";
|
|
273
|
+
};
|
|
274
|
+
readonly owns: {
|
|
275
|
+
readonly inverse: "owned_by";
|
|
276
|
+
readonly class: "state";
|
|
277
|
+
readonly subjects: readonly ["person", "team"];
|
|
278
|
+
readonly objects: readonly ["project", "product"];
|
|
279
|
+
readonly cardinality: "multi";
|
|
280
|
+
};
|
|
281
|
+
readonly owned_by: {
|
|
282
|
+
readonly inverse: "owns";
|
|
283
|
+
readonly class: "state";
|
|
284
|
+
readonly subjects: readonly ["project", "product"];
|
|
285
|
+
readonly objects: readonly ["person", "team"];
|
|
286
|
+
readonly cardinality: "single";
|
|
287
|
+
};
|
|
288
|
+
readonly works_at: {
|
|
289
|
+
readonly inverse: "employs";
|
|
290
|
+
readonly class: "state";
|
|
291
|
+
readonly subjects: readonly ["person"];
|
|
292
|
+
readonly objects: readonly ["company"];
|
|
293
|
+
readonly cardinality: "multi";
|
|
294
|
+
};
|
|
295
|
+
readonly employs: {
|
|
296
|
+
readonly inverse: "works_at";
|
|
297
|
+
readonly class: "state";
|
|
298
|
+
readonly subjects: readonly ["company"];
|
|
299
|
+
readonly objects: readonly ["person"];
|
|
300
|
+
readonly cardinality: "multi";
|
|
301
|
+
};
|
|
302
|
+
readonly part_of: {
|
|
303
|
+
readonly inverse: "has_part";
|
|
304
|
+
readonly class: "state";
|
|
305
|
+
readonly subjects: readonly ["team", "project", "product", "role", "concept", "tool"];
|
|
306
|
+
readonly objects: readonly ["team", "project", "product", "role", "concept", "tool", "company"];
|
|
307
|
+
readonly cardinality: "multi";
|
|
308
|
+
};
|
|
309
|
+
readonly has_part: {
|
|
310
|
+
readonly inverse: "part_of";
|
|
311
|
+
readonly class: "state";
|
|
312
|
+
readonly subjects: readonly ["team", "project", "product", "role", "concept", "tool", "company"];
|
|
313
|
+
readonly objects: readonly ["team", "project", "product", "role", "concept", "tool"];
|
|
314
|
+
readonly cardinality: "multi";
|
|
315
|
+
};
|
|
316
|
+
readonly customer_of: {
|
|
317
|
+
readonly inverse: "has_customer";
|
|
318
|
+
readonly class: "state";
|
|
319
|
+
readonly subjects: readonly ["company"];
|
|
320
|
+
readonly objects: readonly ["company"];
|
|
321
|
+
readonly cardinality: "multi";
|
|
322
|
+
};
|
|
323
|
+
readonly has_customer: {
|
|
324
|
+
readonly inverse: "customer_of";
|
|
325
|
+
readonly class: "state";
|
|
326
|
+
readonly subjects: readonly ["company"];
|
|
327
|
+
readonly objects: readonly ["company"];
|
|
328
|
+
readonly cardinality: "multi";
|
|
329
|
+
};
|
|
330
|
+
readonly vendor_of: {
|
|
331
|
+
readonly inverse: "has_vendor";
|
|
332
|
+
readonly class: "state";
|
|
333
|
+
readonly subjects: readonly ["company"];
|
|
334
|
+
readonly objects: readonly ["company"];
|
|
335
|
+
readonly cardinality: "multi";
|
|
336
|
+
};
|
|
337
|
+
readonly has_vendor: {
|
|
338
|
+
readonly inverse: "vendor_of";
|
|
339
|
+
readonly class: "state";
|
|
340
|
+
readonly subjects: readonly ["company"];
|
|
341
|
+
readonly objects: readonly ["company"];
|
|
342
|
+
readonly cardinality: "multi";
|
|
343
|
+
};
|
|
344
|
+
readonly partner_of: {
|
|
345
|
+
readonly inverse: "partner_of";
|
|
346
|
+
readonly class: "state";
|
|
347
|
+
readonly subjects: readonly ["company"];
|
|
348
|
+
readonly objects: readonly ["company"];
|
|
349
|
+
readonly cardinality: "multi";
|
|
350
|
+
};
|
|
351
|
+
readonly uses: {
|
|
352
|
+
readonly inverse: "used_by";
|
|
353
|
+
readonly class: "state";
|
|
354
|
+
readonly subjects: readonly ["project", "product"];
|
|
355
|
+
readonly objects: readonly ["tool", "project"];
|
|
356
|
+
readonly cardinality: "multi";
|
|
357
|
+
};
|
|
358
|
+
readonly used_by: {
|
|
359
|
+
readonly inverse: "uses";
|
|
360
|
+
readonly class: "state";
|
|
361
|
+
readonly subjects: readonly ["tool", "project"];
|
|
362
|
+
readonly objects: readonly ["project", "product"];
|
|
363
|
+
readonly cardinality: "multi";
|
|
364
|
+
};
|
|
365
|
+
readonly depends_on: {
|
|
366
|
+
readonly inverse: "dependency_of";
|
|
367
|
+
readonly class: "state";
|
|
368
|
+
readonly subjects: readonly ["project", "product"];
|
|
369
|
+
readonly objects: readonly ["tool", "project"];
|
|
370
|
+
readonly cardinality: "multi";
|
|
371
|
+
};
|
|
372
|
+
readonly dependency_of: {
|
|
373
|
+
readonly inverse: "depends_on";
|
|
374
|
+
readonly class: "state";
|
|
375
|
+
readonly subjects: readonly ["tool", "project"];
|
|
376
|
+
readonly objects: readonly ["project", "product"];
|
|
377
|
+
readonly cardinality: "multi";
|
|
378
|
+
};
|
|
379
|
+
readonly attended: {
|
|
380
|
+
readonly inverse: "had_attendee";
|
|
381
|
+
readonly class: "event";
|
|
382
|
+
readonly subjects: readonly ["person"];
|
|
383
|
+
readonly objects: readonly ["meeting"];
|
|
384
|
+
readonly cardinality: "multi";
|
|
385
|
+
};
|
|
386
|
+
readonly had_attendee: {
|
|
387
|
+
readonly inverse: "attended";
|
|
388
|
+
readonly class: "event";
|
|
389
|
+
readonly subjects: readonly ["meeting"];
|
|
390
|
+
readonly objects: readonly ["person"];
|
|
391
|
+
readonly cardinality: "multi";
|
|
392
|
+
};
|
|
393
|
+
readonly decided: {
|
|
394
|
+
readonly inverse: "decided_by";
|
|
395
|
+
readonly class: "event";
|
|
396
|
+
readonly subjects: readonly ["person"];
|
|
397
|
+
readonly objects: readonly ["decision"];
|
|
398
|
+
readonly cardinality: "multi";
|
|
399
|
+
};
|
|
400
|
+
readonly decided_by: {
|
|
401
|
+
readonly inverse: "decided";
|
|
402
|
+
readonly class: "event";
|
|
403
|
+
readonly subjects: readonly ["decision"];
|
|
404
|
+
readonly objects: readonly ["person"];
|
|
405
|
+
readonly cardinality: "multi";
|
|
406
|
+
};
|
|
407
|
+
readonly decided_in: {
|
|
408
|
+
readonly inverse: "produced_decision";
|
|
409
|
+
readonly class: "event";
|
|
410
|
+
readonly subjects: readonly ["decision"];
|
|
411
|
+
readonly objects: readonly ["meeting"];
|
|
412
|
+
readonly cardinality: "multi";
|
|
413
|
+
};
|
|
414
|
+
readonly produced_decision: {
|
|
415
|
+
readonly inverse: "decided_in";
|
|
416
|
+
readonly class: "event";
|
|
417
|
+
readonly subjects: readonly ["meeting"];
|
|
418
|
+
readonly objects: readonly ["decision"];
|
|
419
|
+
readonly cardinality: "multi";
|
|
420
|
+
};
|
|
421
|
+
readonly about: {
|
|
422
|
+
readonly inverse: "discussed_in";
|
|
423
|
+
readonly class: "event";
|
|
424
|
+
readonly subjects: readonly ["decision", "meeting"];
|
|
425
|
+
readonly objects: readonly ["*"];
|
|
426
|
+
readonly cardinality: "multi";
|
|
427
|
+
};
|
|
428
|
+
readonly discussed_in: {
|
|
429
|
+
readonly inverse: "about";
|
|
430
|
+
readonly class: "event";
|
|
431
|
+
readonly subjects: readonly ["*"];
|
|
432
|
+
readonly objects: readonly ["decision", "meeting"];
|
|
433
|
+
readonly cardinality: "multi";
|
|
434
|
+
};
|
|
435
|
+
readonly supersedes: {
|
|
436
|
+
readonly inverse: "superseded_by";
|
|
437
|
+
readonly class: "event";
|
|
438
|
+
readonly subjects: readonly ["decision"];
|
|
439
|
+
readonly objects: readonly ["decision"];
|
|
440
|
+
readonly cardinality: "multi";
|
|
441
|
+
};
|
|
442
|
+
readonly superseded_by: {
|
|
443
|
+
readonly inverse: "supersedes";
|
|
444
|
+
readonly class: "event";
|
|
445
|
+
readonly subjects: readonly ["decision"];
|
|
446
|
+
readonly objects: readonly ["decision"];
|
|
447
|
+
readonly cardinality: "multi";
|
|
448
|
+
};
|
|
449
|
+
readonly mentions: {
|
|
450
|
+
readonly inverse: "mentioned_in";
|
|
451
|
+
readonly class: "reference";
|
|
452
|
+
readonly subjects: readonly ["*"];
|
|
453
|
+
readonly objects: readonly ["*"];
|
|
454
|
+
readonly cardinality: "multi";
|
|
455
|
+
};
|
|
456
|
+
readonly mentioned_in: {
|
|
457
|
+
readonly inverse: "mentions";
|
|
458
|
+
readonly class: "reference";
|
|
459
|
+
readonly subjects: readonly ["*"];
|
|
460
|
+
readonly objects: readonly ["*"];
|
|
461
|
+
readonly cardinality: "multi";
|
|
462
|
+
};
|
|
463
|
+
readonly related_to: {
|
|
464
|
+
readonly inverse: "related_to";
|
|
465
|
+
readonly class: "reference";
|
|
466
|
+
readonly subjects: readonly ["*"];
|
|
467
|
+
readonly objects: readonly ["*"];
|
|
468
|
+
readonly cardinality: "multi";
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
export type Verb = keyof typeof VERBS;
|
|
472
|
+
export declare const VERB_NAMES: Verb[];
|
|
473
|
+
export interface FactFieldSpec {
|
|
474
|
+
/** `single` fields close on change (role_title, stage, status). */
|
|
475
|
+
cardinality: "single" | "multi";
|
|
476
|
+
description?: string;
|
|
477
|
+
}
|
|
478
|
+
export interface EntityTypeSpec {
|
|
479
|
+
description?: string;
|
|
480
|
+
/** Allowed fact fields. A row with an unlisted field is refused. */
|
|
481
|
+
facts: Record<string, FactFieldSpec>;
|
|
482
|
+
}
|
|
483
|
+
/** One legacy relationship label and what the legacy import does with it. */
|
|
484
|
+
export interface VerbMapEntry {
|
|
485
|
+
/** Old label, matched case-insensitively after trimming. */
|
|
486
|
+
label: string;
|
|
487
|
+
action: "verb" | "timeline" | "fact" | "skip" | "related";
|
|
488
|
+
/** For `verb`: the new verb. */
|
|
489
|
+
verb?: Verb;
|
|
490
|
+
/** For `fact`: the fact field the label's text becomes (role_title). */
|
|
491
|
+
field?: string;
|
|
492
|
+
/** For `verb`: subject and object are swapped when their types match only reversed. */
|
|
493
|
+
flip_if_reversed?: boolean;
|
|
494
|
+
conf?: Confidence;
|
|
495
|
+
}
|
|
496
|
+
export interface RefusalLists {
|
|
497
|
+
/** A name shorter than this is never linked. */
|
|
498
|
+
min_name_length: number;
|
|
499
|
+
generic_words: string[];
|
|
500
|
+
job_titles: string[];
|
|
501
|
+
/** Minimum Jaccard similarity for the fuzzy pass. */
|
|
502
|
+
fuzzy_min_jaccard: number;
|
|
503
|
+
fuzzy_min_chars: number;
|
|
504
|
+
fuzzy_min_tokens: number;
|
|
505
|
+
}
|
|
506
|
+
export interface GraphSchema {
|
|
507
|
+
version: 1;
|
|
508
|
+
entity_types: Record<GraphEntityType, EntityTypeSpec>;
|
|
509
|
+
link_types: Record<Verb, VerbSpec>;
|
|
510
|
+
verb_map: VerbMapEntry[];
|
|
511
|
+
/** What to do with a legacy label that is not in `verb_map`. */
|
|
512
|
+
verb_map_default: {
|
|
513
|
+
action: "related";
|
|
514
|
+
verb: "related_to";
|
|
515
|
+
conf: Confidence;
|
|
516
|
+
};
|
|
517
|
+
refusals: RefusalLists;
|
|
518
|
+
}
|
|
519
|
+
export type RowRefusalCode = "missing_src" | "missing_learned" | "missing_by" | "bad_src" | "bad_by" | "bad_date" | "bad_validity" | "bad_conf" | "bad_closure" | "bad_entity_ref" | "bad_audience" | "unknown_entity_type" | "unknown_field" | "unknown_verb" | "bad_subject_type" | "bad_object_type" | "empty_value" | "multiline" | "bad_signal_type" | "grammar";
|
|
520
|
+
export interface RowRefusal {
|
|
521
|
+
code: RowRefusalCode;
|
|
522
|
+
message: string;
|
|
523
|
+
}
|
|
524
|
+
/** Thrown by the store when a row fails validation. Nothing is written. */
|
|
525
|
+
export declare class RowRefusedError extends Error {
|
|
526
|
+
readonly code: RowRefusalCode;
|
|
527
|
+
readonly entity: string;
|
|
528
|
+
readonly refusals: readonly RowRefusal[];
|
|
529
|
+
constructor(entity: string, refusals: readonly RowRefusal[]);
|
|
530
|
+
}
|
|
531
|
+
export interface WriteRowsResult {
|
|
532
|
+
/** Rows that were new and are now on disk. */
|
|
533
|
+
added: number;
|
|
534
|
+
/** Rows already present with the same id. Writing twice adds nothing. */
|
|
535
|
+
duplicate: number;
|
|
536
|
+
/** Ids of all rows passed, in input order. */
|
|
537
|
+
ids: RowId[];
|
|
538
|
+
}
|
|
539
|
+
export interface ReadRowsOptions {
|
|
540
|
+
/** Limit to these audience folders. Default: every `facts/@{key}/` present. */
|
|
541
|
+
audiences?: readonly AudienceKey[];
|
|
542
|
+
kinds?: readonly RowKind[];
|
|
543
|
+
/**
|
|
544
|
+
* Only F and E rows whose validity covers this day, and T rows dated on or
|
|
545
|
+
* before it. Rows learned after this day are still returned; callers that
|
|
546
|
+
* need "as the graph stood" filter on `learned` too.
|
|
547
|
+
*/
|
|
548
|
+
asOf?: IsoDate;
|
|
549
|
+
/** Only open F and E rows (no `valid.to`). T rows are unaffected. */
|
|
550
|
+
openOnly?: boolean;
|
|
551
|
+
}
|
|
552
|
+
/** One `## [date] <op> | ...` entry in log.md. */
|
|
553
|
+
export interface LogEntry {
|
|
554
|
+
date: IsoDate;
|
|
555
|
+
op: "ingest" | "lint" | "decision" | "rebuild" | "update" | "import" | "compile";
|
|
556
|
+
/** Source ref, proposal id or run label. */
|
|
557
|
+
subject: string;
|
|
558
|
+
/** Entities touched, written on the line under the heading. */
|
|
559
|
+
touched: EntityRef[];
|
|
560
|
+
rowsAdded: number;
|
|
561
|
+
rowsClosed: number;
|
|
562
|
+
/** Extra one-line note, optional. */
|
|
563
|
+
note?: string;
|
|
564
|
+
}
|
|
565
|
+
/** One line in `.state/ledger.jsonl`: one replayed day, or one phase of a run. */
|
|
566
|
+
export interface LedgerEntry {
|
|
567
|
+
/** Run id shared by every entry of one rebuild or update. */
|
|
568
|
+
run: string;
|
|
569
|
+
command: "rebuild" | "update" | "import" | "compile" | "lint" | "bench";
|
|
570
|
+
/** The replayed day, or the phase name for non-day phases (`legacy-import`). */
|
|
571
|
+
day: IsoDate | string;
|
|
572
|
+
/** Inputs read, by kind. */
|
|
573
|
+
inputs: Partial<Record<ReplayInputKind, number>>;
|
|
574
|
+
rowsAdded: number;
|
|
575
|
+
rowsClosed: number;
|
|
576
|
+
entitiesCreated: number;
|
|
577
|
+
modelCalls: number;
|
|
578
|
+
cacheHits: number;
|
|
579
|
+
inputTokens: number;
|
|
580
|
+
outputTokens: number;
|
|
581
|
+
/** Model calls skipped because the budget ran out. */
|
|
582
|
+
pending: number;
|
|
583
|
+
seconds: number;
|
|
584
|
+
at: IsoTimestamp;
|
|
585
|
+
/** Free counters a package wants in the ledger (`retyped_related_to`). */
|
|
586
|
+
counters?: Record<string, number>;
|
|
587
|
+
}
|
|
588
|
+
export interface LedgerTotals {
|
|
589
|
+
entries: number;
|
|
590
|
+
rowsAdded: number;
|
|
591
|
+
rowsClosed: number;
|
|
592
|
+
entitiesCreated: number;
|
|
593
|
+
modelCalls: number;
|
|
594
|
+
cacheHits: number;
|
|
595
|
+
inputTokens: number;
|
|
596
|
+
outputTokens: number;
|
|
597
|
+
pending: number;
|
|
598
|
+
seconds: number;
|
|
599
|
+
counters: Record<string, number>;
|
|
600
|
+
}
|
|
601
|
+
/** `.state/cursor.json`. */
|
|
602
|
+
export interface ReplayCursor {
|
|
603
|
+
/** Last fully replayed day per input kind. */
|
|
604
|
+
days: Partial<Record<ReplayInputKind, IsoDate>>;
|
|
605
|
+
/** True once the legacy import has completed. */
|
|
606
|
+
legacyImported: boolean;
|
|
607
|
+
/** Run id that last advanced the cursor. */
|
|
608
|
+
run?: string;
|
|
609
|
+
updatedAt?: IsoTimestamp;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* The store. Markdown files are canonical. All methods are synchronous; one
|
|
613
|
+
* process writes a graph root at a time. Every write is atomic (temp file plus
|
|
614
|
+
* rename) and files have a deterministic order, so the same rows always
|
|
615
|
+
* produce the same bytes.
|
|
616
|
+
*/
|
|
617
|
+
export interface GraphStore {
|
|
618
|
+
/** Absolute path of the graph root (default `companies/<slug>/.hq/ontology-graph`). */
|
|
619
|
+
readonly root: string;
|
|
620
|
+
/** Creates the folder skeleton and schema.yaml if absent. Idempotent. */
|
|
621
|
+
init(): void;
|
|
622
|
+
/** Reads and validates schema.yaml. Cached per store instance. */
|
|
623
|
+
schema(): GraphSchema;
|
|
624
|
+
readEntity(ref: EntityRef): GraphEntity | null;
|
|
625
|
+
/** Creates the entity or merges aliases, keys and legacy ids into it. */
|
|
626
|
+
upsertEntity(input: EntityUpsert): {
|
|
627
|
+
entity: GraphEntity;
|
|
628
|
+
created: boolean;
|
|
629
|
+
changed: boolean;
|
|
630
|
+
};
|
|
631
|
+
/** Sorted refs. With no type, every type. */
|
|
632
|
+
listEntities(type?: GraphEntityType): EntityRef[];
|
|
633
|
+
/** Removes the identity file only (used by an accepted merge). Rows stay. */
|
|
634
|
+
removeEntity(ref: EntityRef): boolean;
|
|
635
|
+
/** Audience keys that have a `facts/@{key}/` folder, sorted. */
|
|
636
|
+
listAudiences(): AudienceKey[];
|
|
637
|
+
readRows(ref: EntityRef, options?: ReadRowsOptions): StoredRow[];
|
|
638
|
+
/**
|
|
639
|
+
* Validates every row, then writes. Throws RowRefusedError and writes
|
|
640
|
+
* nothing if any row is refused (a row without `src`, `learned` or `by`,
|
|
641
|
+
* an unknown field or verb, a bad date). Idempotent by row id.
|
|
642
|
+
*/
|
|
643
|
+
writeRows(ref: EntityRef, audience: AudienceKey, rows: readonly GraphRow[]): WriteRowsResult;
|
|
644
|
+
/**
|
|
645
|
+
* Closes an open F or E row: sets `valid.to` to `closure.on` when empty and
|
|
646
|
+
* appends ` | closed <date> by <ref>`. Returns false when the row is absent
|
|
647
|
+
* or already closed. T rows cannot be closed.
|
|
648
|
+
*/
|
|
649
|
+
closeRow(ref: EntityRef, audience: AudienceKey, id: RowId, closure: RowClosure): boolean;
|
|
650
|
+
/** Entities that have a facts file in the given audiences (default all), sorted. */
|
|
651
|
+
listEntitiesWithRows(audiences?: readonly AudienceKey[]): EntityRef[];
|
|
652
|
+
appendLog(entry: LogEntry): void;
|
|
653
|
+
/** Newest last. `limit` keeps the last N entries. */
|
|
654
|
+
readLog(limit?: number): LogEntry[];
|
|
655
|
+
appendLedger(entry: LedgerEntry): void;
|
|
656
|
+
readLedger(run?: string): LedgerEntry[];
|
|
657
|
+
readCursor(): ReplayCursor;
|
|
658
|
+
writeCursor(cursor: ReplayCursor): void;
|
|
659
|
+
markDirty(refs: readonly EntityRef[]): void;
|
|
660
|
+
readDirty(): EntityRef[];
|
|
661
|
+
clearDirty(refs?: readonly EntityRef[]): void;
|
|
662
|
+
/**
|
|
663
|
+
* From here on row writes, closures, log entries and dirty marks are held in
|
|
664
|
+
* memory; reads through this store see them. Nothing reaches disk until
|
|
665
|
+
* `flushBatch`. Entities, ledger and cursor are written at once as always.
|
|
666
|
+
* Calling it again while a batch is open does nothing.
|
|
667
|
+
*/
|
|
668
|
+
beginBatch?(): void;
|
|
669
|
+
/**
|
|
670
|
+
* Writes everything held: each touched facts file once, the log entries in
|
|
671
|
+
* one append, the dirty marks in one append. The bytes are the same as if
|
|
672
|
+
* every call had written at once. `end` closes the batch; without it the
|
|
673
|
+
* batch stays open for the next window.
|
|
674
|
+
*/
|
|
675
|
+
flushBatch?(options?: {
|
|
676
|
+
end?: boolean;
|
|
677
|
+
}): BatchFlushResult;
|
|
678
|
+
/** Rows added since the last flush. 0 when no batch is open. */
|
|
679
|
+
batchRows?(): number;
|
|
680
|
+
/**
|
|
681
|
+
* Reopens a row that was closed: drops its closure and the end day the
|
|
682
|
+
* closure set. Returns false when the row is absent, a T row, or not closed.
|
|
683
|
+
*/
|
|
684
|
+
reopenRow?(ref: EntityRef, audience: AudienceKey, id: RowId): boolean;
|
|
685
|
+
/** Removes rows by id from one facts file. Returns how many were there and are gone. */
|
|
686
|
+
removeRows?(ref: EntityRef, audience: AudienceKey, ids: readonly RowId[]): number;
|
|
687
|
+
}
|
|
688
|
+
/** What one `flushBatch` wrote. */
|
|
689
|
+
export interface BatchFlushResult {
|
|
690
|
+
/** Facts files written. */
|
|
691
|
+
files: number;
|
|
692
|
+
/** Rows added in the window. */
|
|
693
|
+
rows: number;
|
|
694
|
+
/** Rows closed in the window. */
|
|
695
|
+
closures: number;
|
|
696
|
+
logEntries: number;
|
|
697
|
+
ms: number;
|
|
698
|
+
}
|
|
699
|
+
export interface IngestRow {
|
|
700
|
+
entity: EntityRef;
|
|
701
|
+
audience: AudienceKey;
|
|
702
|
+
row: GraphRow;
|
|
703
|
+
}
|
|
704
|
+
/** A mention the resolver refused to turn into an entity (design 2.5). */
|
|
705
|
+
export interface UnresolvedMention {
|
|
706
|
+
mention: string;
|
|
707
|
+
reason: ResolutionReason;
|
|
708
|
+
src: SourceRef;
|
|
709
|
+
date: IsoDate;
|
|
710
|
+
audience: AudienceKey;
|
|
711
|
+
candidates?: EntityRef[];
|
|
712
|
+
}
|
|
713
|
+
/** Everything one input contributes. Built by extractors, applied by `applyIngest`. */
|
|
714
|
+
export interface IngestBatch {
|
|
715
|
+
/** The input's ref; becomes the log entry subject. */
|
|
716
|
+
input: SourceRef;
|
|
717
|
+
/** The input's date; becomes the log entry date. */
|
|
718
|
+
date: IsoDate;
|
|
719
|
+
entities: EntityUpsert[];
|
|
720
|
+
/** Forward rows only. `applyIngest` writes the inverse edge on each target. */
|
|
721
|
+
rows: IngestRow[];
|
|
722
|
+
unresolved?: UnresolvedMention[];
|
|
723
|
+
}
|
|
724
|
+
/** Two open rows that disagree, where the newer one may not close the older. */
|
|
725
|
+
export interface Contradiction {
|
|
726
|
+
entity: EntityRef;
|
|
727
|
+
audience: AudienceKey;
|
|
728
|
+
/** Fact field or verb. */
|
|
729
|
+
key: string;
|
|
730
|
+
kept: RowId;
|
|
731
|
+
challenger: RowId;
|
|
732
|
+
reason: "lower_tier_challenger" | "same_day_conflict";
|
|
733
|
+
}
|
|
734
|
+
export interface IngestResult {
|
|
735
|
+
input: SourceRef;
|
|
736
|
+
touched: EntityRef[];
|
|
737
|
+
entitiesCreated: number;
|
|
738
|
+
rowsAdded: number;
|
|
739
|
+
rowsDuplicate: number;
|
|
740
|
+
rowsClosed: number;
|
|
741
|
+
contradictions: Contradiction[];
|
|
742
|
+
unresolved: number;
|
|
743
|
+
}
|
|
744
|
+
export type ResolutionReason = "identity_key" | "exact_name" | "alias" | "fuzzy" | "fuzzy_adjudicated" | "refused_short" | "refused_generic" | "refused_job_title" | "ambiguous_first_word" | "ambiguous_name" | "unknown_slack_id" | "no_match";
|
|
745
|
+
export interface Mention {
|
|
746
|
+
/** The text as it appeared. */
|
|
747
|
+
text: string;
|
|
748
|
+
/** Narrow the search to these types. */
|
|
749
|
+
types?: readonly GraphEntityType[];
|
|
750
|
+
/** Identity keys seen beside the mention. */
|
|
751
|
+
keys?: Partial<EntityKeys>;
|
|
752
|
+
/** Audiences the caller may read. Dedup never crosses audiences. */
|
|
753
|
+
audiences?: readonly AudienceKey[];
|
|
754
|
+
}
|
|
755
|
+
export interface Resolution {
|
|
756
|
+
status: "resolved" | "ambiguous" | "refused" | "unresolved";
|
|
757
|
+
/** Set when status is `resolved`. */
|
|
758
|
+
entity?: EntityRef;
|
|
759
|
+
reason: ResolutionReason;
|
|
760
|
+
/** Candidates for `ambiguous`, and for a fuzzy match that needs a proposal. */
|
|
761
|
+
candidates: EntityRef[];
|
|
762
|
+
/** 0 to 1. 1 for identity keys and exact names. */
|
|
763
|
+
score: number;
|
|
764
|
+
/** True when a name-only match should file a merge proposal instead of merging. */
|
|
765
|
+
proposeMerge?: boolean;
|
|
766
|
+
}
|
|
767
|
+
export interface Resolver {
|
|
768
|
+
resolve(mention: Mention): Resolution;
|
|
769
|
+
resolveMany(mentions: readonly Mention[]): Resolution[];
|
|
770
|
+
/** Tells the resolver about an entity created during the same run. */
|
|
771
|
+
remember(entity: GraphEntity): void;
|
|
772
|
+
}
|
|
773
|
+
/** `extract-source`: rows from a source that has no signals (correction C3). Added for WP-D. */
|
|
774
|
+
export type ModelStepKind = "type-relationship" | "resolve-fuzzy" | "summarize-page" | "extract-source";
|
|
775
|
+
export interface ModelBudget {
|
|
776
|
+
inputTokens: number;
|
|
777
|
+
outputTokens: number;
|
|
778
|
+
}
|
|
779
|
+
export interface ModelUsage {
|
|
780
|
+
inputTokens: number;
|
|
781
|
+
outputTokens: number;
|
|
782
|
+
}
|
|
783
|
+
export interface ModelStepRequest {
|
|
784
|
+
kind: ModelStepKind;
|
|
785
|
+
/** Bumped whenever the prompt text changes. Part of the cache key. */
|
|
786
|
+
promptVersion: string;
|
|
787
|
+
/** Instructions. Not part of the cache key beyond `promptVersion`. */
|
|
788
|
+
prompt: string;
|
|
789
|
+
/** Canonical input text. Part of the cache key. Passed to the model as data. */
|
|
790
|
+
input: string;
|
|
791
|
+
/** The replayed day the call is charged to. */
|
|
792
|
+
day: IsoDate;
|
|
793
|
+
maxOutputTokens?: number;
|
|
794
|
+
}
|
|
795
|
+
export interface ModelStepResult {
|
|
796
|
+
/**
|
|
797
|
+
* `ok`: a fresh reply. `cached`: reply from `.state/cache/`, 0 tokens.
|
|
798
|
+
* `pending`: budget exhausted or dry run; no call was made. `error`: the
|
|
799
|
+
* call failed; the caller carries on with rules only.
|
|
800
|
+
*/
|
|
801
|
+
status: "ok" | "cached" | "pending" | "error";
|
|
802
|
+
/** `sha256(promptVersion + "\n" + kind + "\n" + input)`, hex. */
|
|
803
|
+
cacheKey: string;
|
|
804
|
+
output?: string;
|
|
805
|
+
usage: ModelUsage;
|
|
806
|
+
error?: string;
|
|
807
|
+
}
|
|
808
|
+
export interface ModelStepStats {
|
|
809
|
+
calls: number;
|
|
810
|
+
cacheHits: number;
|
|
811
|
+
pending: number;
|
|
812
|
+
errors: number;
|
|
813
|
+
used: ModelUsage;
|
|
814
|
+
budget: ModelBudget;
|
|
815
|
+
/** True once the budget has stopped model calls. */
|
|
816
|
+
exhausted: boolean;
|
|
817
|
+
}
|
|
818
|
+
export interface ModelStep {
|
|
819
|
+
run(request: ModelStepRequest): Promise<ModelStepResult>;
|
|
820
|
+
/** Counters since creation or the last `resetDay`. */
|
|
821
|
+
stats(): ModelStepStats;
|
|
822
|
+
/** Starts a new per-day budget window and returns the closed window's stats. */
|
|
823
|
+
resetDay(day: IsoDate): ModelStepStats;
|
|
824
|
+
}
|
|
825
|
+
/** The tool-less single turn behind a model step. Injected in tests. */
|
|
826
|
+
export type ModelRunner = (call: {
|
|
827
|
+
model: string;
|
|
828
|
+
prompt: string;
|
|
829
|
+
input: string;
|
|
830
|
+
maxOutputTokens?: number;
|
|
831
|
+
}) => Promise<{
|
|
832
|
+
output: string;
|
|
833
|
+
usage: ModelUsage;
|
|
834
|
+
}>;
|
|
835
|
+
export declare const REPLAY_INPUT_KINDS: readonly ["legacy", "signal", "source", "doc", "prd", "session", "org-layer"];
|
|
836
|
+
export type ReplayInputKind = (typeof REPLAY_INPUT_KINDS)[number];
|
|
837
|
+
export interface ReplayInput {
|
|
838
|
+
kind: ReplayInputKind;
|
|
839
|
+
/** How rows cite this input. */
|
|
840
|
+
ref: SourceRef;
|
|
841
|
+
/** Absolute path of the file. Empty for inputs that are not files. */
|
|
842
|
+
path: string;
|
|
843
|
+
/** Path relative to the company folder, forward slashes. */
|
|
844
|
+
relPath: string;
|
|
845
|
+
/** The day this input is replayed on. */
|
|
846
|
+
date: IsoDate;
|
|
847
|
+
/** Null means no audience was found; the replay skips the input. */
|
|
848
|
+
audience: AudienceKey | null;
|
|
849
|
+
/**
|
|
850
|
+
* Person uid of the owner when the input is personal-scope (a DM, a
|
|
851
|
+
* personal vault file). Absent for company-scope inputs. A reader never
|
|
852
|
+
* returns an input whose owner is not the member it was created for (C2).
|
|
853
|
+
*/
|
|
854
|
+
ownerPersonUid?: string;
|
|
855
|
+
/** Source class id, as in the corpus manifest (`sources.meetings`, `signals.audience`). Set by the replay's readers. */
|
|
856
|
+
cls?: string;
|
|
857
|
+
/** When the thing happened, when that differs from `date`. Rows use it for `valid` and timeline dates. */
|
|
858
|
+
eventDate?: IsoDate;
|
|
859
|
+
}
|
|
860
|
+
export interface ReplayDocument {
|
|
861
|
+
input: ReplayInput;
|
|
862
|
+
frontmatter: Record<string, unknown>;
|
|
863
|
+
body: string;
|
|
864
|
+
}
|
|
865
|
+
export interface DateRange {
|
|
866
|
+
from?: IsoDate;
|
|
867
|
+
to?: IsoDate;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* One reader per input kind. Readers never write. A reader is created for one
|
|
871
|
+
* member (`ReplayReaderOptions`) and returns only what that member may read:
|
|
872
|
+
* no personal-scope file of another person, no `@key` folder for a key the
|
|
873
|
+
* member does not hold (correction C2).
|
|
874
|
+
*/
|
|
875
|
+
export interface ReplayInputReader {
|
|
876
|
+
readonly kind: ReplayInputKind;
|
|
877
|
+
/** The member this reader filters for. Optional in the type so first-shift stubs still compile; real readers set it. */
|
|
878
|
+
readonly member?: MemberIdentity;
|
|
879
|
+
/** Sorted days in range that have at least one input of this kind. */
|
|
880
|
+
listDays(range?: DateRange): IsoDate[];
|
|
881
|
+
/** Inputs for one day, in a deterministic order. */
|
|
882
|
+
list(day: IsoDate): ReplayInput[];
|
|
883
|
+
read(input: ReplayInput): ReplayDocument;
|
|
884
|
+
}
|
|
885
|
+
/** A model-free extractor: one document in, one ingest batch out. */
|
|
886
|
+
export interface RuleExtractor {
|
|
887
|
+
/** Becomes `by rule:<id>` on the rows it writes. */
|
|
888
|
+
readonly id: string;
|
|
889
|
+
applies(document: ReplayDocument): boolean;
|
|
890
|
+
extract(document: ReplayDocument, context: ExtractContext): IngestBatch | null;
|
|
891
|
+
}
|
|
892
|
+
export interface ExtractContext {
|
|
893
|
+
store: GraphStore;
|
|
894
|
+
schema: GraphSchema;
|
|
895
|
+
resolver: Resolver;
|
|
896
|
+
/** The day being replayed; use it for `learned`. */
|
|
897
|
+
day: IsoDate;
|
|
898
|
+
}
|
|
899
|
+
export interface ReplayRunResult {
|
|
900
|
+
run: string;
|
|
901
|
+
command: "rebuild" | "update";
|
|
902
|
+
days: number;
|
|
903
|
+
firstDay?: IsoDate;
|
|
904
|
+
lastDay?: IsoDate;
|
|
905
|
+
totals: LedgerTotals;
|
|
906
|
+
/** True when the run stopped before the end of the range (budget, signal, error). */
|
|
907
|
+
partial: boolean;
|
|
908
|
+
stoppedBecause?: string;
|
|
909
|
+
dryRun: boolean;
|
|
910
|
+
}
|
|
911
|
+
export interface LegacyImportResult {
|
|
912
|
+
filesRead: number;
|
|
913
|
+
conflictCopiesSkipped: number;
|
|
914
|
+
accountingSkipped: number;
|
|
915
|
+
slackIdPeopleSkipped: number;
|
|
916
|
+
entitiesCreated: number;
|
|
917
|
+
rowsAdded: number;
|
|
918
|
+
/** Count per new verb, plus `timeline`, `fact`, `skip`. */
|
|
919
|
+
verbCounts: Record<string, number>;
|
|
920
|
+
seconds: number;
|
|
921
|
+
}
|
|
922
|
+
export interface CompilePagesResult {
|
|
923
|
+
compiled: number;
|
|
924
|
+
skipped: number;
|
|
925
|
+
summaries: number;
|
|
926
|
+
uncitedLines: number;
|
|
927
|
+
indexWritten: boolean;
|
|
928
|
+
}
|
|
929
|
+
export type LintKind = "dead_link" | "orphan" | "contradiction" | "stale" | "slack_id_person" | "conflict_copy" | "uncited" | "unknown_verb" | "unknown_field" | "grammar" | "untyped_related" | "near_duplicate" | "closed_entity_edge" | "audience_leak";
|
|
930
|
+
export interface LintFinding {
|
|
931
|
+
kind: LintKind;
|
|
932
|
+
/** `error` findings make `hq ontology lint` exit non-zero (grammar class). */
|
|
933
|
+
severity: "error" | "warn";
|
|
934
|
+
entity?: EntityRef;
|
|
935
|
+
audience?: AudienceKey;
|
|
936
|
+
rows: RowId[];
|
|
937
|
+
/** File and 1-based line for grammar findings. */
|
|
938
|
+
file?: string;
|
|
939
|
+
line?: number;
|
|
940
|
+
message: string;
|
|
941
|
+
evidence: SourceRef[];
|
|
942
|
+
}
|
|
943
|
+
export interface LintReport {
|
|
944
|
+
counts: Partial<Record<LintKind, number>>;
|
|
945
|
+
findings: LintFinding[];
|
|
946
|
+
errors: number;
|
|
947
|
+
proposalsFiled: number;
|
|
948
|
+
}
|
|
949
|
+
export type ProposalKind = LintKind | "merge" | "retype" | "split" | "close_fact";
|
|
950
|
+
/** One row of one entity, by audience and row id. */
|
|
951
|
+
export interface RowAddress {
|
|
952
|
+
audience: AudienceKey;
|
|
953
|
+
row: RowId;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Keep one row of a single-valued field or verb and close the rows that
|
|
957
|
+
* disagree with it. `keep` is the full row so the decision can be written
|
|
958
|
+
* again when the row it came from does not exist yet.
|
|
959
|
+
*/
|
|
960
|
+
export interface KeepFactAction {
|
|
961
|
+
type: "keep_fact";
|
|
962
|
+
entity: EntityRef;
|
|
963
|
+
audience: AudienceKey;
|
|
964
|
+
keep: FactRow | EdgeRow;
|
|
965
|
+
close: RowAddress[];
|
|
966
|
+
}
|
|
967
|
+
/** Replace an edge's verb (usually `related_to`) with a typed verb. `edge` is the row as filed. */
|
|
968
|
+
export interface RetypeEdgeAction {
|
|
969
|
+
type: "retype_edge";
|
|
970
|
+
entity: EntityRef;
|
|
971
|
+
audience: AudienceKey;
|
|
972
|
+
row: RowId;
|
|
973
|
+
edge: EdgeRow;
|
|
974
|
+
verb: Verb;
|
|
975
|
+
}
|
|
976
|
+
/** Move some rows of one entity onto a new entity of the same type. */
|
|
977
|
+
export interface SplitAction {
|
|
978
|
+
type: "split";
|
|
979
|
+
entity: EntityRef;
|
|
980
|
+
into: {
|
|
981
|
+
slug: string;
|
|
982
|
+
canonical_name: string;
|
|
983
|
+
aliases?: string[];
|
|
984
|
+
keys?: Partial<EntityKeys>;
|
|
985
|
+
};
|
|
986
|
+
rows: RowAddress[];
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Write one row. On accept an F or E row is written as the member's own
|
|
990
|
+
* statement: origin human, confidence 1. When an edge points at an entity
|
|
991
|
+
* with no file yet, the accept creates it first, named `targetName` when given.
|
|
992
|
+
*/
|
|
993
|
+
export interface WriteRowAction {
|
|
994
|
+
type: "write_row";
|
|
995
|
+
entity: EntityRef;
|
|
996
|
+
audience: AudienceKey;
|
|
997
|
+
row: GraphRow;
|
|
998
|
+
targetName?: string;
|
|
999
|
+
}
|
|
1000
|
+
/** Several names of one person or thing: every entity in `from` is merged into `into`. */
|
|
1001
|
+
export interface MergeGroupAction {
|
|
1002
|
+
type: "merge_group";
|
|
1003
|
+
into: EntityRef;
|
|
1004
|
+
from: EntityRef[];
|
|
1005
|
+
}
|
|
1006
|
+
export type ProposalAction = {
|
|
1007
|
+
type: "close_row";
|
|
1008
|
+
entity: EntityRef;
|
|
1009
|
+
audience: AudienceKey;
|
|
1010
|
+
row: RowId;
|
|
1011
|
+
} | WriteRowAction | {
|
|
1012
|
+
type: "merge";
|
|
1013
|
+
from: EntityRef;
|
|
1014
|
+
into: EntityRef;
|
|
1015
|
+
} | MergeGroupAction | {
|
|
1016
|
+
type: "remove_entity";
|
|
1017
|
+
entity: EntityRef;
|
|
1018
|
+
} | {
|
|
1019
|
+
type: "none";
|
|
1020
|
+
} | KeepFactAction | RetypeEdgeAction | SplitAction;
|
|
1021
|
+
/** One JSON line in proposals/open.jsonl. */
|
|
1022
|
+
export interface Proposal {
|
|
1023
|
+
/** Stable: 12 hex from a hash of kind, entity and rows, so re-linting does not duplicate. */
|
|
1024
|
+
id: string;
|
|
1025
|
+
kind: ProposalKind;
|
|
1026
|
+
entity?: EntityRef;
|
|
1027
|
+
audience?: AudienceKey;
|
|
1028
|
+
rows: RowId[];
|
|
1029
|
+
summary: string;
|
|
1030
|
+
/** What `accept` will do. */
|
|
1031
|
+
action: ProposalAction;
|
|
1032
|
+
evidence: SourceRef[];
|
|
1033
|
+
filedAt: IsoTimestamp;
|
|
1034
|
+
/**
|
|
1035
|
+
* The reviewed set the proposal belongs to (`org chart draft`, `name variants`).
|
|
1036
|
+
* A set is listed and answered as one. When absent, a name in square brackets
|
|
1037
|
+
* at the start of the summary names the set.
|
|
1038
|
+
*/
|
|
1039
|
+
set?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Proposals this one stands in for (the pair proposals a group proposal was
|
|
1042
|
+
* folded from). They return to the open list when it is declined, and are
|
|
1043
|
+
* decided with it when it is accepted.
|
|
1044
|
+
*/
|
|
1045
|
+
replaces?: Proposal[];
|
|
1046
|
+
}
|
|
1047
|
+
/** One JSON line in proposals/decided.jsonl. */
|
|
1048
|
+
export interface DecidedProposal extends Proposal {
|
|
1049
|
+
/** `undo` takes back an earlier accept or nope of the same proposal. */
|
|
1050
|
+
decision: "accept" | "nope" | "undo";
|
|
1051
|
+
/** `human:<prs id>` */
|
|
1052
|
+
decidedBy: Origin;
|
|
1053
|
+
decidedAt: IsoTimestamp;
|
|
1054
|
+
}
|
|
1055
|
+
/** Resolved once by src/commands/ontology-graph.ts and passed to every entry point. */
|
|
1056
|
+
export interface GraphContext {
|
|
1057
|
+
hqRoot: string;
|
|
1058
|
+
/** Company slug. */
|
|
1059
|
+
company: string;
|
|
1060
|
+
/** `<hqRoot>/companies/<company>`. */
|
|
1061
|
+
companyRoot: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* The graph root, from `resolveGraphRoot` in store/paths.ts: the
|
|
1064
|
+
* `--graph-root` flag, else `HQ_ONTOLOGY_GRAPH_ROOT`, else
|
|
1065
|
+
* `<companyRoot>/.hq/ontology-graph` (correction C1). Search indexers skip
|
|
1066
|
+
* dot folders, so readers always take this explicit path.
|
|
1067
|
+
*/
|
|
1068
|
+
graphRoot: string;
|
|
1069
|
+
json: boolean;
|
|
1070
|
+
/**
|
|
1071
|
+
* The member this run builds or reads for (correction C2). Set by the
|
|
1072
|
+
* command file from `--member`, `--audience-key` and their env vars. Input
|
|
1073
|
+
* readers must have it: a reader with no member reads no personal-scope
|
|
1074
|
+
* file and no per-audience (`@key`) folder.
|
|
1075
|
+
*/
|
|
1076
|
+
member?: MemberIdentity;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Who a build is for (correction C2). Every input reader takes this and
|
|
1080
|
+
* (1) excludes personal-scope files that belong to another person (Slack DMs,
|
|
1081
|
+
* personal vault folders): a personal file is read only when its owner is
|
|
1082
|
+
* `personUid`; (2) reads a per-audience folder (`@<key>`) or a source whose
|
|
1083
|
+
* audience is `<key>` only when `<key>` is in `audienceKeys`. `company` is
|
|
1084
|
+
* always readable and need not be listed.
|
|
1085
|
+
*/
|
|
1086
|
+
export interface MemberIdentity {
|
|
1087
|
+
/** The member's person uid (`prs_...`). */
|
|
1088
|
+
personUid: string;
|
|
1089
|
+
/** 16 hex audience keys the member holds. */
|
|
1090
|
+
audienceKeys: readonly AudienceKey[];
|
|
1091
|
+
}
|
|
1092
|
+
/** Options every input reader is created with (correction C2). */
|
|
1093
|
+
export interface ReplayReaderOptions {
|
|
1094
|
+
member: MemberIdentity;
|
|
1095
|
+
}
|
|
1096
|
+
/** Thrown by a reader factory or entry point that needs a member and has none. */
|
|
1097
|
+
export declare class MemberIdentityRequiredError extends Error {
|
|
1098
|
+
constructor(what: string);
|
|
1099
|
+
}
|
|
1100
|
+
/** What every command entry point returns. The command file prints it. */
|
|
1101
|
+
export interface CommandOutput {
|
|
1102
|
+
/** Human text for stdout. */
|
|
1103
|
+
text: string;
|
|
1104
|
+
/** Printed instead of `text` under `--json`. */
|
|
1105
|
+
json: unknown;
|
|
1106
|
+
/** Default 0. */
|
|
1107
|
+
exitCode?: number;
|
|
1108
|
+
}
|
|
1109
|
+
export interface RebuildOptions {
|
|
1110
|
+
from?: IsoDate;
|
|
1111
|
+
to?: IsoDate;
|
|
1112
|
+
resume: boolean;
|
|
1113
|
+
/** Cap on model input tokens for the run. 0 means rules only, the same as `noModel`. */
|
|
1114
|
+
budgetTokens?: number;
|
|
1115
|
+
/** Rules only: no model call is made and model work is left pending (`--no-model`). */
|
|
1116
|
+
noModel?: boolean;
|
|
1117
|
+
dryRun: boolean;
|
|
1118
|
+
}
|
|
1119
|
+
export interface UpdateOptions {
|
|
1120
|
+
/** Replay one input file instead of the days after the cursor. */
|
|
1121
|
+
input?: string;
|
|
1122
|
+
/** Cap on model input tokens for the run. 0 means rules only, the same as `noModel`. */
|
|
1123
|
+
budgetTokens?: number;
|
|
1124
|
+
/** Rules only: no model call is made and model work is left pending (`--no-model`). */
|
|
1125
|
+
noModel?: boolean;
|
|
1126
|
+
/** List the whole corpus again instead of only new and changed files (`--full-listing`). */
|
|
1127
|
+
fullListing?: boolean;
|
|
1128
|
+
dryRun: boolean;
|
|
1129
|
+
}
|
|
1130
|
+
export interface LookupOptions {
|
|
1131
|
+
name: string;
|
|
1132
|
+
asOf?: IsoDate;
|
|
1133
|
+
}
|
|
1134
|
+
export interface NeighborsOptions {
|
|
1135
|
+
id: string;
|
|
1136
|
+
verb?: string;
|
|
1137
|
+
asOf?: IsoDate;
|
|
1138
|
+
}
|
|
1139
|
+
export interface SearchOptions {
|
|
1140
|
+
text: string;
|
|
1141
|
+
limit?: number;
|
|
1142
|
+
}
|
|
1143
|
+
export interface TraverseOptions {
|
|
1144
|
+
id: string;
|
|
1145
|
+
verb?: string;
|
|
1146
|
+
/** 1 to 3. */
|
|
1147
|
+
depth: number;
|
|
1148
|
+
asOf?: IsoDate;
|
|
1149
|
+
}
|
|
1150
|
+
export interface BriefOptions {
|
|
1151
|
+
/** Print the brief without writing brief.md. */
|
|
1152
|
+
stdout: boolean;
|
|
1153
|
+
}
|
|
1154
|
+
export interface LintOptions {
|
|
1155
|
+
/** File a proposal per finding. Default true. */
|
|
1156
|
+
fileProposals: boolean;
|
|
1157
|
+
/** Exit 1 when an error-class finding exists (`--strict`). Default false. */
|
|
1158
|
+
strict?: boolean;
|
|
1159
|
+
/** Print the coverage table instead of the findings (`--coverage`). Writes nothing. */
|
|
1160
|
+
coverage?: boolean;
|
|
1161
|
+
/**
|
|
1162
|
+
* Check these entities only (what a daily update touched). The findings are
|
|
1163
|
+
* the ones a full lint reports for them, less the classes that compare every
|
|
1164
|
+
* entity with every other (`near_duplicate`, and a closed target outside the set).
|
|
1165
|
+
*/
|
|
1166
|
+
entities?: readonly EntityRef[];
|
|
1167
|
+
}
|
|
1168
|
+
export interface ProposalsListOptions {
|
|
1169
|
+
kind?: string;
|
|
1170
|
+
limit?: number;
|
|
1171
|
+
/** Only the proposals of this set. */
|
|
1172
|
+
set?: string;
|
|
1173
|
+
}
|
|
1174
|
+
export interface ProposalDecisionOptions {
|
|
1175
|
+
/** One proposal, by id or unique prefix. Either `id` or `set` is given. */
|
|
1176
|
+
id?: string;
|
|
1177
|
+
/** Every open proposal of this set. */
|
|
1178
|
+
set?: string;
|
|
1179
|
+
decision: "accept" | "nope";
|
|
1180
|
+
/** prs id of the deciding member. Resolved from the signed-in identity when absent. */
|
|
1181
|
+
as?: string;
|
|
1182
|
+
}
|
|
1183
|
+
//# sourceMappingURL=types.d.ts.map
|