@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,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-F: `hq ontology lint --coverage`. How much of the organization the graph
|
|
3
|
+
* describes, counted the same way after every rebuild (correction C8). These
|
|
4
|
+
* are the measures the first critique used. Model-free, read-only: one scan of
|
|
5
|
+
* the graph folder, nothing written.
|
|
6
|
+
*
|
|
7
|
+
* Definitions (a row is "open" when it has no end day; a row that sits in two
|
|
8
|
+
* audience folders under the same id is counted once):
|
|
9
|
+
*
|
|
10
|
+
* Internal people people with an open `works_at` edge to the company the graph belongs to
|
|
11
|
+
* (the company with an open `relation = self` fact, else `company/<slug>`).
|
|
12
|
+
* with a role an open `role_title` fact or an open `holds_role` edge
|
|
13
|
+
* with a team an open `member_of` edge
|
|
14
|
+
* with a manager an open `reports_to` edge
|
|
15
|
+
* Projects every project entity
|
|
16
|
+
* with an owner an open `owned_by` or `led_by` edge
|
|
17
|
+
* with a status an open `status` fact
|
|
18
|
+
* Customers companies with an open `customer_of` edge to the company itself, or an open `relation = customer` fact
|
|
19
|
+
* informative stage an open `stage` fact whose value is not a placeholder (lead, unknown, none, n/a, tbd, other)
|
|
20
|
+
* and is not the one value every staged company shares (ten or more staged companies)
|
|
21
|
+
* with a contact an open `employs` edge on the company, or a person with an open `works_at` edge to it
|
|
22
|
+
* Edges every E row, open or closed. An edge and its inverse are two rows, as in the critique.
|
|
23
|
+
* about / discussed_in the share that only says "this was named in that meeting or decision"
|
|
24
|
+
* Single-valued fields per entity, a single-valued fact field or verb with two or more open rows. Must be 0.
|
|
25
|
+
* Timeline rows T rows by the month of their date, for the six calendar months ending with the run's month
|
|
26
|
+
* Entities with no rows an entity file with no row in any audience folder
|
|
27
|
+
*/
|
|
28
|
+
import type { CommandOutput, EntityRef, GraphContext, IsoDate } from "../types.js";
|
|
29
|
+
import { type GraphScan } from "./checks.js";
|
|
30
|
+
export interface CoverageShare {
|
|
31
|
+
count: number;
|
|
32
|
+
of: number;
|
|
33
|
+
/** `count / of`, 0 to 1, four decimals. 0 when `of` is 0. */
|
|
34
|
+
share: number;
|
|
35
|
+
}
|
|
36
|
+
export interface CoverageReport {
|
|
37
|
+
graphRoot: string;
|
|
38
|
+
day: IsoDate;
|
|
39
|
+
/** The company the graph belongs to, or null when the graph has no such entity. */
|
|
40
|
+
self: EntityRef | null;
|
|
41
|
+
internalPeople: {
|
|
42
|
+
total: number;
|
|
43
|
+
withRole: CoverageShare;
|
|
44
|
+
withTeam: CoverageShare;
|
|
45
|
+
withManager: CoverageShare;
|
|
46
|
+
withAll: CoverageShare;
|
|
47
|
+
};
|
|
48
|
+
projects: {
|
|
49
|
+
total: number;
|
|
50
|
+
withOwner: CoverageShare;
|
|
51
|
+
withStatus: CoverageShare;
|
|
52
|
+
withBoth: CoverageShare;
|
|
53
|
+
};
|
|
54
|
+
customers: {
|
|
55
|
+
total: number;
|
|
56
|
+
withStage: CoverageShare;
|
|
57
|
+
withInformativeStage: CoverageShare;
|
|
58
|
+
withContact: CoverageShare;
|
|
59
|
+
withBoth: CoverageShare;
|
|
60
|
+
};
|
|
61
|
+
edges: {
|
|
62
|
+
total: number;
|
|
63
|
+
aboutOrDiscussedIn: CoverageShare;
|
|
64
|
+
relatedToOrMentions: CoverageShare;
|
|
65
|
+
/** Rows per verb class: state (structure), event, reference. */
|
|
66
|
+
byClass: Record<"state" | "event" | "reference", number>;
|
|
67
|
+
};
|
|
68
|
+
singleValuedOverfull: {
|
|
69
|
+
/** Entity and field pairs with two or more open rows. Must be 0. */
|
|
70
|
+
total: number;
|
|
71
|
+
/** `<type> <field or verb>` to the number of entities. */
|
|
72
|
+
byField: Record<string, number>;
|
|
73
|
+
};
|
|
74
|
+
timeline: {
|
|
75
|
+
/** Oldest month first; the last entry is the month of `day`. */
|
|
76
|
+
months: {
|
|
77
|
+
month: string;
|
|
78
|
+
rows: number;
|
|
79
|
+
}[];
|
|
80
|
+
total: number;
|
|
81
|
+
};
|
|
82
|
+
entities: {
|
|
83
|
+
total: number;
|
|
84
|
+
zeroRows: CoverageShare;
|
|
85
|
+
zeroRowsByType: Record<string, number>;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface CoverageOptions {
|
|
89
|
+
/** Default: the clock. */
|
|
90
|
+
now?: Date;
|
|
91
|
+
/** Months of timeline to report. Default 6. */
|
|
92
|
+
months?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Stage values that say nothing about where a customer stands. */
|
|
95
|
+
export declare const UNINFORMATIVE_STAGES: ReadonlySet<string>;
|
|
96
|
+
/** The six (or `count`) calendar months ending with the month of `day`, oldest first, as `YYYY-MM`. */
|
|
97
|
+
export declare function lastMonths(day: IsoDate, count: number): string[];
|
|
98
|
+
/** Counts the coverage measures from one scan. Pure: the same graph and day give the same report. */
|
|
99
|
+
export declare function measureCoverage(scan: GraphScan, context: Pick<GraphContext, "company" | "graphRoot">, options?: CoverageOptions): CoverageReport;
|
|
100
|
+
/** The report as a markdown table: the same rows in the same order on every run. */
|
|
101
|
+
export declare function renderCoverage(report: CoverageReport): string;
|
|
102
|
+
/** Reads the graph and counts. Writes nothing. */
|
|
103
|
+
export declare function runCoverage(context: GraphContext, options?: CoverageOptions): CoverageReport;
|
|
104
|
+
/** `hq ontology lint --coverage`: the table, or the same numbers as JSON with `--json`. */
|
|
105
|
+
export declare function coverageCommand(context: GraphContext, options?: CoverageOptions): Promise<CommandOutput>;
|
|
106
|
+
//# sourceMappingURL=coverage.d.ts.map
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { VERBS } from "../types.js";
|
|
2
|
+
import { isSingleValued, parseEntityRef } from "../schema/index.js";
|
|
3
|
+
import { openGraphStore } from "../store/index.js";
|
|
4
|
+
import { scanGraph } from "./checks.js";
|
|
5
|
+
const compareText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
6
|
+
const share = (count, of) => ({ count, of, share: of === 0 ? 0 : Math.round((count / of) * 10_000) / 10_000 });
|
|
7
|
+
/** Stage values that say nothing about where a customer stands. */
|
|
8
|
+
export const UNINFORMATIVE_STAGES = new Set(["", "lead", "unknown", "none", "n/a", "na", "tbd", "other", "?"]);
|
|
9
|
+
/** One entity's rows, each id once. */
|
|
10
|
+
function distinct(rows) {
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
const out = [];
|
|
13
|
+
for (const stored of rows ?? []) {
|
|
14
|
+
if (seen.has(stored.id))
|
|
15
|
+
continue;
|
|
16
|
+
seen.add(stored.id);
|
|
17
|
+
out.push(stored);
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
function opened(rows) {
|
|
22
|
+
const out = { facts: [], edges: [] };
|
|
23
|
+
for (const { row } of rows) {
|
|
24
|
+
if (row.kind === "T" || row.valid.to !== undefined || row.closed)
|
|
25
|
+
continue;
|
|
26
|
+
if (row.kind === "F")
|
|
27
|
+
out.facts.push(row);
|
|
28
|
+
else
|
|
29
|
+
out.edges.push(row);
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/** The six (or `count`) calendar months ending with the month of `day`, oldest first, as `YYYY-MM`. */
|
|
34
|
+
export function lastMonths(day, count) {
|
|
35
|
+
const year = Number(day.slice(0, 4));
|
|
36
|
+
const month = Number(day.slice(5, 7));
|
|
37
|
+
const out = [];
|
|
38
|
+
for (let back = count - 1; back >= 0; back -= 1) {
|
|
39
|
+
const index = year * 12 + (month - 1) - back;
|
|
40
|
+
out.push(`${String(Math.floor(index / 12)).padStart(4, "0")}-${String((index % 12) + 1).padStart(2, "0")}`);
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/** Counts the coverage measures from one scan. Pure: the same graph and day give the same report. */
|
|
45
|
+
export function measureCoverage(scan, context, options = {}) {
|
|
46
|
+
const day = (options.now ?? new Date()).toISOString().slice(0, 10);
|
|
47
|
+
const rowsOf = new Map();
|
|
48
|
+
const openOf = new Map();
|
|
49
|
+
for (const ref of new Set([...scan.entities.keys(), ...scan.rows.keys()])) {
|
|
50
|
+
const rows = distinct(scan.rows.get(ref));
|
|
51
|
+
rowsOf.set(ref, rows);
|
|
52
|
+
openOf.set(ref, opened(rows));
|
|
53
|
+
}
|
|
54
|
+
const ofType = (type) => [...scan.entities.keys()].filter((ref) => parseEntityRef(ref)?.type === type).sort(compareText);
|
|
55
|
+
const open = (ref) => openOf.get(ref) ?? { facts: [], edges: [] };
|
|
56
|
+
// The company the graph belongs to.
|
|
57
|
+
let self = null;
|
|
58
|
+
for (const ref of ofType("company")) {
|
|
59
|
+
if (open(ref).facts.some((fact) => fact.field === "relation" && fact.value.trim().toLowerCase() === "self")) {
|
|
60
|
+
self = ref;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const bySlug = `company/${context.company}`;
|
|
65
|
+
if (!self && scan.entities.has(bySlug))
|
|
66
|
+
self = bySlug;
|
|
67
|
+
// Internal people.
|
|
68
|
+
const internal = self ? ofType("person").filter((ref) => open(ref).edges.some((edge) => edge.verb === "works_at" && edge.target === self)) : [];
|
|
69
|
+
const hasRole = (ref) => open(ref).facts.some((fact) => fact.field === "role_title") || open(ref).edges.some((edge) => edge.verb === "holds_role");
|
|
70
|
+
const hasTeam = (ref) => open(ref).edges.some((edge) => edge.verb === "member_of");
|
|
71
|
+
const hasManager = (ref) => open(ref).edges.some((edge) => edge.verb === "reports_to");
|
|
72
|
+
// Projects.
|
|
73
|
+
const projects = ofType("project");
|
|
74
|
+
const hasOwner = (ref) => open(ref).edges.some((edge) => edge.verb === "owned_by" || edge.verb === "led_by");
|
|
75
|
+
const hasStatus = (ref) => open(ref).facts.some((fact) => fact.field === "status");
|
|
76
|
+
// Customers.
|
|
77
|
+
const companies = ofType("company");
|
|
78
|
+
const stageOf = (ref) => {
|
|
79
|
+
const stage = open(ref).facts.find((fact) => fact.field === "stage");
|
|
80
|
+
return stage ? stage.value.trim().toLowerCase() : null;
|
|
81
|
+
};
|
|
82
|
+
const staged = companies.map(stageOf).filter((value) => value !== null);
|
|
83
|
+
const sharedStage = staged.length >= 10 && new Set(staged).size === 1 ? staged[0] : null;
|
|
84
|
+
const employed = new Set();
|
|
85
|
+
for (const ref of ofType("person"))
|
|
86
|
+
for (const edge of open(ref).edges)
|
|
87
|
+
if (edge.verb === "works_at")
|
|
88
|
+
employed.add(edge.target);
|
|
89
|
+
const customers = companies.filter((ref) => ref !== self &&
|
|
90
|
+
(open(ref).facts.some((fact) => fact.field === "relation" && fact.value.trim().toLowerCase() === "customer") ||
|
|
91
|
+
(self !== null && open(ref).edges.some((edge) => edge.verb === "customer_of" && edge.target === self))));
|
|
92
|
+
const informative = (ref) => {
|
|
93
|
+
const stage = stageOf(ref);
|
|
94
|
+
return stage !== null && !UNINFORMATIVE_STAGES.has(stage) && stage !== sharedStage;
|
|
95
|
+
};
|
|
96
|
+
const hasContact = (ref) => employed.has(ref) || open(ref).edges.some((edge) => edge.verb === "employs");
|
|
97
|
+
// Edges, single-valued fields, timeline, empty entities.
|
|
98
|
+
const byClass = { state: 0, event: 0, reference: 0 };
|
|
99
|
+
let edgeTotal = 0;
|
|
100
|
+
let aboutEdges = 0;
|
|
101
|
+
let looseEdges = 0;
|
|
102
|
+
const overfull = {};
|
|
103
|
+
let overfullTotal = 0;
|
|
104
|
+
const months = lastMonths(day, Math.max(1, options.months ?? 6));
|
|
105
|
+
const perMonth = new Map(months.map((month) => [month, 0]));
|
|
106
|
+
let timelineTotal = 0;
|
|
107
|
+
for (const [ref, rows] of rowsOf) {
|
|
108
|
+
const type = parseEntityRef(ref)?.type;
|
|
109
|
+
const groups = new Map();
|
|
110
|
+
for (const { row } of rows) {
|
|
111
|
+
if (row.kind === "T") {
|
|
112
|
+
timelineTotal += 1;
|
|
113
|
+
const month = row.date.slice(0, 7);
|
|
114
|
+
if (perMonth.has(month))
|
|
115
|
+
perMonth.set(month, (perMonth.get(month) ?? 0) + 1);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (row.kind === "E") {
|
|
119
|
+
edgeTotal += 1;
|
|
120
|
+
if (row.verb === "about" || row.verb === "discussed_in")
|
|
121
|
+
aboutEdges += 1;
|
|
122
|
+
if (row.verb === "related_to" || row.verb === "mentions" || row.verb === "mentioned_in")
|
|
123
|
+
looseEdges += 1;
|
|
124
|
+
const verbClass = VERBS[row.verb]?.class;
|
|
125
|
+
if (verbClass)
|
|
126
|
+
byClass[verbClass] += 1;
|
|
127
|
+
}
|
|
128
|
+
const stamped = row;
|
|
129
|
+
if (!type || stamped.valid.to !== undefined || stamped.closed || !isSingleValued(scan.schema, type, stamped))
|
|
130
|
+
continue;
|
|
131
|
+
const key = `${type} ${stamped.kind === "F" ? stamped.field : stamped.verb}`;
|
|
132
|
+
groups.set(key, (groups.get(key) ?? 0) + 1);
|
|
133
|
+
}
|
|
134
|
+
for (const [key, count] of groups) {
|
|
135
|
+
if (count < 2)
|
|
136
|
+
continue;
|
|
137
|
+
overfull[key] = (overfull[key] ?? 0) + 1;
|
|
138
|
+
overfullTotal += 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const zeroByType = {};
|
|
142
|
+
let zeroRows = 0;
|
|
143
|
+
for (const ref of scan.entities.keys()) {
|
|
144
|
+
if ((rowsOf.get(ref) ?? []).length > 0)
|
|
145
|
+
continue;
|
|
146
|
+
zeroRows += 1;
|
|
147
|
+
const type = parseEntityRef(ref)?.type ?? "unknown";
|
|
148
|
+
zeroByType[type] = (zeroByType[type] ?? 0) + 1;
|
|
149
|
+
}
|
|
150
|
+
const count = (refs, test) => refs.filter(test).length;
|
|
151
|
+
const sorted = (record) => Object.fromEntries(Object.entries(record).sort(([a, left], [b, right]) => right - left || compareText(a, b)));
|
|
152
|
+
return {
|
|
153
|
+
graphRoot: context.graphRoot,
|
|
154
|
+
day,
|
|
155
|
+
self,
|
|
156
|
+
internalPeople: {
|
|
157
|
+
total: internal.length,
|
|
158
|
+
withRole: share(count(internal, hasRole), internal.length),
|
|
159
|
+
withTeam: share(count(internal, hasTeam), internal.length),
|
|
160
|
+
withManager: share(count(internal, hasManager), internal.length),
|
|
161
|
+
withAll: share(count(internal, (ref) => hasRole(ref) && hasTeam(ref) && hasManager(ref)), internal.length),
|
|
162
|
+
},
|
|
163
|
+
projects: {
|
|
164
|
+
total: projects.length,
|
|
165
|
+
withOwner: share(count(projects, hasOwner), projects.length),
|
|
166
|
+
withStatus: share(count(projects, hasStatus), projects.length),
|
|
167
|
+
withBoth: share(count(projects, (ref) => hasOwner(ref) && hasStatus(ref)), projects.length),
|
|
168
|
+
},
|
|
169
|
+
customers: {
|
|
170
|
+
total: customers.length,
|
|
171
|
+
withStage: share(count(customers, (ref) => stageOf(ref) !== null), customers.length),
|
|
172
|
+
withInformativeStage: share(count(customers, informative), customers.length),
|
|
173
|
+
withContact: share(count(customers, hasContact), customers.length),
|
|
174
|
+
withBoth: share(count(customers, (ref) => informative(ref) && hasContact(ref)), customers.length),
|
|
175
|
+
},
|
|
176
|
+
edges: {
|
|
177
|
+
total: edgeTotal,
|
|
178
|
+
aboutOrDiscussedIn: share(aboutEdges, edgeTotal),
|
|
179
|
+
relatedToOrMentions: share(looseEdges, edgeTotal),
|
|
180
|
+
byClass,
|
|
181
|
+
},
|
|
182
|
+
singleValuedOverfull: { total: overfullTotal, byField: sorted(overfull) },
|
|
183
|
+
timeline: { months: months.map((month) => ({ month, rows: perMonth.get(month) ?? 0 })), total: timelineTotal },
|
|
184
|
+
entities: { total: scan.entities.size, zeroRows: share(zeroRows, scan.entities.size), zeroRowsByType: sorted(zeroByType) },
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const percent = (value) => (value.of === 0 ? "n/a" : `${(value.share * 100).toFixed(1)}%`);
|
|
188
|
+
/** The report as a markdown table: the same rows in the same order on every run. */
|
|
189
|
+
export function renderCoverage(report) {
|
|
190
|
+
const rows = [];
|
|
191
|
+
const line = (measure, value) => void rows.push([measure, String(value.count), String(value.of), percent(value)]);
|
|
192
|
+
const plain = (measure, value, note = "") => void rows.push([measure, String(value), "", note]);
|
|
193
|
+
plain("Internal people", report.internalPeople.total);
|
|
194
|
+
line("Internal people with a role", report.internalPeople.withRole);
|
|
195
|
+
line("Internal people with a team", report.internalPeople.withTeam);
|
|
196
|
+
line("Internal people with a manager", report.internalPeople.withManager);
|
|
197
|
+
line("Internal people with role, team and manager", report.internalPeople.withAll);
|
|
198
|
+
plain("Projects", report.projects.total);
|
|
199
|
+
line("Projects with an owner", report.projects.withOwner);
|
|
200
|
+
line("Projects with a status", report.projects.withStatus);
|
|
201
|
+
line("Projects with an owner and a status", report.projects.withBoth);
|
|
202
|
+
plain("Customers", report.customers.total);
|
|
203
|
+
line("Customers with any stage", report.customers.withStage);
|
|
204
|
+
line("Customers with an informative stage", report.customers.withInformativeStage);
|
|
205
|
+
line("Customers with a contact", report.customers.withContact);
|
|
206
|
+
line("Customers with an informative stage and a contact", report.customers.withBoth);
|
|
207
|
+
plain("Edges", report.edges.total);
|
|
208
|
+
line("Edges that are about or discussed_in", report.edges.aboutOrDiscussedIn);
|
|
209
|
+
line("Edges that are related_to or mentions", report.edges.relatedToOrMentions);
|
|
210
|
+
line("Edges that state structure (state verbs)", share(report.edges.byClass.state, report.edges.total));
|
|
211
|
+
plain("Single-valued fields with 2 or more open rows", report.singleValuedOverfull.total, report.singleValuedOverfull.total === 0 ? "ok" : "must be 0");
|
|
212
|
+
for (const [key, count] of Object.entries(report.singleValuedOverfull.byField))
|
|
213
|
+
plain(` ${key}`, count);
|
|
214
|
+
for (const entry of report.timeline.months)
|
|
215
|
+
plain(`Timeline rows in ${entry.month}`, entry.rows);
|
|
216
|
+
plain("Entities", report.entities.total);
|
|
217
|
+
line("Entities with zero rows", report.entities.zeroRows);
|
|
218
|
+
for (const [type, count] of Object.entries(report.entities.zeroRowsByType))
|
|
219
|
+
plain(` ${type}`, count);
|
|
220
|
+
const header = ["Measure", "Count", "Of", "Share"];
|
|
221
|
+
const widths = header.map((title, index) => Math.max(title.length, ...rows.map((row) => row[index].length)));
|
|
222
|
+
const format = (row) => `| ${row.map((cell, index) => (index === 0 ? cell.padEnd(widths[index]) : cell.padStart(widths[index]))).join(" | ")} |`;
|
|
223
|
+
return [
|
|
224
|
+
`Ontology graph coverage: ${report.graphRoot}`,
|
|
225
|
+
`Day ${report.day}. Company: ${report.self ?? "not found in the graph (no internal people or customers can be counted)"}.`,
|
|
226
|
+
"",
|
|
227
|
+
format(header),
|
|
228
|
+
`| ${widths.map((width, index) => (index === 0 ? "-".repeat(width) : `${"-".repeat(width - 1)}:`)).join(" | ")} |`,
|
|
229
|
+
...rows.map(format),
|
|
230
|
+
].join("\n");
|
|
231
|
+
}
|
|
232
|
+
/** Reads the graph and counts. Writes nothing. */
|
|
233
|
+
export function runCoverage(context, options = {}) {
|
|
234
|
+
return measureCoverage(scanGraph(openGraphStore(context.graphRoot, { company: context.company })), context, options);
|
|
235
|
+
}
|
|
236
|
+
/** `hq ontology lint --coverage`: the table, or the same numbers as JSON with `--json`. */
|
|
237
|
+
export async function coverageCommand(context, options = {}) {
|
|
238
|
+
const report = runCoverage(context, options);
|
|
239
|
+
return { text: renderCoverage(report), json: report };
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { BriefOptions, CommandOutput, GraphContext, IsoDate, IsoTimestamp, LintOptions, LintReport, ReplayInputKind, ReplayInputReader, ReplayRunResult, UpdateOptions } from "../types.js";
|
|
2
|
+
/** Daily cap on model input tokens (design section 5). It is what `hq ontology update --budget-tokens` counts. */
|
|
3
|
+
export declare const DAILY_BUDGET_TOKENS = 150000;
|
|
4
|
+
/** Days between two lints of the whole graph by the daily job. In between it lints what each update touched. */
|
|
5
|
+
export declare const FULL_LINT_EVERY_DAYS = 7;
|
|
6
|
+
/** How far back the change check looks for new or changed inputs. */
|
|
7
|
+
export declare const CHANGE_WINDOW_DAYS = 14;
|
|
8
|
+
export interface DailyState {
|
|
9
|
+
/** Local calendar day of the last run that did work. */
|
|
10
|
+
day: IsoDate;
|
|
11
|
+
lastRunAt: IsoTimestamp;
|
|
12
|
+
status: "ran" | "failed";
|
|
13
|
+
/** Fingerprint of the inputs the last good run saw. Null when it could not be computed. */
|
|
14
|
+
fingerprint: string | null;
|
|
15
|
+
/** Local day of the last run that linted the whole graph. */
|
|
16
|
+
lastFullLintDay?: IsoDate;
|
|
17
|
+
/** Model input tokens spent by every run on `day`; the budget is charged against this. */
|
|
18
|
+
tokensToday: number;
|
|
19
|
+
/** Model output tokens spent by every run on `day`. */
|
|
20
|
+
outputTokensToday?: number;
|
|
21
|
+
run?: string;
|
|
22
|
+
rowsAdded?: number;
|
|
23
|
+
lintErrors?: number;
|
|
24
|
+
lintWarnings?: number;
|
|
25
|
+
proposalsFiled?: number;
|
|
26
|
+
seconds?: number;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface DailyDeps {
|
|
30
|
+
update: (context: GraphContext, options: UpdateOptions) => Promise<ReplayRunResult>;
|
|
31
|
+
lint: (context: GraphContext, options: LintOptions) => Promise<LintReport>;
|
|
32
|
+
brief: (context: GraphContext, options: BriefOptions) => Promise<CommandOutput>;
|
|
33
|
+
/** A value that changes when an input was added or changed. Null: cannot tell, so run. */
|
|
34
|
+
fingerprint: (context: GraphContext, today: IsoDate) => Promise<string | null>;
|
|
35
|
+
}
|
|
36
|
+
export interface DailyOptions {
|
|
37
|
+
/** Run even when nothing changed. */
|
|
38
|
+
force?: boolean;
|
|
39
|
+
/** The day's cap on model input tokens. Default DAILY_BUDGET_TOKENS. */
|
|
40
|
+
budgetTokens?: number;
|
|
41
|
+
/** Default: the clock. */
|
|
42
|
+
now?: Date;
|
|
43
|
+
deps?: Partial<DailyDeps>;
|
|
44
|
+
}
|
|
45
|
+
export interface DailyResult {
|
|
46
|
+
status: "ran" | "skipped" | "busy" | "failed";
|
|
47
|
+
reason?: string;
|
|
48
|
+
day: IsoDate;
|
|
49
|
+
/** Input tokens left for the day before this run. */
|
|
50
|
+
budgetLeft: number;
|
|
51
|
+
/** Input tokens this run spent. */
|
|
52
|
+
tokensUsed: number;
|
|
53
|
+
outputTokensUsed: number;
|
|
54
|
+
update?: Pick<ReplayRunResult, "run" | "days" | "partial" | "stoppedBecause"> & {
|
|
55
|
+
rowsAdded: number;
|
|
56
|
+
rowsClosed: number;
|
|
57
|
+
pending: number;
|
|
58
|
+
};
|
|
59
|
+
lint?: {
|
|
60
|
+
errors: number;
|
|
61
|
+
warnings: number;
|
|
62
|
+
proposalsFiled: number;
|
|
63
|
+
scope?: "all" | "touched";
|
|
64
|
+
};
|
|
65
|
+
briefWritten: boolean;
|
|
66
|
+
seconds: number;
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function readDailyState(graphRoot: string): DailyState | null;
|
|
70
|
+
/**
|
|
71
|
+
* A lock older than this is taken whatever its process id says. The scheduled
|
|
72
|
+
* script ends a run after 45 minutes, so a lock this old is not a run: its
|
|
73
|
+
* process id has been given to some other process, and without a limit that
|
|
74
|
+
* process would keep the daily run out for as long as it lives.
|
|
75
|
+
*/
|
|
76
|
+
export declare const LOCK_MAX_AGE_MS: number;
|
|
77
|
+
/** With `--force`, a lock older than this is taken: past the 45 minutes a scheduled run may last, with room to spare. */
|
|
78
|
+
export declare const LOCK_FORCE_AGE_MS: number;
|
|
79
|
+
/** A takeover file with nothing readable in it yet is a run that has just created it: it is left alone for this long. */
|
|
80
|
+
export declare const TAKEOVER_GRACE_MS = 10000;
|
|
81
|
+
/** A takeover is over in milliseconds. A takeover file older than this was left behind, whatever its process id says. */
|
|
82
|
+
export declare const TAKEOVER_MAX_AGE_MS = 60000;
|
|
83
|
+
export interface DailyLockOptions {
|
|
84
|
+
/** `--force`: also take a lock older than LOCK_FORCE_AGE_MS from a process that is alive. */
|
|
85
|
+
force?: boolean;
|
|
86
|
+
/** The wall clock, for the age of the takeover file. Default: Date.now(). */
|
|
87
|
+
clock?: () => number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Takes the run lock. Returns a release function, or null when a live run holds it.
|
|
91
|
+
*
|
|
92
|
+
* The lock is a file created exclusively (src/utils/exclusive-lock.ts). It is
|
|
93
|
+
* stale when its owner's process is gone, when it cannot be read, when this
|
|
94
|
+
* process left it behind, or when it is older than LOCK_MAX_AGE_MS (with
|
|
95
|
+
* `force`, LOCK_FORCE_AGE_MS). A stale lock is replaced under a second
|
|
96
|
+
* exclusive file, so of two runs that find the same stale lock one takes it
|
|
97
|
+
* and the other is told a run holds it. Release removes the lock only while it
|
|
98
|
+
* is still this run's.
|
|
99
|
+
*/
|
|
100
|
+
export declare function acquireDailyLock(graphRoot: string, now: Date, options?: DailyLockOptions): (() => void) | null;
|
|
101
|
+
/**
|
|
102
|
+
* Hash of every input dated in the last CHANGE_WINDOW_DAYS: kind, day, path,
|
|
103
|
+
* size and modified time. A new or edited signal, source, document or thread
|
|
104
|
+
* changes it; the graph's own files do not. Null when the readers cannot be
|
|
105
|
+
* created (no member identity, replay not available), which means "run".
|
|
106
|
+
*/
|
|
107
|
+
export declare function inputFingerprint(context: GraphContext, today: IsoDate, given?: Partial<Record<ReplayInputKind, ReplayInputReader>>): Promise<string | null>;
|
|
108
|
+
/**
|
|
109
|
+
* One daily run: update, lint, brief. Idempotent: a second run on unchanged
|
|
110
|
+
* inputs does nothing and writes nothing. Never throws for a failed step; the
|
|
111
|
+
* result says `failed` and the state file keeps the error.
|
|
112
|
+
*/
|
|
113
|
+
export declare function runDaily(context: GraphContext, options?: DailyOptions): Promise<DailyResult>;
|
|
114
|
+
/** `hq ontology daily [--force] [--budget-tokens N]`. Exit code 1 when a step failed. */
|
|
115
|
+
export declare function dailyCommand(context: GraphContext, options?: DailyOptions): Promise<CommandOutput>;
|
|
116
|
+
export declare const ONTOLOGY_DAILY_JOB_NAME = "ontology-daily";
|
|
117
|
+
/** 07:10 local: after the 06:30 signals run, so the day's new signals are in. */
|
|
118
|
+
export declare const ONTOLOGY_DAILY_SCHEDULE = "10 7 * * *";
|
|
119
|
+
/** The script gives the run this long before it stops it. */
|
|
120
|
+
export declare const ONTOLOGY_DAILY_TIMEOUT_SECONDS: number;
|
|
121
|
+
export declare function ontologyDailyScriptName(company: string): string;
|
|
122
|
+
/** The slice of a Fleet cron job this module reads. Matches `FleetCronJob` in src/lib/bot/fleet-cron.ts. */
|
|
123
|
+
export interface DailyCronJob {
|
|
124
|
+
id: string;
|
|
125
|
+
name?: string;
|
|
126
|
+
script?: string | null;
|
|
127
|
+
schedule?: {
|
|
128
|
+
expr?: string;
|
|
129
|
+
};
|
|
130
|
+
enabled?: boolean;
|
|
131
|
+
next_run_at?: string | null;
|
|
132
|
+
last_run_at?: string | null;
|
|
133
|
+
last_status?: string | null;
|
|
134
|
+
}
|
|
135
|
+
/** The slice of `FleetCronOps` this module calls. */
|
|
136
|
+
export interface DailyCronOps {
|
|
137
|
+
list(): DailyCronJob[];
|
|
138
|
+
create(input: {
|
|
139
|
+
prompt: string;
|
|
140
|
+
schedule: string;
|
|
141
|
+
origin: {
|
|
142
|
+
platform: "hqdm";
|
|
143
|
+
chat_id: string;
|
|
144
|
+
user_id: string;
|
|
145
|
+
chat_name?: string;
|
|
146
|
+
};
|
|
147
|
+
name?: string;
|
|
148
|
+
script?: string;
|
|
149
|
+
noAgent?: boolean;
|
|
150
|
+
workdir?: string;
|
|
151
|
+
}): DailyCronJob;
|
|
152
|
+
remove(id: string): boolean;
|
|
153
|
+
reschedule(id: string, schedule: string): DailyCronJob | null;
|
|
154
|
+
}
|
|
155
|
+
/** Where the job lives: the member's Executive bot and its Fleet profile. */
|
|
156
|
+
export interface DailyJobTarget {
|
|
157
|
+
botName: string;
|
|
158
|
+
/** ~/.hq/bots/<name>; the job's log goes in its `logs/` folder. */
|
|
159
|
+
botDir: string;
|
|
160
|
+
agentUid: string;
|
|
161
|
+
ownerUid: string;
|
|
162
|
+
/** The Fleet profile folder; scripts live in its `scripts/` folder. */
|
|
163
|
+
profileDir: string;
|
|
164
|
+
ops: DailyCronOps;
|
|
165
|
+
origin: (jobs: readonly DailyCronJob[]) => {
|
|
166
|
+
platform: "hqdm";
|
|
167
|
+
chat_id: string;
|
|
168
|
+
user_id: string;
|
|
169
|
+
chat_name?: string;
|
|
170
|
+
};
|
|
171
|
+
nodeBinary: string;
|
|
172
|
+
hqBinary: string;
|
|
173
|
+
/** Stable `hq` launcher that survives a CLI update, or "". */
|
|
174
|
+
launcher: string;
|
|
175
|
+
}
|
|
176
|
+
export declare class DailyJobError extends Error {
|
|
177
|
+
constructor(message: string);
|
|
178
|
+
}
|
|
179
|
+
export interface DailyJobDeps {
|
|
180
|
+
/** Default: the Executive bot on this computer. Null when there is none. */
|
|
181
|
+
resolveTarget?: () => Promise<DailyJobTarget | null>;
|
|
182
|
+
}
|
|
183
|
+
/** `HH:MM` (24 hour, local) to a daily cron expression. */
|
|
184
|
+
export declare function dailyCronAt(at: string): string;
|
|
185
|
+
export interface DailyScriptInput {
|
|
186
|
+
company: string;
|
|
187
|
+
hqRoot: string;
|
|
188
|
+
nodeBinary: string;
|
|
189
|
+
hqBinary: string;
|
|
190
|
+
launcher: string;
|
|
191
|
+
logFile: string;
|
|
192
|
+
/** Arguments after `hq`: the daily run. */
|
|
193
|
+
args: readonly string[];
|
|
194
|
+
/** The same work as separate commands, for an installed `hq` that has no `ontology daily` yet. */
|
|
195
|
+
steps: readonly (readonly string[])[];
|
|
196
|
+
timeoutSeconds: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The Python the Fleet runtime runs. It appends the run's output to the log
|
|
200
|
+
* and prints nothing unless the run failed. Finding `hq` follows the signals
|
|
201
|
+
* job: the entry this CLI was started from, then the stable pnpm launcher,
|
|
202
|
+
* then PATH. When the installed `hq` answers "unknown command" for
|
|
203
|
+
* `ontology daily` (an older CLI), it runs update, lint and brief one by one.
|
|
204
|
+
*/
|
|
205
|
+
export declare function renderOntologyDailyScript(input: DailyScriptInput): string;
|
|
206
|
+
/** The arguments the script passes to `hq`: the daily run for this company. */
|
|
207
|
+
export declare function dailyArgs(context: GraphContext, budgetTokens: number | undefined): string[];
|
|
208
|
+
/** The same work as the three commands every `hq ontology` has. No shared day budget and no change check. */
|
|
209
|
+
export declare function dailySteps(context: GraphContext, budgetTokens: number | undefined): string[][];
|
|
210
|
+
export interface DailyJobInstallOptions {
|
|
211
|
+
/** `HH:MM` local. Default 07:10. */
|
|
212
|
+
at?: string;
|
|
213
|
+
budgetTokens?: number;
|
|
214
|
+
deps?: DailyJobDeps;
|
|
215
|
+
}
|
|
216
|
+
export interface DailyJobInstallResult {
|
|
217
|
+
bot: string;
|
|
218
|
+
job: DailyCronJob;
|
|
219
|
+
created: boolean;
|
|
220
|
+
rescheduled: boolean;
|
|
221
|
+
schedule: string;
|
|
222
|
+
scriptFile: string;
|
|
223
|
+
logFile: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Registers the daily job for this company on the member's Executive bot.
|
|
227
|
+
* Idempotent: the script is rewritten every time, the job is created once, and
|
|
228
|
+
* a different `--at` moves the existing job instead of adding a second one.
|
|
229
|
+
*/
|
|
230
|
+
export declare function installDailyJob(context: GraphContext, options?: DailyJobInstallOptions): Promise<DailyJobInstallResult>;
|
|
231
|
+
export interface DailyJobUninstallResult {
|
|
232
|
+
bot: string;
|
|
233
|
+
removed: string[];
|
|
234
|
+
scriptRemoved: boolean;
|
|
235
|
+
}
|
|
236
|
+
/** Removes the job and its script. Idempotent. The graph folder and the log are left alone. */
|
|
237
|
+
export declare function uninstallDailyJob(context: GraphContext, options?: {
|
|
238
|
+
deps?: DailyJobDeps;
|
|
239
|
+
}): Promise<DailyJobUninstallResult>;
|
|
240
|
+
export interface DailyJobStatus {
|
|
241
|
+
bot: string | null;
|
|
242
|
+
installed: boolean;
|
|
243
|
+
job: DailyCronJob | null;
|
|
244
|
+
lastRun: DailyState | null;
|
|
245
|
+
}
|
|
246
|
+
export declare function dailyJobStatus(context: GraphContext, options?: {
|
|
247
|
+
deps?: DailyJobDeps;
|
|
248
|
+
}): Promise<DailyJobStatus>;
|
|
249
|
+
/** `hq ontology job install [--at HH:MM] [--budget-tokens N]`. */
|
|
250
|
+
export declare function jobInstallCommand(context: GraphContext, options?: DailyJobInstallOptions): Promise<CommandOutput>;
|
|
251
|
+
/** `hq ontology job uninstall`. */
|
|
252
|
+
export declare function jobUninstallCommand(context: GraphContext, options?: {
|
|
253
|
+
deps?: DailyJobDeps;
|
|
254
|
+
}): Promise<CommandOutput>;
|
|
255
|
+
/** `hq ontology job status`. */
|
|
256
|
+
export declare function jobStatusCommand(context: GraphContext, options?: {
|
|
257
|
+
deps?: DailyJobDeps;
|
|
258
|
+
}): Promise<CommandOutput>;
|
|
259
|
+
//# sourceMappingURL=daily-job.d.ts.map
|