@indigoai-us/hq-cli 5.345.246 → 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 +63 -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 +1116 -3
- package/dist/command-catalog.generated.js +1373 -3
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/install-global.d.ts +15 -0
- package/dist/commands/install-global.js +98 -4
- 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/mcp-registration.d.ts +17 -0
- package/dist/commands/mcp-registration.js +119 -0
- 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/commands/pkg-install.js +1 -1
- package/dist/commands/reindex.js +1 -1
- 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/doctor/checks/antigravity-wiring.d.ts +21 -0
- package/dist/lib/doctor/checks/antigravity-wiring.js +75 -0
- package/dist/lib/doctor/checks/anywhere.js +30 -0
- package/dist/lib/doctor/checks/runtime-probe.js +13 -0
- package/dist/lib/doctor/platform.d.ts +1 -1
- package/dist/lib/doctor/platform.js +5 -0
- package/dist/lib/doctor/registry.js +3 -0
- 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/hook-engine/coverage.d.ts +91 -0
- package/dist/lib/hook-engine/coverage.js +184 -0
- 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/install/antigravity-targets.d.ts +39 -0
- package/dist/lib/install/antigravity-targets.js +122 -0
- 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,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-C: the org-layer seed reader. The company's reporting lines are kept by
|
|
3
|
+
* people in the HQ org-layer table and served by `GET /v1/org-layer/graph`,
|
|
4
|
+
* which any active member of the company may read. This file reads it with the
|
|
5
|
+
* CLI's own signed-in session (the same token and client `hq crm` and `hq
|
|
6
|
+
* secrets` use: no new sign-in path, no token on disk or in output), keeps the
|
|
7
|
+
* answer in `.state/org-layer.json` in the graph folder, and turns it into
|
|
8
|
+
* seed rows. A rebuild with no network reads the kept answer.
|
|
9
|
+
*
|
|
10
|
+
* Read-only: two GET calls. Nothing is written to the service.
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import { atomicWriteFile, graphPath } from "../store/index.js";
|
|
14
|
+
import { isEmail, normalizeEmail } from "./normalize.js";
|
|
15
|
+
export const ORG_LAYER_CACHE = ".state/org-layer.json";
|
|
16
|
+
const PERSON_UID_RE = /^prs_[0-9A-Za-z]+$/;
|
|
17
|
+
const MEMBER_UID_RE = /^(?:prs|agt)_[0-9A-Za-z]+$/;
|
|
18
|
+
const text = (value) => (typeof value === "string" ? value.trim() : "");
|
|
19
|
+
const list = (value) => (Array.isArray(value) ? value : []);
|
|
20
|
+
const record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21
|
+
function dayOfStamp(value) {
|
|
22
|
+
const match = /^(\d{4}-\d{2}-\d{2})(?:$|[T ])/.exec(text(value));
|
|
23
|
+
return match ? match[1] : null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The default fetcher: the CLI's signed-in person session and its vault API
|
|
27
|
+
* client. It never opens a browser sign-in (a member who is signed out gets an
|
|
28
|
+
* error, and the caller falls back to the kept answer).
|
|
29
|
+
*/
|
|
30
|
+
export const signedInOrgLayerFetcher = async (company) => {
|
|
31
|
+
const { ensureCognitoToken } = await import("../../../utils/cognito-session.js");
|
|
32
|
+
const { getEntityUid, vaultApiFetch } = await import("../../../utils/vault-api.js");
|
|
33
|
+
const token = await ensureCognitoToken({ interactive: false, tokenSource: "person" });
|
|
34
|
+
const companyUid = await getEntityUid(token, { companySlug: company });
|
|
35
|
+
const read = async (path) => {
|
|
36
|
+
const response = await vaultApiFetch({ token, path, query: { companyUid }, signal: AbortSignal.timeout(30_000) });
|
|
37
|
+
if (!response.ok)
|
|
38
|
+
throw new Error(`org layer: GET ${path} answered ${response.status}`);
|
|
39
|
+
return (await response.json());
|
|
40
|
+
};
|
|
41
|
+
const graph = await read("/v1/org-layer/graph");
|
|
42
|
+
// The member list is a second call. Reporting lines are still worth keeping when it fails.
|
|
43
|
+
const aggregate = await read("/v1/org-layer/graph/aggregate").catch(() => null);
|
|
44
|
+
return { companyUid, graph, aggregate };
|
|
45
|
+
};
|
|
46
|
+
export function readOrgLayerCache(graphRoot) {
|
|
47
|
+
try {
|
|
48
|
+
const loaded = JSON.parse(fs.readFileSync(graphPath(graphRoot, ORG_LAYER_CACHE), "utf8"));
|
|
49
|
+
if (loaded.schema !== 1 || typeof loaded.company !== "string" || typeof loaded.fetchedAt !== "string")
|
|
50
|
+
return null;
|
|
51
|
+
return { schema: 1, company: loaded.company, companyUid: text(loaded.companyUid), fetchedAt: loaded.fetchedAt, graph: loaded.graph ?? null, aggregate: loaded.aggregate ?? null };
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reads the org layer and keeps it under the graph root. On any failure the
|
|
59
|
+
* kept answer stays as it was. The error text is cut to its first line and to
|
|
60
|
+
* 200 characters, so a response body never reaches a log.
|
|
61
|
+
*/
|
|
62
|
+
export async function refreshOrgLayerCache(context, options = {}) {
|
|
63
|
+
const fetcher = options.fetcher ?? signedInOrgLayerFetcher;
|
|
64
|
+
try {
|
|
65
|
+
const fetched = await fetcher(context.company);
|
|
66
|
+
const snapshot = {
|
|
67
|
+
schema: 1,
|
|
68
|
+
company: context.company,
|
|
69
|
+
companyUid: fetched.companyUid,
|
|
70
|
+
fetchedAt: options.now ?? new Date().toISOString(),
|
|
71
|
+
graph: fetched.graph,
|
|
72
|
+
aggregate: fetched.aggregate,
|
|
73
|
+
};
|
|
74
|
+
atomicWriteFile(graphPath(context.graphRoot, ORG_LAYER_CACHE), `${JSON.stringify(snapshot, null, 2)}\n`);
|
|
75
|
+
return { status: "fetched", fetchedAt: snapshot.fetchedAt };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const reason = (error instanceof Error ? error.message : String(error)).split("\n")[0].slice(0, 200);
|
|
79
|
+
const kept = readOrgLayerCache(context.graphRoot);
|
|
80
|
+
return kept && kept.company === context.company ? { status: "cached", reason, fetchedAt: kept.fetchedAt } : { status: "unavailable", reason };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Turns a kept answer into seed input. Rows that do not name two member ids are left out. */
|
|
84
|
+
export function parseOrgLayer(snapshot) {
|
|
85
|
+
if (!snapshot)
|
|
86
|
+
return null;
|
|
87
|
+
const graph = record(snapshot.graph);
|
|
88
|
+
const aggregate = record(snapshot.aggregate);
|
|
89
|
+
const fetchedDay = dayOfStamp(snapshot.fetchedAt);
|
|
90
|
+
const edges = [];
|
|
91
|
+
const seenEdge = new Set();
|
|
92
|
+
for (const entry of list(graph.edges)) {
|
|
93
|
+
const edge = record(entry);
|
|
94
|
+
const managerUid = text(edge.managerMemberId);
|
|
95
|
+
const reportUid = text(edge.reportMemberId);
|
|
96
|
+
if (!MEMBER_UID_RE.test(managerUid) || !MEMBER_UID_RE.test(reportUid) || managerUid === reportUid)
|
|
97
|
+
continue;
|
|
98
|
+
const relation = text(edge.relation) === "speaks-for" ? "speaks-for" : "reports-to";
|
|
99
|
+
const key = `${relation}\n${reportUid}\n${managerUid}`;
|
|
100
|
+
if (seenEdge.has(key))
|
|
101
|
+
continue;
|
|
102
|
+
seenEdge.add(key);
|
|
103
|
+
const setBy = text(edge.createdBy);
|
|
104
|
+
edges.push({
|
|
105
|
+
managerUid,
|
|
106
|
+
reportUid,
|
|
107
|
+
relation,
|
|
108
|
+
human: text(edge.origin) === "human-set",
|
|
109
|
+
setBy: PERSON_UID_RE.test(setBy) ? setBy : "",
|
|
110
|
+
day: dayOfStamp(edge.createdAt) ?? dayOfStamp(edge.updatedAt) ?? fetchedDay,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
edges.sort((a, b) => (a.reportUid + a.managerUid + a.relation < b.reportUid + b.managerUid + b.relation ? -1 : 1));
|
|
114
|
+
const members = [];
|
|
115
|
+
const identities = record(aggregate.identities);
|
|
116
|
+
const seenMember = new Set();
|
|
117
|
+
for (const entry of list(aggregate.nodes)) {
|
|
118
|
+
const node = record(entry);
|
|
119
|
+
const uid = text(node.id);
|
|
120
|
+
if (!MEMBER_UID_RE.test(uid) || seenMember.has(uid))
|
|
121
|
+
continue;
|
|
122
|
+
seenMember.add(uid);
|
|
123
|
+
const identity = record(identities[uid]);
|
|
124
|
+
const email = normalizeEmail(text(identity.email));
|
|
125
|
+
const name = text(identity.name) || text(node.name);
|
|
126
|
+
members.push({
|
|
127
|
+
uid,
|
|
128
|
+
// The service falls back to the email or the id when it has no name: that is not a name.
|
|
129
|
+
name: name === uid || isEmail(name) ? "" : name,
|
|
130
|
+
email: isEmail(email) ? email : "",
|
|
131
|
+
kind: text(node.kind) === "agent" || uid.startsWith("agt_") ? "agent" : "human",
|
|
132
|
+
membershipRole: text(node.role),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
members.sort((a, b) => (a.uid < b.uid ? -1 : 1));
|
|
136
|
+
const suggestions = [];
|
|
137
|
+
for (const entry of list(graph.suggestions)) {
|
|
138
|
+
const suggestion = record(entry);
|
|
139
|
+
if (text(suggestion.type) !== "reporting_line" || text(suggestion.status) !== "pending")
|
|
140
|
+
continue;
|
|
141
|
+
const claim = record(suggestion.claim);
|
|
142
|
+
const managerUid = text(claim.managerMemberId);
|
|
143
|
+
const reportUid = text(claim.reportMemberId);
|
|
144
|
+
if (!MEMBER_UID_RE.test(managerUid) || !MEMBER_UID_RE.test(reportUid) || managerUid === reportUid)
|
|
145
|
+
continue;
|
|
146
|
+
if (seenEdge.has(`reports-to\n${reportUid}\n${managerUid}`))
|
|
147
|
+
continue;
|
|
148
|
+
const confidence = typeof suggestion.confidence === "number" && Number.isFinite(suggestion.confidence) ? suggestion.confidence : 0;
|
|
149
|
+
suggestions.push({
|
|
150
|
+
managerUid,
|
|
151
|
+
reportUid,
|
|
152
|
+
confidence: Math.max(0, Math.min(1, confidence)),
|
|
153
|
+
sources: list(suggestion.citations).map((citation) => text(record(citation).sourcePath)).filter((path) => path !== "").slice(0, 5),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
suggestions.sort((a, b) => (a.reportUid + a.managerUid < b.reportUid + b.managerUid ? -1 : 1));
|
|
157
|
+
return { fetchedAt: snapshot.fetchedAt, edges, members, suggestions };
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=org-layer.js.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-C: writes the org structure the files in org-sources.ts and the org-layer
|
|
3
|
+
* reader state: reporting lines, role titles, teams, project owners, customers
|
|
4
|
+
* and who works where. Rules only. Every row cites its file or record.
|
|
5
|
+
*
|
|
6
|
+
* Honest by construction:
|
|
7
|
+
* - a team is written only when two independent sources point at it; one
|
|
8
|
+
* source files a proposal;
|
|
9
|
+
* - a role title from signals needs two documents that agree;
|
|
10
|
+
* - a first name resolves only to the one member of the company who has it;
|
|
11
|
+
* - a billing record is not a customer; a signed or effective agreement is.
|
|
12
|
+
*/
|
|
13
|
+
import type { EntityRef, IsoDate, IsoTimestamp, SourceRef } from "../types.js";
|
|
14
|
+
import type { EntityIndex } from "./entity-index.js";
|
|
15
|
+
import type { OrgLayerSeed } from "./org-layer.js";
|
|
16
|
+
import { type OrgSources, type SeedClient } from "./org-sources.js";
|
|
17
|
+
import { type GraphWriter } from "./writer.js";
|
|
18
|
+
export interface OrgSeedCounts {
|
|
19
|
+
/** People with a role title from a rule (the roster's own titles are counted by the seed). */
|
|
20
|
+
rolesDerived: number;
|
|
21
|
+
rolesBySource: Record<string, number>;
|
|
22
|
+
roleStatementsUnresolved: number;
|
|
23
|
+
signalRolesOneDocument: number;
|
|
24
|
+
teamsAsserted: number;
|
|
25
|
+
teamsProposed: number;
|
|
26
|
+
teamMembers: number;
|
|
27
|
+
teamMembersProposed: number;
|
|
28
|
+
teamLeads: number;
|
|
29
|
+
/** A title from signals alone that suggests someone leads a team: proposal only. */
|
|
30
|
+
teamLeadsProposed: number;
|
|
31
|
+
channelsNotATeam: number;
|
|
32
|
+
orgLayerEdges: number;
|
|
33
|
+
orgLayerHumanEdges: number;
|
|
34
|
+
orgLayerAgentEdges: number;
|
|
35
|
+
orgLayerUnresolved: number;
|
|
36
|
+
orgLayerSpeaksFor: number;
|
|
37
|
+
orgLayerSuggestions: number;
|
|
38
|
+
prdOwners: number;
|
|
39
|
+
prdOwnersUnresolved: number;
|
|
40
|
+
clients: number;
|
|
41
|
+
clientsWithStage: number;
|
|
42
|
+
clientCustomers: number;
|
|
43
|
+
clientOwners: number;
|
|
44
|
+
clientOwnersUnresolved: number;
|
|
45
|
+
clientContacts: number;
|
|
46
|
+
internalByDomain: number;
|
|
47
|
+
/** People with an address on the company's own domain who are not on the roster: left unplaced. */
|
|
48
|
+
ownDomainNotOnRoster: number;
|
|
49
|
+
internalByAttendance: number;
|
|
50
|
+
externalByDomain: number;
|
|
51
|
+
standupAttendees: number;
|
|
52
|
+
firstNamesResolved: number;
|
|
53
|
+
}
|
|
54
|
+
export declare function emptyOrgSeedCounts(): OrgSeedCounts;
|
|
55
|
+
/** One pointer from a source to "this person is in this working group". */
|
|
56
|
+
export interface TeamEvidence {
|
|
57
|
+
person: EntityRef;
|
|
58
|
+
/** A function key, or `name:<normalized>` for a team a roster names outright. */
|
|
59
|
+
team: string;
|
|
60
|
+
/** Display name. */
|
|
61
|
+
label: string;
|
|
62
|
+
/** What counts as one independent source: `standup`, `channel`, `git`, `policy`, `signal`, or `roster:<file>`. */
|
|
63
|
+
source: string;
|
|
64
|
+
src: SourceRef;
|
|
65
|
+
day: IsoDate;
|
|
66
|
+
}
|
|
67
|
+
export interface OrgSeedState {
|
|
68
|
+
writer: GraphWriter;
|
|
69
|
+
index: EntityIndex;
|
|
70
|
+
learned: IsoDate;
|
|
71
|
+
now: IsoTimestamp;
|
|
72
|
+
selfRef: EntityRef | null;
|
|
73
|
+
selfName: string;
|
|
74
|
+
ownDomains: ReadonlySet<string>;
|
|
75
|
+
/** People known to belong to the company itself. Grows as rules mark more. */
|
|
76
|
+
internal: Set<EntityRef>;
|
|
77
|
+
/**
|
|
78
|
+
* True when a roster exists (workspace members, people files). Then the
|
|
79
|
+
* roster alone says who is inside: a mail domain or a standup line marks
|
|
80
|
+
* nobody internal.
|
|
81
|
+
*/
|
|
82
|
+
rosterAuthoritative?: boolean;
|
|
83
|
+
/** People whose role title a kept record already states. */
|
|
84
|
+
titled: Map<EntityRef, {
|
|
85
|
+
title: string;
|
|
86
|
+
conf: number;
|
|
87
|
+
src: SourceRef;
|
|
88
|
+
day: IsoDate;
|
|
89
|
+
}>;
|
|
90
|
+
teamEvidence: TeamEvidence[];
|
|
91
|
+
counts: OrgSeedCounts;
|
|
92
|
+
}
|
|
93
|
+
export interface NameResolution {
|
|
94
|
+
ref: EntityRef | null;
|
|
95
|
+
/** `key`, `name` or `first_name`. */
|
|
96
|
+
how: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolves a person written in an internal file: by email, person uid, Slack
|
|
100
|
+
* id or old entity path first, then by full name, then (one word only) by the
|
|
101
|
+
* one member of the company with that first name.
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolvePersonName(state: OrgSeedState, written: string, email?: string): NameResolution;
|
|
104
|
+
export declare function applyOrgLayerLinks(state: OrgSeedState, orgLayer: OrgLayerSeed | null): void;
|
|
105
|
+
/**
|
|
106
|
+
* One role title per person who has none on record: a statement in a policy
|
|
107
|
+
* first, then a title two or more signal documents agree on.
|
|
108
|
+
*/
|
|
109
|
+
export declare function applyRoleStatements(state: OrgSeedState, sources: OrgSources): void;
|
|
110
|
+
export interface ChannelSeen {
|
|
111
|
+
name: string;
|
|
112
|
+
src: SourceRef;
|
|
113
|
+
firstDay: IsoDate;
|
|
114
|
+
frequent: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Writes a team when at least two independent sources point at it, and a
|
|
118
|
+
* membership when the team stands and either two sources or a kept roster
|
|
119
|
+
* file place the person in it. Everything short of that is a proposal.
|
|
120
|
+
*/
|
|
121
|
+
export declare function applyTeams(state: OrgSeedState, channels: readonly ChannelSeen[]): void;
|
|
122
|
+
/** Standup headings: `## <Name> — <area>` is one source for the person's working group. */
|
|
123
|
+
export declare function collectStandupEvidence(state: OrgSeedState, sources: OrgSources): void;
|
|
124
|
+
/** Marks people by the mail domain of an address they hold: the company's own domain, or the web domain of exactly one other company. */
|
|
125
|
+
export declare function applyEmailAffiliation(state: OrgSeedState): void;
|
|
126
|
+
/** A timeline line per regular standup attendee, and membership of the company for one found by full name. */
|
|
127
|
+
export declare function applyStandupAttendance(state: OrgSeedState, sources: OrgSources, minNotes?: number): void;
|
|
128
|
+
export declare function applyPrdOwners(state: OrgSeedState, sources: OrgSources, phase: {
|
|
129
|
+
anchors: boolean;
|
|
130
|
+
links: boolean;
|
|
131
|
+
}): number;
|
|
132
|
+
/**
|
|
133
|
+
* Companies from the clients folder: a stage where a file states one, a
|
|
134
|
+
* customer edge only where a file says an agreement is signed or in effect,
|
|
135
|
+
* the people named as contacts, and the account owner.
|
|
136
|
+
*/
|
|
137
|
+
export declare function applyClients(state: OrgSeedState, clients: readonly SeedClient[], phase: {
|
|
138
|
+
anchors: boolean;
|
|
139
|
+
links: boolean;
|
|
140
|
+
}): number;
|
|
141
|
+
//# sourceMappingURL=org-seed.d.ts.map
|