@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,49 @@
|
|
|
1
|
+
export interface LegacyRelationship {
|
|
2
|
+
/** The free-text verb: `Works on`, `Related to`, `Referenced in`. */
|
|
3
|
+
label: string;
|
|
4
|
+
/** The link text. */
|
|
5
|
+
text: string;
|
|
6
|
+
target: LegacyTarget;
|
|
7
|
+
}
|
|
8
|
+
export type LegacyTarget = {
|
|
9
|
+
kind: "entity"; /** Old `type/slug`. */
|
|
10
|
+
path: string;
|
|
11
|
+
type: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "signal";
|
|
14
|
+
/** 64 hex signal id. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Path under the company's `signals/` folder. */
|
|
17
|
+
relPath: string;
|
|
18
|
+
signalType: string;
|
|
19
|
+
/** `company`, `personal` (a DM signal) or a 16 hex audience key. */
|
|
20
|
+
scope: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "none";
|
|
23
|
+
};
|
|
24
|
+
export interface LegacyEntityFile {
|
|
25
|
+
/** Path under the entities folder, forward slashes: `person/dan-schwartz.md`. */
|
|
26
|
+
relPath: string;
|
|
27
|
+
/** Top-level folder: `person`, `tool`. */
|
|
28
|
+
dirType: string;
|
|
29
|
+
fileSlug: string;
|
|
30
|
+
/** 64 hex. */
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
aliases: string[];
|
|
34
|
+
firstSeen: string;
|
|
35
|
+
lastUpdated: string;
|
|
36
|
+
/** `<system>:<id>`. */
|
|
37
|
+
externalIds: string[];
|
|
38
|
+
webDomains: string[];
|
|
39
|
+
/** Older ids this file was merged from, 64 hex. */
|
|
40
|
+
legacyIds: string[];
|
|
41
|
+
relationships: LegacyRelationship[];
|
|
42
|
+
}
|
|
43
|
+
/** `../project/hq-cli.md`, `../../signals/slack-dm/question/<sha>.md`, or empty. */
|
|
44
|
+
export declare function parseLegacyTarget(link: string): LegacyTarget;
|
|
45
|
+
/** `- <Verb> [text](target)`. The text may itself contain brackets. */
|
|
46
|
+
export declare function parseRelationshipLine(line: string): LegacyRelationship | null;
|
|
47
|
+
/** Parses one old entity file. Null when it has no usable frontmatter. */
|
|
48
|
+
export declare function parseLegacyEntity(text: string, relPath: string): LegacyEntityFile | null;
|
|
49
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-C: reader for the old `ontology/entities/<type>/<slug>.md` files.
|
|
3
|
+
* Read-only: nothing here writes to that folder.
|
|
4
|
+
*/
|
|
5
|
+
import yaml from "js-yaml";
|
|
6
|
+
import { splitLenientFrontmatter } from "../../../utils/frontmatter.js";
|
|
7
|
+
function loadFrontmatter(block) {
|
|
8
|
+
for (const candidate of [block, block.replace(/\t/g, " ")]) {
|
|
9
|
+
try {
|
|
10
|
+
const loaded = yaml.load(candidate, { schema: yaml.CORE_SCHEMA });
|
|
11
|
+
if (loaded && typeof loaded === "object" && !Array.isArray(loaded))
|
|
12
|
+
return loaded;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// try the next form
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// Last resort: the scalar keys the import needs, line by line.
|
|
19
|
+
const out = {};
|
|
20
|
+
for (const line of block.split("\n")) {
|
|
21
|
+
const match = /^(id|type|canonical_name|first_seen|last_updated):\s*(.+?)\s*$/.exec(line);
|
|
22
|
+
if (match)
|
|
23
|
+
out[match[1]] = match[2].replace(/^["']|["']$/g, "");
|
|
24
|
+
}
|
|
25
|
+
return typeof out.id === "string" && typeof out.canonical_name === "string" ? out : null;
|
|
26
|
+
}
|
|
27
|
+
const strings = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter((entry) => entry !== "") : [];
|
|
28
|
+
/** `../project/hq-cli.md`, `../../signals/slack-dm/question/<sha>.md`, or empty. */
|
|
29
|
+
export function parseLegacyTarget(link) {
|
|
30
|
+
const clean = link.trim().replace(/\\/g, "/");
|
|
31
|
+
if (clean === "")
|
|
32
|
+
return { kind: "none" };
|
|
33
|
+
const parts = clean.split("/").filter((part) => part !== "" && part !== "." && part !== "..");
|
|
34
|
+
const signals = parts.indexOf("signals");
|
|
35
|
+
if (signals >= 0) {
|
|
36
|
+
const rest = parts.slice(signals + 1);
|
|
37
|
+
const file = rest[rest.length - 1] ?? "";
|
|
38
|
+
const id = file.replace(/\.md$/, "").toLowerCase();
|
|
39
|
+
if (rest.length < 2 || !/^[0-9a-f]{12,64}$/.test(id))
|
|
40
|
+
return { kind: "none" };
|
|
41
|
+
const first = rest[0];
|
|
42
|
+
const scope = first === "slack-dm" ? "personal" : /^@[0-9a-f]{16}$/.test(first) ? first.slice(1) : "company";
|
|
43
|
+
return { kind: "signal", id, relPath: rest.join("/"), signalType: rest[rest.length - 2], scope };
|
|
44
|
+
}
|
|
45
|
+
if (parts.length < 2 || !parts[parts.length - 1].endsWith(".md"))
|
|
46
|
+
return { kind: "none" };
|
|
47
|
+
const entities = parts.indexOf("entities");
|
|
48
|
+
const tail = entities >= 0 ? parts.slice(entities + 1) : parts;
|
|
49
|
+
if (tail.length < 2)
|
|
50
|
+
return { kind: "none" };
|
|
51
|
+
const type = tail[0];
|
|
52
|
+
const slug = tail[tail.length - 1].slice(0, -3);
|
|
53
|
+
return { kind: "entity", path: `${type}/${slug}`, type };
|
|
54
|
+
}
|
|
55
|
+
/** `- <Verb> [text](target)`. The text may itself contain brackets. */
|
|
56
|
+
export function parseRelationshipLine(line) {
|
|
57
|
+
if (!line.startsWith("- "))
|
|
58
|
+
return null;
|
|
59
|
+
const open = line.indexOf(" [", 1);
|
|
60
|
+
const close = line.lastIndexOf("](");
|
|
61
|
+
const trimmed = line.trimEnd();
|
|
62
|
+
if (open < 2 || close < open || !trimmed.endsWith(")"))
|
|
63
|
+
return null;
|
|
64
|
+
const label = line.slice(2, open).trim();
|
|
65
|
+
if (label === "")
|
|
66
|
+
return null;
|
|
67
|
+
return {
|
|
68
|
+
label,
|
|
69
|
+
text: line.slice(open + 2, close).trim(),
|
|
70
|
+
target: parseLegacyTarget(trimmed.slice(close + 2, -1)),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Parses one old entity file. Null when it has no usable frontmatter. */
|
|
74
|
+
export function parseLegacyEntity(text, relPath) {
|
|
75
|
+
const body = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
76
|
+
const split = splitLenientFrontmatter(body);
|
|
77
|
+
if (!split)
|
|
78
|
+
return null;
|
|
79
|
+
const end = split.closeAt;
|
|
80
|
+
const frontmatter = loadFrontmatter(split.yaml);
|
|
81
|
+
if (!frontmatter)
|
|
82
|
+
return null;
|
|
83
|
+
const id = typeof frontmatter.id === "string" ? frontmatter.id.trim().toLowerCase() : "";
|
|
84
|
+
const name = typeof frontmatter.canonical_name === "string" ? frontmatter.canonical_name.replace(/\s+/g, " ").trim() : "";
|
|
85
|
+
if (!/^[0-9a-f]{12,64}$/.test(id) || name === "")
|
|
86
|
+
return null;
|
|
87
|
+
const externalIds = [];
|
|
88
|
+
const external = frontmatter.external_ids;
|
|
89
|
+
if (external && typeof external === "object" && !Array.isArray(external)) {
|
|
90
|
+
for (const [system, value] of Object.entries(external)) {
|
|
91
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
92
|
+
externalIds.push(`${system.toLowerCase()}:${value.trim()}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(frontmatter.external_refs)) {
|
|
96
|
+
for (const entry of frontmatter.external_refs) {
|
|
97
|
+
const ref = entry;
|
|
98
|
+
if (ref && typeof ref.system === "string" && typeof ref.recordId === "string" && ref.recordId.trim() !== "") {
|
|
99
|
+
externalIds.push(`${ref.system.toLowerCase()}:${ref.recordId.trim()}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const relationships = [];
|
|
104
|
+
for (const line of body.slice(end + 4).split("\n")) {
|
|
105
|
+
const relationship = parseRelationshipLine(line);
|
|
106
|
+
if (relationship)
|
|
107
|
+
relationships.push(relationship);
|
|
108
|
+
}
|
|
109
|
+
const segments = relPath.split("/");
|
|
110
|
+
const day = (value) => (typeof value === "string" ? value : value instanceof Date ? value.toISOString() : "");
|
|
111
|
+
return {
|
|
112
|
+
relPath,
|
|
113
|
+
dirType: segments[0] ?? "",
|
|
114
|
+
fileSlug: (segments[segments.length - 1] ?? "").replace(/\.md$/, ""),
|
|
115
|
+
id,
|
|
116
|
+
name,
|
|
117
|
+
aliases: strings(frontmatter.aliases),
|
|
118
|
+
firstSeen: day(frontmatter.first_seen),
|
|
119
|
+
lastUpdated: day(frontmatter.last_updated),
|
|
120
|
+
externalIds: [...new Set(externalIds)].sort(),
|
|
121
|
+
webDomains: strings(frontmatter.web_domains),
|
|
122
|
+
legacyIds: strings(frontmatter.legacy_ids).map((value) => value.toLowerCase()),
|
|
123
|
+
relationships,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-C: the legacy import run report, as markdown. Pure: takes the counts,
|
|
3
|
+
* returns text. The caller decides where the file goes.
|
|
4
|
+
*/
|
|
5
|
+
import type { LegacyImportReport } from "./index.js";
|
|
6
|
+
export interface LegacyReportMeta {
|
|
7
|
+
title: string;
|
|
8
|
+
/** Lines printed under the title: company, graph root, command, commit. */
|
|
9
|
+
context: readonly string[];
|
|
10
|
+
/** Shown under "Not done". */
|
|
11
|
+
notDone?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function renderLegacyImportReport(report: LegacyImportReport, meta: LegacyReportMeta): string;
|
|
14
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
function table(headers, rows) {
|
|
2
|
+
if (rows.length === 0)
|
|
3
|
+
return "None.\n";
|
|
4
|
+
const line = (cells) => `| ${cells.map((cell) => String(cell).replace(/\|/g, "\\|")).join(" | ")} |`;
|
|
5
|
+
return [line(headers), line(headers.map(() => "---")), ...rows.map(line)].join("\n") + "\n";
|
|
6
|
+
}
|
|
7
|
+
function counts(record, order = "count") {
|
|
8
|
+
const entries = Object.entries(record);
|
|
9
|
+
return order === "name"
|
|
10
|
+
? entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
11
|
+
: entries.sort(([a, x], [b, y]) => y - x || (a < b ? -1 : a > b ? 1 : 0));
|
|
12
|
+
}
|
|
13
|
+
const total = (record) => Object.values(record).reduce((sum, value) => sum + value, 0);
|
|
14
|
+
export function renderLegacyImportReport(report, meta) {
|
|
15
|
+
const out = [];
|
|
16
|
+
const push = (...lines) => void out.push(...lines);
|
|
17
|
+
push(`# ${meta.title}`, "");
|
|
18
|
+
push(`Written ${report.at}. ${report.dryRun ? "Dry run: nothing was written to the graph folder." : "Rows were written to the graph folder."} Rows are stamped \`learned ${report.learned}\`. Run time ${report.seconds} s.`, "");
|
|
19
|
+
for (const line of meta.context)
|
|
20
|
+
push(`- ${line}`);
|
|
21
|
+
push("");
|
|
22
|
+
push("## Counts", "");
|
|
23
|
+
push(table(["Measure", "Count"], [
|
|
24
|
+
["Old entity files read (entities in)", report.filesRead],
|
|
25
|
+
["Conflict copies skipped (imported types)", report.conflictCopiesSkipped],
|
|
26
|
+
["Accounting files skipped", report.accountingSkipped],
|
|
27
|
+
["Files that did not parse", report.parseFailures],
|
|
28
|
+
["Distinct graph entities the old files became (entities out)", total(report.entitiesOutByType)],
|
|
29
|
+
["Entities created by the import", report.entitiesCreated],
|
|
30
|
+
["Old files merged into an existing entity", report.merges],
|
|
31
|
+
["Old files already imported by an earlier run", report.alreadyImported],
|
|
32
|
+
["Slack-ID people in the graph (must be 0)", report.slackIdPeople],
|
|
33
|
+
["Old Slack-ID people parked in unresolved", report.slackIdPeopleSkipped],
|
|
34
|
+
["Old Slack-ID people joined to a real person through the Slack maps", report.slackIdPeopleResolved],
|
|
35
|
+
["Relationship lines read", report.relationshipLines],
|
|
36
|
+
["Distinct old labels (verbs) mapped", report.distinctLabels],
|
|
37
|
+
["Rows queued (seed and import)", report.rowsQueued],
|
|
38
|
+
["Rows added to the graph", report.rowsAdded],
|
|
39
|
+
["Rows refused by the schema", report.rowsRefused],
|
|
40
|
+
["Relationship lines dropped", total(report.rowsDropped)],
|
|
41
|
+
["Merge proposals", report.proposals],
|
|
42
|
+
]));
|
|
43
|
+
push("## Entities in and out, by type", "");
|
|
44
|
+
const types = [...new Set([...Object.keys(report.entitiesInByType), ...Object.keys(report.entitiesOutByType), ...Object.keys(report.graphEntitiesByType)])].sort();
|
|
45
|
+
push(table(["Type", "Old files in", "Entities out (from old files)", "In the graph after the run (with the seed)"], types.map((type) => [type, report.entitiesInByType[type] ?? 0, report.entitiesOutByType[type] ?? 0, report.graphEntitiesByType[type] ?? 0])));
|
|
46
|
+
if (Object.keys(report.otherTypesSkipped).length > 0) {
|
|
47
|
+
push("Other old types left in place: " + counts(report.otherTypesSkipped).map(([type, count]) => `${type} ${count}`).join(", ") + ".", "");
|
|
48
|
+
}
|
|
49
|
+
push("## Merges", "");
|
|
50
|
+
push(table(["Reason", "Old files"], counts(report.mergesByReason)));
|
|
51
|
+
push("Reasons: `identity_key` shared email, Slack id, CRM id or web domain; `identical_name` the same name after normalization " +
|
|
52
|
+
"(for companies also without a legal form), and no conflicting email, record id or web domain; `alias` the old file's name is a recorded alias of the entity (never used for people); " +
|
|
53
|
+
"`variant` a project name that is another project's name plus a suffix such as `-bug`, `-pr-2`, `-v16`; " +
|
|
54
|
+
"`slack_directory` a person named by a Slack id, joined through the Slack id maps.", "");
|
|
55
|
+
for (const [reason, examples] of Object.entries(report.mergeExamples).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
56
|
+
push(`Examples, ${reason}:`, "", ...examples.map((line) => `- ${line}`), "");
|
|
57
|
+
}
|
|
58
|
+
push("## Refusals", "");
|
|
59
|
+
push("Inputs that became no entity or no row, by reason code (seed and import together).", "");
|
|
60
|
+
push(table(["Reason", "Count"], counts(report.refusals)));
|
|
61
|
+
push("Aliases dropped (people: a Slack id, a path, a generic word, a title, a possessive, another person's name; every type: another old file's own name):", "");
|
|
62
|
+
push(table(["Reason", "Aliases"], counts(report.aliasesDropped)));
|
|
63
|
+
push(`Slack ids listed as an alias: ${report.slackIdAliasesKept} kept as an identity key, ${report.slackIdAliasesRejected} rejected (the Slack maps name someone else, or two old files claim the id).`, "");
|
|
64
|
+
push("## Verbs mapped", "");
|
|
65
|
+
push(table(["New row", "Count"], counts(report.verbCounts)));
|
|
66
|
+
push(`Flipped (subject and object swapped): ${report.edgesFlipped}. Ownership by a company written as \`part_of\`: ${report.edgesCoerced}. ` +
|
|
67
|
+
`Typed label with types the verb does not allow, written as \`related_to\` with the old label: ${report.edgesDowngraded}. ` +
|
|
68
|
+
`Edges that cite a signal both ends were referenced in: ${report.edgesCitingSignal}.`, "");
|
|
69
|
+
push("### Every old label", "");
|
|
70
|
+
push(table(["Old label", "Lines", "Became"], Object.entries(report.labels)
|
|
71
|
+
.sort(([a, x], [b, y]) => y.count - x.count || (a < b ? -1 : a > b ? 1 : 0))
|
|
72
|
+
.map(([label, entry]) => [label, entry.count, counts(entry.became).map(([what, count]) => `${what} ${count}`).join(", ")])));
|
|
73
|
+
push("## Rows dropped", "");
|
|
74
|
+
push(table(["Reason", "Lines"], counts(report.rowsDropped)));
|
|
75
|
+
push("## `Referenced in` links", "");
|
|
76
|
+
push(table(["Outcome", "Links"], [
|
|
77
|
+
["Written as a timeline row citing the signal", report.timeline.written],
|
|
78
|
+
["Left to the replay (the signal file lists the entity in entity_refs)", report.timeline.deferredToReplay],
|
|
79
|
+
["Skipped: the signal is a DM signal (personal scope)", report.timeline.personalScopeSkipped],
|
|
80
|
+
["Skipped: audience key the member does not hold", report.timeline.audienceSkipped],
|
|
81
|
+
["Skipped: the signal has no audience key and no member was given", report.timeline.noMemberSkipped],
|
|
82
|
+
]));
|
|
83
|
+
push("## Rows by kind", "");
|
|
84
|
+
push(table(["Kind", "Rows queued"], counts(report.rowsByKind)));
|
|
85
|
+
if (report.seed) {
|
|
86
|
+
const seed = report.seed;
|
|
87
|
+
push("## Identity seed", "");
|
|
88
|
+
push(table(["Measure", "Count"], [
|
|
89
|
+
["People files read", seed.counts.peopleFiles],
|
|
90
|
+
["DM files read (the member's own)", seed.counts.dmFilesRead],
|
|
91
|
+
["DM files skipped (another owner, or no member given)", seed.counts.dmFilesSkippedOtherOwner],
|
|
92
|
+
["Slack ids with an email", seed.counts.slackIdsWithEmail],
|
|
93
|
+
["Slack ids with a real name", seed.counts.slackIdsWithName],
|
|
94
|
+
["Contacts read", seed.counts.meshContacts],
|
|
95
|
+
["Contacts matched to a company identity by key", seed.counts.meshContactsMatched],
|
|
96
|
+
["Contacts left out (no tie to this company's sources)", seed.counts.meshContactsUnmatched],
|
|
97
|
+
["Agent contacts skipped", seed.counts.meshAgentsSkipped],
|
|
98
|
+
["Repos read", seed.counts.gitRepos],
|
|
99
|
+
["Repos that could not be read", seed.counts.gitReposFailed],
|
|
100
|
+
["Git authors (bots removed)", seed.counts.gitAuthors],
|
|
101
|
+
["Git bots skipped", seed.counts.gitBotsSkipped],
|
|
102
|
+
["Git authors with a known name and a different email (proposal only)", seed.counts.gitAuthorsSameNameOtherEmail],
|
|
103
|
+
["Identities with keys and no name (kept in the Slack directory, no person)", seed.counts.namelessIdentities],
|
|
104
|
+
["Board projects", seed.counts.boardProjects],
|
|
105
|
+
["CRM accounts", seed.counts.crmAccounts],
|
|
106
|
+
["CRM accounts without a name", seed.counts.crmAccountsUnnamed],
|
|
107
|
+
["People created", seed.peopleSeeded],
|
|
108
|
+
["People merged into one already seeded", seed.peopleMerged],
|
|
109
|
+
["People refused", seed.peopleRefused],
|
|
110
|
+
["Roles", seed.roles],
|
|
111
|
+
["Teams", seed.teams],
|
|
112
|
+
["Projects", seed.projects],
|
|
113
|
+
["Companies", seed.companies],
|
|
114
|
+
["reports_to edges", seed.reportsToEdges],
|
|
115
|
+
["member_of edges", seed.memberOfEdges],
|
|
116
|
+
["works_on edges", seed.worksOnEdges],
|
|
117
|
+
["owned_by edges", seed.ownsEdges],
|
|
118
|
+
["customer_of edges from a CRM stage", seed.customerEdges],
|
|
119
|
+
["Owners and managers that did not resolve to one person", seed.unresolvedOwners],
|
|
120
|
+
]));
|
|
121
|
+
const org = seed.org;
|
|
122
|
+
push("## Org rules", "");
|
|
123
|
+
const orgLayer = report.orgLayer;
|
|
124
|
+
push(`Org layer: mode \`${orgLayer.mode}\`, ${orgLayer.status}${orgLayer.fetchedAt ? `, answer of ${orgLayer.fetchedAt}` : ""}${orgLayer.reason ? ` (read failed: ${orgLayer.reason})` : ""}.`, "");
|
|
125
|
+
push(table(["Measure", "Count"], [
|
|
126
|
+
["Repos listed for the company", seed.counts.gitReposListed ?? 0],
|
|
127
|
+
["Repos read (every clone of the company's GitHub owner)", seed.counts.gitRepos],
|
|
128
|
+
["Org layer: human members", seed.counts.orgLayerMembers ?? 0],
|
|
129
|
+
["Org layer: members added as people", seed.counts.orgLayerMembersAdded ?? 0],
|
|
130
|
+
["Org layer: agents left out", seed.counts.orgLayerAgentsSkipped ?? 0],
|
|
131
|
+
["Org layer: reports_to edges written", org.orgLayerEdges],
|
|
132
|
+
["Org layer: of those, set by a person (origin human)", org.orgLayerHumanEdges],
|
|
133
|
+
["Org layer: edges with an agent at one end (left out)", org.orgLayerAgentEdges],
|
|
134
|
+
["Org layer: edges whose people did not resolve", org.orgLayerUnresolved],
|
|
135
|
+
["Org layer: speaks_for kept as related_to", org.orgLayerSpeaksFor],
|
|
136
|
+
["Org layer: suggested reporting lines filed as proposals", org.orgLayerSuggestions],
|
|
137
|
+
["Role titles from a rule (people with none on record)", org.rolesDerived],
|
|
138
|
+
...Object.entries(org.rolesBySource).sort(([a], [b]) => (a < b ? -1 : 1)).map(([source, count]) => [`Role titles from ${source}`, count]),
|
|
139
|
+
["Role statements whose person did not resolve", org.roleStatementsUnresolved],
|
|
140
|
+
["People with a signal role from one document only (not written)", org.signalRolesOneDocument],
|
|
141
|
+
["Teams written (two independent sources)", org.teamsAsserted],
|
|
142
|
+
["Teams with one source (proposal only)", org.teamsProposed],
|
|
143
|
+
["Team memberships written", org.teamMembers],
|
|
144
|
+
["Team memberships with one source (proposal only)", org.teamMembersProposed],
|
|
145
|
+
["Team leads from a role title on record or in a policy", org.teamLeads],
|
|
146
|
+
["Team leads suggested by a signal title (proposal only)", org.teamLeadsProposed],
|
|
147
|
+
["Channels that match no team (proposal only)", org.channelsNotATeam],
|
|
148
|
+
["Project owners from a PRD", org.prdOwners],
|
|
149
|
+
["PRD owners that did not resolve", org.prdOwnersUnresolved],
|
|
150
|
+
["Client folders that became a company", org.clients],
|
|
151
|
+
["Clients with a stated stage", org.clientsWithStage],
|
|
152
|
+
["Clients with a signed or effective agreement (customer_of)", org.clientCustomers],
|
|
153
|
+
["Client account owners", org.clientOwners],
|
|
154
|
+
["Client account owners that did not resolve", org.clientOwnersUnresolved],
|
|
155
|
+
["Client contacts written as people", org.clientContacts],
|
|
156
|
+
["CRM accounts whose stage is the same default on every account (stage left out)", seed.counts.crmStageConstant ?? 0],
|
|
157
|
+
["People marked internal by their mail domain", org.internalByDomain],
|
|
158
|
+
["People marked internal by standup attendance", org.internalByAttendance],
|
|
159
|
+
["People placed at another company by their mail domain", org.externalByDomain],
|
|
160
|
+
["Regular standup attendees", org.standupAttendees],
|
|
161
|
+
["First names resolved to the one member who has it", org.firstNamesResolved],
|
|
162
|
+
]));
|
|
163
|
+
}
|
|
164
|
+
if (report.coverage) {
|
|
165
|
+
const coverage = report.coverage;
|
|
166
|
+
push("## Org structure in the graph", "");
|
|
167
|
+
push(table(["Measure", "Count"], [
|
|
168
|
+
["People", coverage.people],
|
|
169
|
+
["People with a role", coverage.peopleWithRole],
|
|
170
|
+
["People with a team", coverage.peopleWithTeam],
|
|
171
|
+
["reports_to edges", coverage.reportsToEdges],
|
|
172
|
+
["Internal people (works at the company itself)", coverage.internalPeople],
|
|
173
|
+
["External people (works at another company, or status external)", coverage.externalPeople],
|
|
174
|
+
["People the graph cannot place inside or outside", coverage.unplacedPeople],
|
|
175
|
+
["People with a works_on edge", coverage.peopleWorkingOnAProject],
|
|
176
|
+
["Teams", coverage.teams],
|
|
177
|
+
["Roles", coverage.roles],
|
|
178
|
+
["Projects", coverage.projects],
|
|
179
|
+
["Projects with an owner", coverage.projectsWithOwner],
|
|
180
|
+
["Companies", coverage.companies],
|
|
181
|
+
["Customers (customer_of the company itself)", coverage.customers],
|
|
182
|
+
["Customers with a stage", coverage.customersWithStage],
|
|
183
|
+
["Companies with any stage", coverage.companiesWithStage],
|
|
184
|
+
...Object.entries(coverage.companiesByRelation).map(([relation, count]) => [`Companies with relation ${relation}`, count]),
|
|
185
|
+
["related_to edges (each pair once)", coverage.relatedToEdges],
|
|
186
|
+
]));
|
|
187
|
+
if (report.payingCustomersStated) {
|
|
188
|
+
push(`Cross-check: the company's own KPI file states ${report.payingCustomersStated.payingCustomers} paying customers on ${report.payingCustomersStated.date}. The graph has ${coverage.customers} customers from signed or effective agreements and CRM stages; billing records alone are not counted.`, "");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
push("## Graph quality", "");
|
|
192
|
+
const quality = report.quality;
|
|
193
|
+
push(table(["Measure", "Count"], [
|
|
194
|
+
["First-name duplicates remaining (a one-word person beside a full-name person with that first name)", quality ? quality.firstNameDuplicates : "not counted (dry run)"],
|
|
195
|
+
["Rows those one-word people hold", quality ? quality.firstNameDuplicateRows : "not counted"],
|
|
196
|
+
["Of those, beside a roster person (left for a person: a key that contradicts, or two roster people share the name)", quality ? quality.firstNameDuplicatesOfRoster : "not counted"],
|
|
197
|
+
["Bots typed as people (must be 0)", quality ? quality.botsAsPeople : "not counted"],
|
|
198
|
+
["CRM-only companies remaining (must be 0)", quality ? quality.crmOnlyCompanies : "not counted"],
|
|
199
|
+
["Companies named by a record id (must be 0)", quality ? quality.companiesNamedByRecordId : "not counted"],
|
|
200
|
+
["Legacy state edges imported closed", total(report.edgesImportedClosed)],
|
|
201
|
+
["Legacy state edges imported open (a signal from the last 120 days names both ends)", total(report.edgesConfirmedRecent)],
|
|
202
|
+
["Open leads, owns and works_at rows of origin legacy", quality ? quality.openLegacyStateEdges : "not counted"],
|
|
203
|
+
["Old reporting lines dropped", report.reportingLinesDropped],
|
|
204
|
+
["Open reports_to or manages rows of origin legacy (must be 0)", quality ? quality.legacyReportingLines : "not counted"],
|
|
205
|
+
["Roster people marked internal", quality ? quality.rosterInternal : "not counted"],
|
|
206
|
+
["People marked internal who are not on the roster (must be 0)", quality ? quality.internalNotOnRoster : "not counted"],
|
|
207
|
+
["Names folded into a roster person by rule", total(report.rosterMerges)],
|
|
208
|
+
["Old person files imported as a tool (bot, agent, service)", report.machinesAsTools],
|
|
209
|
+
["Old person files dropped: a group or a seat", report.groupNamesDropped],
|
|
210
|
+
["Old person files dropped: a company's name", report.companyNamesAsPeople],
|
|
211
|
+
["Old company files held back: a CRM row and nothing else", report.companiesHeld],
|
|
212
|
+
["CRM accounts attached to a company another source names", report.seed?.counts.crmAccountsAttached ?? 0],
|
|
213
|
+
["CRM accounts held back", report.seed?.counts.crmAccountsHeld ?? 0],
|
|
214
|
+
["Companies marked vendor", report.vendorsMarked],
|
|
215
|
+
["Rows citing the old entity file because the signal has no file (request F7)", report.signalCitationsMissing],
|
|
216
|
+
]));
|
|
217
|
+
if (quality && quality.botsAsPeopleList.length > 0)
|
|
218
|
+
push(`Still typed as people: ${quality.botsAsPeopleList.join(", ")}.`, "");
|
|
219
|
+
if (Object.keys(report.edgesImportedClosed).length > 0)
|
|
220
|
+
push("Imported closed, by verb: " + counts(report.edgesImportedClosed).map(([verb, count]) => `${verb} ${count}`).join(", ") + ".", "");
|
|
221
|
+
if (Object.keys(report.edgesConfirmedRecent).length > 0)
|
|
222
|
+
push("Imported open, by verb: " + counts(report.edgesConfirmedRecent).map(([verb, count]) => `${verb} ${count}`).join(", ") + ".", "");
|
|
223
|
+
if (Object.keys(report.typeChanges).length > 0)
|
|
224
|
+
push("Old files imported under another type: " + counts(report.typeChanges).map(([reason, count]) => `${reason} ${count}`).join(", ") + ".", "");
|
|
225
|
+
if (report.products.length > 0)
|
|
226
|
+
push("Products: " + report.products.join("; ") + ".", "");
|
|
227
|
+
if (report.rosterMergeList.length > 0) {
|
|
228
|
+
push("### Names folded into a roster person", "");
|
|
229
|
+
push("By reason: " + counts(report.rosterMerges).map(([reason, count]) => `${reason} ${count}`).join(", ") + ".", "");
|
|
230
|
+
for (const line of report.rosterMergeList)
|
|
231
|
+
push(`- ${line}`);
|
|
232
|
+
push("");
|
|
233
|
+
}
|
|
234
|
+
if (report.machineExamples.length > 0) {
|
|
235
|
+
push("### Old person files imported as a tool", "");
|
|
236
|
+
for (const line of report.machineExamples)
|
|
237
|
+
push(`- ${line}`);
|
|
238
|
+
push("");
|
|
239
|
+
}
|
|
240
|
+
push("## Proposals", "");
|
|
241
|
+
push(`${report.proposals} merge proposals. Filed with the proposals package: ${report.proposalsFiled}. Waiting in \`.state/legacy-import-proposals.jsonl\`: ${report.proposalsPending}. ` +
|
|
242
|
+
`Contradictions reported by the store: ${report.contradictions}, filed as proposals: ${report.contradictionProposalsFiled}. Rows closed: ${report.rowsClosed}. Mentions parked in unresolved: ${report.unresolvedParked}.`, "");
|
|
243
|
+
push(table(["Type, reason", "Proposals"], counts(report.proposalsByKind)));
|
|
244
|
+
push(`Alias and fuzzy name hints between concepts or tools, counted and not filed: ${report.aliasHintsNotFiled}. ` +
|
|
245
|
+
`Old people whose alias list held an email or Slack id of a person with no name in common (key not used, proposal filed): ${report.keysOfAnotherName}.`, "");
|
|
246
|
+
if (meta.notDone && meta.notDone.length > 0) {
|
|
247
|
+
push("## Not done", "");
|
|
248
|
+
for (const line of meta.notDone)
|
|
249
|
+
push(`- ${line}`);
|
|
250
|
+
push("");
|
|
251
|
+
}
|
|
252
|
+
return out.join("\n");
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-C: the legacy verb map (design 2.4). Turns one old free-text
|
|
3
|
+
* relationship label, with the types at its two ends, into what the import
|
|
4
|
+
* writes: a typed edge from the closed vocabulary, a fact, a `related_to`
|
|
5
|
+
* edge that keeps the old label, or nothing.
|
|
6
|
+
*
|
|
7
|
+
* The table itself lives in schema.yaml (`verb_map`, `verb_map_default`), so a
|
|
8
|
+
* company can change it without a code change. This file only applies it.
|
|
9
|
+
*/
|
|
10
|
+
import type { GraphEntityType, GraphSchema, Verb, VerbMapEntry } from "../types.js";
|
|
11
|
+
export type LegacyEdgePlan = {
|
|
12
|
+
action: "skip";
|
|
13
|
+
} | {
|
|
14
|
+
action: "timeline";
|
|
15
|
+
} | {
|
|
16
|
+
action: "fact";
|
|
17
|
+
field: string;
|
|
18
|
+
value: string;
|
|
19
|
+
on: "subject" | "object";
|
|
20
|
+
conf: number;
|
|
21
|
+
} | {
|
|
22
|
+
action: "edge";
|
|
23
|
+
verb: Verb;
|
|
24
|
+
/** True when the edge is written from the old object to the old subject. */
|
|
25
|
+
flipped: boolean;
|
|
26
|
+
conf: number;
|
|
27
|
+
/** Old label, kept on a `related_to` edge that came from another label. */
|
|
28
|
+
was?: string;
|
|
29
|
+
/** How the plan was reached. */
|
|
30
|
+
via: "mapped" | "vocabulary" | "flipped" | "coerced" | "downgraded" | "related" | "default";
|
|
31
|
+
};
|
|
32
|
+
/** The `verb_map` entry for a label, matched case-insensitively after trimming. */
|
|
33
|
+
export declare function verbMapEntry(schema: GraphSchema, label: string): VerbMapEntry | undefined;
|
|
34
|
+
export declare function planLegacyEdge(schema: GraphSchema, label: string, subject: GraphEntityType, object: GraphEntityType): LegacyEdgePlan;
|
|
35
|
+
//# sourceMappingURL=verb-map.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const key = (label) => label.trim().toLowerCase().replace(/\s+/g, " ");
|
|
2
|
+
function allowed(schema, verb, subject, object) {
|
|
3
|
+
const spec = schema.link_types[verb];
|
|
4
|
+
if (!spec)
|
|
5
|
+
return false;
|
|
6
|
+
return (spec.subjects.includes("*") || spec.subjects.includes(subject)) && (spec.objects.includes("*") || spec.objects.includes(object));
|
|
7
|
+
}
|
|
8
|
+
/** The `verb_map` entry for a label, matched case-insensitively after trimming. */
|
|
9
|
+
export function verbMapEntry(schema, label) {
|
|
10
|
+
const wanted = key(label);
|
|
11
|
+
return schema.verb_map.find((entry) => key(entry.label) === wanted);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Ownership by a company is not `owned_by` in the closed vocabulary (that verb
|
|
15
|
+
* points at a person or a team). The vocabulary's way to say a project or
|
|
16
|
+
* product belongs to a company is `part_of`.
|
|
17
|
+
*/
|
|
18
|
+
function coerce(schema, verb, subject, object) {
|
|
19
|
+
if (verb === "owned_by" && object === "company" && allowed(schema, "part_of", subject, object))
|
|
20
|
+
return { verb: "part_of", flipped: false };
|
|
21
|
+
if (verb === "owns" && subject === "company" && allowed(schema, "part_of", object, subject))
|
|
22
|
+
return { verb: "part_of", flipped: true };
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
export function planLegacyEdge(schema, label, subject, object) {
|
|
26
|
+
const fallback = schema.verb_map_default;
|
|
27
|
+
const related = (via) => ({
|
|
28
|
+
action: "edge",
|
|
29
|
+
verb: fallback.verb,
|
|
30
|
+
flipped: false,
|
|
31
|
+
conf: fallback.conf,
|
|
32
|
+
was: label.trim(),
|
|
33
|
+
via,
|
|
34
|
+
});
|
|
35
|
+
let entry = verbMapEntry(schema, label);
|
|
36
|
+
let via = "mapped";
|
|
37
|
+
if (!entry) {
|
|
38
|
+
// A label that is itself a verb of the closed vocabulary (`Used by`, `Led by`, `Manages`).
|
|
39
|
+
const asVerb = key(label).replace(/ /g, "_");
|
|
40
|
+
if (asVerb in schema.link_types && asVerb !== fallback.verb) {
|
|
41
|
+
entry = { label, action: "verb", verb: asVerb, flip_if_reversed: true, conf: 0.5 };
|
|
42
|
+
via = "vocabulary";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!entry)
|
|
46
|
+
return related("default");
|
|
47
|
+
switch (entry.action) {
|
|
48
|
+
case "skip":
|
|
49
|
+
return { action: "skip" };
|
|
50
|
+
case "timeline":
|
|
51
|
+
return { action: "timeline" };
|
|
52
|
+
case "fact": {
|
|
53
|
+
const field = entry.field ?? "";
|
|
54
|
+
const on = schema.entity_types[subject]?.facts[field] && subject === "person" ? "subject" : schema.entity_types[object]?.facts[field] && object === "person" ? "object" : null;
|
|
55
|
+
if (!on || field === "")
|
|
56
|
+
return related("downgraded");
|
|
57
|
+
return { action: "fact", field, value: entry.label, on, conf: entry.conf ?? 0.5 };
|
|
58
|
+
}
|
|
59
|
+
case "related":
|
|
60
|
+
return {
|
|
61
|
+
action: "edge",
|
|
62
|
+
verb: entry.verb ?? fallback.verb,
|
|
63
|
+
flipped: false,
|
|
64
|
+
conf: entry.conf ?? fallback.conf,
|
|
65
|
+
...(key(label) === "related to" ? {} : { was: label.trim() }),
|
|
66
|
+
via: "related",
|
|
67
|
+
};
|
|
68
|
+
case "verb": {
|
|
69
|
+
const verb = entry.verb;
|
|
70
|
+
if (!verb || !schema.link_types[verb])
|
|
71
|
+
return related("downgraded");
|
|
72
|
+
const conf = entry.conf ?? 0.5;
|
|
73
|
+
if (allowed(schema, verb, subject, object))
|
|
74
|
+
return { action: "edge", verb, flipped: false, conf, via };
|
|
75
|
+
const coerced = coerce(schema, verb, subject, object);
|
|
76
|
+
if (coerced)
|
|
77
|
+
return { action: "edge", verb: coerced.verb, flipped: coerced.flipped, conf, via: "coerced" };
|
|
78
|
+
if (entry.flip_if_reversed && allowed(schema, verb, object, subject))
|
|
79
|
+
return { action: "edge", verb, flipped: true, conf, via: "flipped" };
|
|
80
|
+
return related("downgraded");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=verb-map.js.map
|