@indigoai-us/hq-cli 5.345.247 → 5.345.250
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 +95 -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 +1198 -0
- package/dist/command-catalog.generated.js +1476 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/core-job-run-native.js +4 -0
- package/dist/commands/core-knowledge-prefs.d.ts +1 -1
- package/dist/commands/core-knowledge-prefs.js +1 -16
- package/dist/commands/core.js +0 -2
- package/dist/commands/daemon.js +21 -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 +63 -0
- package/dist/commands/ontology-graph.js +470 -0
- package/dist/commands/sync-core.js +6 -0
- package/dist/fast-scaffold.js +1 -3
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +281 -256
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +48 -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/installed-cli-restart.d.ts +57 -0
- package/dist/lib/daemon/installed-cli-restart.js +114 -0
- 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/legacy-journal-gate.d.ts +32 -0
- package/dist/lib/daemon/legacy-journal-gate.js +102 -0
- package/dist/lib/daemon/machine-checks.d.ts +7 -0
- package/dist/lib/daemon/machine-checks.js +10 -0
- 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.d.ts +3 -1
- package/dist/lib/daemon/run.js +49 -6
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.js +1 -1
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.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/hook-engine/coverage.d.ts +82 -13
- package/dist/lib/hook-engine/coverage.js +214 -18
- package/dist/lib/hook-engine/registration-identity.d.ts +5 -0
- package/dist/lib/hook-engine/registration-identity.js +1 -1
- package/dist/lib/hook-engine/resolve.d.ts +23 -0
- package/dist/lib/hook-engine/resolve.js +48 -1
- package/dist/lib/hook-engine/stable-heal.d.ts +87 -0
- package/dist/lib/hook-engine/stable-heal.js +214 -0
- package/dist/lib/hot-channels/graph-context.d.ts +105 -0
- package/dist/lib/hot-channels/graph-context.js +380 -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 +197 -0
- package/dist/lib/ontology-graph/model/step.js +526 -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 +67 -0
- package/dist/lib/ontology-graph/org/derive.js +359 -0
- package/dist/lib/ontology-graph/org/index.d.ts +102 -0
- package/dist/lib/ontology-graph/org/index.js +630 -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 +97 -0
- package/dist/lib/ontology-graph/org/text.js +321 -0
- package/dist/lib/ontology-graph/org/types.d.ts +457 -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 +144 -0
- package/dist/lib/ontology-graph/pages/render.js +688 -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 +254 -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 +803 -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 +49 -0
- package/dist/lib/ontology-graph/read/names.js +297 -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 +146 -0
- package/dist/lib/ontology-graph/replay/engine.js +1240 -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 +91 -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 +107 -0
- package/dist/lib/ontology-graph/schema/authority.js +186 -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 +1190 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- package/dist/lib/sync-core/engine-holds.d.ts +1 -1
- package/dist/lib/sync-core/engine-holds.js +12 -2
- package/dist/lib/sync-core/hand-back.d.ts +2 -1
- package/dist/lib/sync-core/hand-back.js +16 -2
- package/dist/lib/sync-core/legacy-journal-export-child.d.ts +2 -0
- package/dist/lib/sync-core/legacy-journal-export-child.js +24 -0
- package/dist/lib/sync-core/legacy-journal-export.d.ts +39 -0
- package/dist/lib/sync-core/legacy-journal-export.js +241 -0
- package/dist/lib/sync-core/legacy-journal-reader.d.ts +15 -0
- package/dist/lib/sync-core/legacy-journal-reader.js +56 -0
- package/dist/lib/sync-core/reconcile.d.ts +3 -0
- package/dist/lib/sync-core/reconcile.js +43 -3
- package/dist/utils/cli-telemetry.d.ts +1 -0
- package/dist/utils/cli-telemetry.js +6 -3
- package/dist/utils/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/hook-engine-rollup.d.ts +96 -0
- package/dist/utils/hook-engine-rollup.js +725 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +9 -9
- package/scripts/install-hook-engine.mjs +4 -0
- package/assets/scaffold/core/scripts/knowledge-prefs.sh +0 -55
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type RosterFile } from "../resolve/roster.js";
|
|
2
|
+
import type { AudienceKey, EntityRef, GraphContext, GraphEntity, GraphStore, IsoDate } from "../types.js";
|
|
3
|
+
import type { OrgGraph, OrgView, SourceClass } from "./types.js";
|
|
4
|
+
export interface LoadOptions {
|
|
5
|
+
view: OrgView;
|
|
6
|
+
asOf: IsoDate;
|
|
7
|
+
foldVariants?: boolean;
|
|
8
|
+
/** Injected in tests; default opens `context.graphRoot`. */
|
|
9
|
+
store?: GraphStore;
|
|
10
|
+
roster?: RosterFile | null;
|
|
11
|
+
}
|
|
12
|
+
/** The audiences a view may read, limited to the folders the graph holds. */
|
|
13
|
+
export declare function audiencesOf(view: OrgView, context: Pick<GraphContext, "member">, held: readonly AudienceKey[]): AudienceKey[];
|
|
14
|
+
/** The source class of a row, from its citation and type. `personal` are the audiences that hold the member's own sessions or DMs. */
|
|
15
|
+
export declare function classifySource(src: string, type: string, audience: AudienceKey, personal: ReadonlySet<AudienceKey>, onMeeting: boolean): SourceClass;
|
|
16
|
+
interface FoldDecision {
|
|
17
|
+
from: EntityRef;
|
|
18
|
+
into: EntityRef;
|
|
19
|
+
reason: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Name variants of a roster member that the graph still holds as separate
|
|
23
|
+
* people. Folded for this computation only, each with its reason, when exactly
|
|
24
|
+
* one roster member fits: the variant's name contains every word of the
|
|
25
|
+
* member's name, or is the first name plus the initial of the last name, or
|
|
26
|
+
* the two share an email or a Slack id. A bare first name is never folded here.
|
|
27
|
+
*/
|
|
28
|
+
export declare function planFolds(entities: readonly GraphEntity[], roster: RosterFile | null): FoldDecision[];
|
|
29
|
+
export declare function loadOrgGraph(context: GraphContext, options: LoadOptions): OrgGraph;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observed org chart: reading the graph.
|
|
3
|
+
*
|
|
4
|
+
* Read-only. One pass over the facts files of people, projects, products,
|
|
5
|
+
* companies, meetings and decisions in the audiences of the view, turned into:
|
|
6
|
+
* timeline events (each row once, with every entity it is filed on), meetings
|
|
7
|
+
* with attendees, decisions with deciders, weekly commit counts, and the
|
|
8
|
+
* stated claims (titles, listed owners, managers) kept apart from behavior.
|
|
9
|
+
*
|
|
10
|
+
* Audience rule: a view reads only its own audiences. The company view reads
|
|
11
|
+
* `company` and nothing else, so nothing a member alone can read reaches a
|
|
12
|
+
* company-wide observation.
|
|
13
|
+
*/
|
|
14
|
+
import { readOrgChartDraft } from "../proposals/org-chart.js";
|
|
15
|
+
import { readConfirmedOrgChart } from "../resolve/org-chart.js";
|
|
16
|
+
import { readRosterFile } from "../resolve/roster.js";
|
|
17
|
+
import { openGraphStore } from "../store/index.js";
|
|
18
|
+
import { parseEntityRef } from "../schema/index.js";
|
|
19
|
+
import { normalizeName, similarity } from "./text.js";
|
|
20
|
+
const READ_TYPES = new Set(["person", "project", "product", "company", "meeting", "decision"]);
|
|
21
|
+
/** Timeline rows that say a thing was named in a document. Not something anyone did. */
|
|
22
|
+
const MENTION_TYPES = new Set(["doc", "policy"]);
|
|
23
|
+
/** Row types two signals often write twice for one moment. */
|
|
24
|
+
const DEDUPE_TYPES = new Set(["decision", "action_item", "commitment", "participant_contribution", "summary", "key_point", "question", "risk"]);
|
|
25
|
+
const DUPLICATE_SIMILARITY = 0.6;
|
|
26
|
+
/** The audiences a view may read, limited to the folders the graph holds. */
|
|
27
|
+
export function audiencesOf(view, context, held) {
|
|
28
|
+
if (view === "company")
|
|
29
|
+
return held.includes("company") ? ["company"] : [];
|
|
30
|
+
const allowed = new Set(["company", "local", ...(context.member?.audienceKeys ?? [])]);
|
|
31
|
+
return held.filter((key) => allowed.has(key));
|
|
32
|
+
}
|
|
33
|
+
/** The source class of a row, from its citation and type. `personal` are the audiences that hold the member's own sessions or DMs. */
|
|
34
|
+
export function classifySource(src, type, audience, personal, onMeeting) {
|
|
35
|
+
if (src.startsWith("record:git:"))
|
|
36
|
+
return "code";
|
|
37
|
+
if (src.startsWith("record:board:") || src === "doc:board.json")
|
|
38
|
+
return "board";
|
|
39
|
+
if (src.startsWith("session:") || src.startsWith("doc:workspace/sessions") || src.startsWith("record:mesh:") || type === "session" || type === "mesh")
|
|
40
|
+
return "member-session";
|
|
41
|
+
if (type === "slack-dm" || src.startsWith("source:sources/slack-dm/"))
|
|
42
|
+
return "member-dm";
|
|
43
|
+
if (src.startsWith("doc:action-items/") || src.startsWith("doc:commitments/"))
|
|
44
|
+
return "member-tracker";
|
|
45
|
+
if (src.startsWith("doc:meetings/notes/") || src.startsWith("doc:people/"))
|
|
46
|
+
return "member-note";
|
|
47
|
+
if (src.startsWith("source:sources/meetings/"))
|
|
48
|
+
return "meeting";
|
|
49
|
+
if (src.startsWith("source:sources/slack/"))
|
|
50
|
+
return "thread";
|
|
51
|
+
if (src.startsWith("signal:")) {
|
|
52
|
+
if (onMeeting)
|
|
53
|
+
return "meeting";
|
|
54
|
+
return personal.has(audience) ? "member-dm" : "signal";
|
|
55
|
+
}
|
|
56
|
+
if (src.startsWith("legacy:"))
|
|
57
|
+
return "legacy";
|
|
58
|
+
if (src.startsWith("record:"))
|
|
59
|
+
return "record";
|
|
60
|
+
if (src.startsWith("source:"))
|
|
61
|
+
return "signal";
|
|
62
|
+
return "document";
|
|
63
|
+
}
|
|
64
|
+
/** True when a row marks its audience as the member's own scope (it holds a session or a DM). */
|
|
65
|
+
function marksPersonal(src, type) {
|
|
66
|
+
return src.startsWith("session:") || src.startsWith("record:mesh:") || type === "slack-dm" || src.startsWith("source:sources/slack-dm/");
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Name variants of a roster member that the graph still holds as separate
|
|
70
|
+
* people. Folded for this computation only, each with its reason, when exactly
|
|
71
|
+
* one roster member fits: the variant's name contains every word of the
|
|
72
|
+
* member's name, or is the first name plus the initial of the last name, or
|
|
73
|
+
* the two share an email or a Slack id. A bare first name is never folded here.
|
|
74
|
+
*/
|
|
75
|
+
export function planFolds(entities, roster) {
|
|
76
|
+
if (!roster)
|
|
77
|
+
return [];
|
|
78
|
+
const rosterRefs = new Set(roster.members.map((member) => member.ref));
|
|
79
|
+
const members = roster.members.map((member) => ({
|
|
80
|
+
ref: member.ref,
|
|
81
|
+
tokens: normalizeName(member.name).split(" ").filter(Boolean),
|
|
82
|
+
emails: new Set(member.emails.map((email) => email.toLowerCase())),
|
|
83
|
+
slack: new Set(member.slackIds),
|
|
84
|
+
}));
|
|
85
|
+
const folds = [];
|
|
86
|
+
for (const entity of entities) {
|
|
87
|
+
if (rosterRefs.has(entity.id))
|
|
88
|
+
continue;
|
|
89
|
+
const tokens = normalizeName(entity.canonical_name).split(" ").filter(Boolean);
|
|
90
|
+
const matches = [];
|
|
91
|
+
for (const member of members) {
|
|
92
|
+
if (member.tokens.length < 2)
|
|
93
|
+
continue;
|
|
94
|
+
const keyShared = entity.keys.email.some((email) => member.emails.has(email.toLowerCase())) || entity.keys.slack_id.some((id) => member.slack.has(id));
|
|
95
|
+
if (keyShared) {
|
|
96
|
+
matches.push({ ref: member.ref, reason: "shares an email or Slack id with the roster member" });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (tokens.length > member.tokens.length && member.tokens.every((token) => tokens.includes(token))) {
|
|
100
|
+
matches.push({ ref: member.ref, reason: "name contains every word of the roster member's name" });
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const first = member.tokens[0];
|
|
104
|
+
const last = member.tokens[member.tokens.length - 1];
|
|
105
|
+
if (tokens.length === 2 && tokens[0] === first && tokens[1].length === 1 && last.startsWith(tokens[1])) {
|
|
106
|
+
matches.push({ ref: member.ref, reason: "first name plus the initial of the roster member's last name" });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (matches.length === 1)
|
|
110
|
+
folds.push({ from: entity.id, into: matches[0].ref, reason: matches[0].reason });
|
|
111
|
+
}
|
|
112
|
+
return folds;
|
|
113
|
+
}
|
|
114
|
+
const typeOf = (ref) => ref.slice(0, ref.indexOf("/"));
|
|
115
|
+
const deslug = (ref) => ref.slice(ref.indexOf("/") + 1).replace(/-/g, " ");
|
|
116
|
+
export function loadOrgGraph(context, options) {
|
|
117
|
+
const store = options.store ?? openGraphStore(context.graphRoot, { company: context.company });
|
|
118
|
+
const roster = options.roster !== undefined ? options.roster : readRosterFile(context.graphRoot);
|
|
119
|
+
const audiences = audiencesOf(options.view, context, store.listAudiences());
|
|
120
|
+
const asOf = options.asOf;
|
|
121
|
+
// People and identity.
|
|
122
|
+
const machine = new Set(roster?.machineNames ?? []);
|
|
123
|
+
const rosterRefs = new Set((roster?.members ?? []).map((member) => member.ref));
|
|
124
|
+
const memberRef = context.member ? ((roster?.members ?? []).find((member) => member.personUids.includes(context.member?.personUid ?? ""))?.ref ?? null) : null;
|
|
125
|
+
const entities = [];
|
|
126
|
+
for (const ref of store.listEntities("person")) {
|
|
127
|
+
const entity = store.readEntity(ref);
|
|
128
|
+
if (entity && !machine.has(normalizeName(entity.canonical_name)))
|
|
129
|
+
entities.push(entity);
|
|
130
|
+
}
|
|
131
|
+
// A name variant belongs to a view only when the view's own audiences hold rows about it.
|
|
132
|
+
// A variant known only from rows this view may not read is left out whole: no fold is
|
|
133
|
+
// recorded for it, and its name reaches neither the stored file nor the output.
|
|
134
|
+
const planned = options.foldVariants === false ? [] : planFolds(entities, roster);
|
|
135
|
+
const inView = new Set(store.listEntitiesWithRows(audiences));
|
|
136
|
+
const folds = planned.filter((fold) => inView.has(fold.from));
|
|
137
|
+
const outOfView = new Set(planned.filter((fold) => !inView.has(fold.from)).map((fold) => fold.from));
|
|
138
|
+
const foldedInto = new Map(folds.map((fold) => [fold.from, fold.into]));
|
|
139
|
+
const people = new Map();
|
|
140
|
+
for (const entity of entities) {
|
|
141
|
+
if (foldedInto.has(entity.id) || outOfView.has(entity.id))
|
|
142
|
+
continue;
|
|
143
|
+
people.set(entity.id, { ref: entity.id, name: entity.canonical_name, aliases: [...entity.aliases], onRoster: rosterRefs.has(entity.id), isMember: entity.id === memberRef, folded: [], employers: [], external: false });
|
|
144
|
+
}
|
|
145
|
+
for (const member of roster?.members ?? []) {
|
|
146
|
+
if (!people.has(member.ref))
|
|
147
|
+
people.set(member.ref, { ref: member.ref, name: member.name, aliases: [], onRoster: true, isMember: member.ref === memberRef, folded: [], employers: [], external: false });
|
|
148
|
+
}
|
|
149
|
+
for (const fold of folds) {
|
|
150
|
+
const target = people.get(fold.into);
|
|
151
|
+
const source = entities.find((entity) => entity.id === fold.from);
|
|
152
|
+
if (!target || !source)
|
|
153
|
+
continue;
|
|
154
|
+
target.folded.push({ ref: fold.from, reason: fold.reason });
|
|
155
|
+
target.aliases.push(source.canonical_name, ...source.aliases);
|
|
156
|
+
}
|
|
157
|
+
const canon = (ref) => foldedInto.get(ref) ?? ref;
|
|
158
|
+
const isPerson = (ref) => people.has(canon(ref));
|
|
159
|
+
const projects = new Map();
|
|
160
|
+
const companies = new Map();
|
|
161
|
+
const meetings = new Map();
|
|
162
|
+
const decisions = new Map();
|
|
163
|
+
const stated = new Map();
|
|
164
|
+
const events = new Map();
|
|
165
|
+
const weekly = [];
|
|
166
|
+
const rollups = [];
|
|
167
|
+
const personal = new Set();
|
|
168
|
+
const ownWords = new Set(roster?.ownWords ?? []);
|
|
169
|
+
let rowsRead = 0;
|
|
170
|
+
const claim = (person, value) => {
|
|
171
|
+
stated.set(person, [...(stated.get(person) ?? []), value]);
|
|
172
|
+
};
|
|
173
|
+
const nameOf = (ref) => store.readEntity(ref)?.canonical_name ?? deslug(ref);
|
|
174
|
+
const meetingNode = (ref, audience, src, date) => {
|
|
175
|
+
let node = meetings.get(ref);
|
|
176
|
+
if (!node) {
|
|
177
|
+
node = { ref, date, title: deslug(ref), audience, src, attendees: [], about: [] };
|
|
178
|
+
meetings.set(ref, node);
|
|
179
|
+
}
|
|
180
|
+
return node;
|
|
181
|
+
};
|
|
182
|
+
const decisionNode = (ref, audience, src, date) => {
|
|
183
|
+
let node = decisions.get(ref);
|
|
184
|
+
if (!node) {
|
|
185
|
+
node = { ref, date, statement: "", audience, src, cls: "signal", deciders: [], about: [] };
|
|
186
|
+
decisions.set(ref, node);
|
|
187
|
+
}
|
|
188
|
+
return node;
|
|
189
|
+
};
|
|
190
|
+
const push = (list, value) => {
|
|
191
|
+
if (!list.includes(value))
|
|
192
|
+
list.push(value);
|
|
193
|
+
};
|
|
194
|
+
const filed = (stored, ref) => {
|
|
195
|
+
const row = stored.row;
|
|
196
|
+
if (row.kind !== "T" || row.date > asOf || MENTION_TYPES.has(row.signalType))
|
|
197
|
+
return;
|
|
198
|
+
if (marksPersonal(row.src, row.signalType))
|
|
199
|
+
personal.add(stored.audience);
|
|
200
|
+
const key = `${stored.audience}|${row.src}|${row.signalType}|${row.text}`;
|
|
201
|
+
let event = events.get(key);
|
|
202
|
+
if (!event) {
|
|
203
|
+
event = { key, date: row.date, type: row.signalType, text: row.text, src: row.src, audience: stored.audience, cls: "signal", people: [], projects: [], companies: [], meetings: [], decisions: [] };
|
|
204
|
+
events.set(key, event);
|
|
205
|
+
}
|
|
206
|
+
const type = typeOf(ref);
|
|
207
|
+
if (type === "person")
|
|
208
|
+
push(event.people, canon(ref));
|
|
209
|
+
else if (type === "project" || type === "product")
|
|
210
|
+
push(event.projects, ref);
|
|
211
|
+
else if (type === "company")
|
|
212
|
+
push(event.companies, ref);
|
|
213
|
+
else if (type === "meeting")
|
|
214
|
+
push(event.meetings, ref);
|
|
215
|
+
else if (type === "decision")
|
|
216
|
+
push(event.decisions, ref);
|
|
217
|
+
};
|
|
218
|
+
for (const ref of store.listEntitiesWithRows(audiences)) {
|
|
219
|
+
const type = typeOf(ref);
|
|
220
|
+
if (!READ_TYPES.has(type))
|
|
221
|
+
continue;
|
|
222
|
+
if (type === "person" && !isPerson(ref))
|
|
223
|
+
continue;
|
|
224
|
+
const rows = store.readRows(ref, { audiences });
|
|
225
|
+
rowsRead += rows.length;
|
|
226
|
+
if (rows.length > 0 && (type === "project" || type === "product") && !projects.has(ref))
|
|
227
|
+
projects.set(ref, { ref, name: nameOf(ref), listedOwners: [] });
|
|
228
|
+
if (rows.length > 0 && type === "company" && !companies.has(ref)) {
|
|
229
|
+
const name = nameOf(ref);
|
|
230
|
+
companies.set(ref, { ref, name, isSelf: ownWords.has(normalizeName(name)) || context.company === ref.slice(ref.indexOf("/") + 1), isCustomer: false, listedOwners: [] });
|
|
231
|
+
}
|
|
232
|
+
for (const stored of rows) {
|
|
233
|
+
const row = stored.row;
|
|
234
|
+
if (row.kind === "T") {
|
|
235
|
+
if (type === "person" && (row.signalType === "commit" || row.signalType === "commits")) {
|
|
236
|
+
if (row.date > asOf)
|
|
237
|
+
continue;
|
|
238
|
+
const match = /^(\d+) commits? to (\S+?),/.exec(row.text);
|
|
239
|
+
if (match) {
|
|
240
|
+
const span = row.signalType === "commits" ? /, (\d{4}-\d{2}-\d{2}) to \d{4}-\d{2}-\d{2}/.exec(row.text) : null;
|
|
241
|
+
const rollup = { person: canon(ref), repo: match[2], count: Number(match[1]), date: row.date, text: row.text, src: row.src, audience: stored.audience, ...(span ? { spanFrom: span[1] } : {}) };
|
|
242
|
+
(row.signalType === "commit" ? weekly : rollups).push(rollup);
|
|
243
|
+
}
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if ((type === "project" || type === "product") && (row.signalType === "commit" || row.signalType === "commits"))
|
|
247
|
+
continue;
|
|
248
|
+
filed(stored, ref);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (row.valid.from > asOf)
|
|
252
|
+
continue;
|
|
253
|
+
const open = row.valid.to === undefined || row.valid.to > asOf;
|
|
254
|
+
const base = { src: row.src, by: row.by, conf: row.conf, open, from: row.valid.from, ...(row.valid.to ? { to: row.valid.to } : {}), audience: stored.audience, via: "row" };
|
|
255
|
+
if (type === "person") {
|
|
256
|
+
const person = canon(ref);
|
|
257
|
+
if (row.kind === "F" && row.field === "role_title")
|
|
258
|
+
claim(person, { field: "title", value: row.value, ...base });
|
|
259
|
+
else if (row.kind === "E" && row.verb === "holds_role")
|
|
260
|
+
claim(person, { field: "role", value: nameOf(row.target), target: row.target, ...base });
|
|
261
|
+
else if (row.kind === "E" && row.verb === "member_of")
|
|
262
|
+
claim(person, { field: "team", value: nameOf(row.target), target: row.target, ...base });
|
|
263
|
+
else if (row.kind === "E" && row.verb === "reports_to")
|
|
264
|
+
claim(person, { field: "manager", value: nameOf(row.target), target: canon(row.target), ...base });
|
|
265
|
+
else if (row.kind === "E" && row.verb === "attended")
|
|
266
|
+
push(meetingNode(row.target, stored.audience, row.src, row.valid.from).attendees, person);
|
|
267
|
+
else if (row.kind === "E" && row.verb === "decided")
|
|
268
|
+
push(decisionNode(row.target, stored.audience, row.src, row.valid.from).deciders, person);
|
|
269
|
+
else if (row.kind === "E" && row.verb === "works_at" && open)
|
|
270
|
+
push(people.get(person).employers, row.target);
|
|
271
|
+
else if (row.kind === "F" && row.field === "status" && open && /^external$/i.test(row.value))
|
|
272
|
+
people.get(person).external = true;
|
|
273
|
+
}
|
|
274
|
+
else if (type === "project" || type === "product") {
|
|
275
|
+
const node = projects.get(ref);
|
|
276
|
+
if (row.kind === "F" && row.field === "repo" && open)
|
|
277
|
+
node.repo = row.value;
|
|
278
|
+
else if (row.kind === "F" && row.field === "status" && open)
|
|
279
|
+
node.status = row.value;
|
|
280
|
+
else if (row.kind === "E" && (row.verb === "owned_by" || row.verb === "led_by") && typeOf(row.target) === "person") {
|
|
281
|
+
node.listedOwners.push({ field: row.verb === "owned_by" ? "owner" : "lead", value: nameOf(row.target), target: canon(row.target), ...base });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else if (type === "company") {
|
|
285
|
+
const node = companies.get(ref);
|
|
286
|
+
if (row.kind === "F" && row.field === "relation" && open) {
|
|
287
|
+
node.relation = row.value;
|
|
288
|
+
if (row.value === "self")
|
|
289
|
+
node.isSelf = true;
|
|
290
|
+
if (/^(customer|prospect|client)$/i.test(row.value))
|
|
291
|
+
node.isCustomer = true;
|
|
292
|
+
}
|
|
293
|
+
else if (row.kind === "F" && row.field === "stage" && open) {
|
|
294
|
+
node.stage = row.value;
|
|
295
|
+
node.isCustomer = true;
|
|
296
|
+
}
|
|
297
|
+
else if (row.kind === "F" && row.field === "owner") {
|
|
298
|
+
const parsed = parseEntityRef(row.value);
|
|
299
|
+
const target = parsed ? canon(row.value) : undefined;
|
|
300
|
+
node.listedOwners.push({ field: "owner", value: target ? nameOf(target) : row.value, ...(target ? { target } : {}), ...base });
|
|
301
|
+
}
|
|
302
|
+
else if (row.kind === "E" && (row.verb === "customer_of" || row.verb === "has_customer") && open)
|
|
303
|
+
node.isCustomer = true;
|
|
304
|
+
}
|
|
305
|
+
else if (type === "meeting") {
|
|
306
|
+
const node = meetingNode(ref, stored.audience, row.src, row.valid.from);
|
|
307
|
+
if (row.kind === "F" && row.field === "date")
|
|
308
|
+
node.date = row.value;
|
|
309
|
+
else if (row.kind === "F" && row.field === "title")
|
|
310
|
+
node.title = row.value;
|
|
311
|
+
else if (row.kind === "E" && row.verb === "had_attendee" && isPerson(row.target))
|
|
312
|
+
push(node.attendees, canon(row.target));
|
|
313
|
+
else if (row.kind === "E" && row.verb === "about")
|
|
314
|
+
push(node.about, row.target);
|
|
315
|
+
}
|
|
316
|
+
else if (type === "decision") {
|
|
317
|
+
const node = decisionNode(ref, stored.audience, row.src, row.valid.from);
|
|
318
|
+
if (row.kind === "F" && row.field === "statement")
|
|
319
|
+
node.statement = row.value;
|
|
320
|
+
else if (row.kind === "F" && row.field === "decided_on")
|
|
321
|
+
node.date = row.value;
|
|
322
|
+
else if (row.kind === "E" && row.verb === "decided_by" && isPerson(row.target))
|
|
323
|
+
push(node.deciders, canon(row.target));
|
|
324
|
+
else if (row.kind === "E" && row.verb === "about")
|
|
325
|
+
push(node.about, row.target);
|
|
326
|
+
else if (row.kind === "E" && row.verb === "decided_in")
|
|
327
|
+
node.meeting = row.target;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// Meetings and decisions seen only from a person's side keep attendees that are people.
|
|
332
|
+
for (const node of meetings.values())
|
|
333
|
+
node.attendees = node.attendees.filter((ref) => people.has(ref));
|
|
334
|
+
for (const [ref, node] of [...meetings])
|
|
335
|
+
if (node.date > asOf)
|
|
336
|
+
meetings.delete(ref);
|
|
337
|
+
// Source classes, now that the member's own audiences are known.
|
|
338
|
+
for (const event of events.values())
|
|
339
|
+
event.cls = classifySource(event.src, event.type, event.audience, personal, event.meetings.length > 0);
|
|
340
|
+
for (const node of decisions.values())
|
|
341
|
+
node.cls = classifySource(node.src, "decision", node.audience, personal, node.meeting !== undefined);
|
|
342
|
+
for (const [ref, node] of [...decisions])
|
|
343
|
+
if (node.date > asOf || node.statement === "")
|
|
344
|
+
decisions.delete(ref);
|
|
345
|
+
// One moment written twice by two signals counts once.
|
|
346
|
+
let duplicatesDropped = 0;
|
|
347
|
+
const kept = [];
|
|
348
|
+
const buckets = new Map();
|
|
349
|
+
for (const event of [...events.values()].sort((a, b) => (a.key < b.key ? -1 : 1))) {
|
|
350
|
+
if (!DEDUPE_TYPES.has(event.type)) {
|
|
351
|
+
kept.push(event);
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const bucketKey = `${event.audience}|${event.date}|${event.type}`;
|
|
355
|
+
const bucket = buckets.get(bucketKey) ?? [];
|
|
356
|
+
buckets.set(bucketKey, bucket);
|
|
357
|
+
const twin = bucket.find((other) => other.people.some((person) => event.people.includes(person)) && similarity(other.text, event.text) >= DUPLICATE_SIMILARITY);
|
|
358
|
+
if (twin) {
|
|
359
|
+
duplicatesDropped += 1;
|
|
360
|
+
for (const ref of event.people)
|
|
361
|
+
push(twin.people, ref);
|
|
362
|
+
for (const ref of event.projects)
|
|
363
|
+
push(twin.projects, ref);
|
|
364
|
+
for (const ref of event.companies)
|
|
365
|
+
push(twin.companies, ref);
|
|
366
|
+
for (const ref of event.meetings)
|
|
367
|
+
push(twin.meetings, ref);
|
|
368
|
+
for (const ref of event.decisions)
|
|
369
|
+
push(twin.decisions, ref);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
bucket.push(event);
|
|
373
|
+
kept.push(event);
|
|
374
|
+
}
|
|
375
|
+
const decisionBuckets = new Map();
|
|
376
|
+
for (const node of [...decisions.values()].sort((a, b) => (a.ref < b.ref ? -1 : 1))) {
|
|
377
|
+
const bucket = decisionBuckets.get(`${node.audience}|${node.date}`) ?? [];
|
|
378
|
+
decisionBuckets.set(`${node.audience}|${node.date}`, bucket);
|
|
379
|
+
const twin = bucket.find((other) => similarity(other.statement, node.statement) >= DUPLICATE_SIMILARITY);
|
|
380
|
+
if (twin) {
|
|
381
|
+
duplicatesDropped += 1;
|
|
382
|
+
for (const ref of node.deciders)
|
|
383
|
+
push(twin.deciders, ref);
|
|
384
|
+
for (const ref of node.about)
|
|
385
|
+
push(twin.about, ref);
|
|
386
|
+
twin.meeting = twin.meeting ?? node.meeting;
|
|
387
|
+
decisions.delete(node.ref);
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
bucket.push(node);
|
|
391
|
+
}
|
|
392
|
+
// Commits: weekly rows where a repo has them, the repo rollup otherwise.
|
|
393
|
+
// A repository maps to a project only when that is unambiguous: the project named like the repository,
|
|
394
|
+
// else the one project that lists it. Many board projects list the same repository; its commits then belong to none of them.
|
|
395
|
+
const repoProject = new Map();
|
|
396
|
+
const listing = new Map();
|
|
397
|
+
for (const node of projects.values())
|
|
398
|
+
if (node.repo)
|
|
399
|
+
listing.set(node.repo, [...(listing.get(node.repo) ?? []), node.ref]);
|
|
400
|
+
for (const [repo, refs] of listing)
|
|
401
|
+
if (refs.length === 1)
|
|
402
|
+
repoProject.set(repo, refs[0]);
|
|
403
|
+
const repos = new Set([...weekly, ...rollups].map((item) => item.repo));
|
|
404
|
+
for (const node of projects.values()) {
|
|
405
|
+
const slug = node.ref.slice(node.ref.indexOf("/") + 1);
|
|
406
|
+
if (typeOf(node.ref) === "project" && repos.has(slug))
|
|
407
|
+
repoProject.set(slug, node.ref);
|
|
408
|
+
}
|
|
409
|
+
const hasWeekly = new Set(weekly.map((item) => `${item.person}|${item.repo}`));
|
|
410
|
+
const commits = [...weekly, ...rollups.filter((item) => !hasWeekly.has(`${item.person}|${item.repo}`))].map((item) => {
|
|
411
|
+
const project = repoProject.get(item.repo);
|
|
412
|
+
return project ? { ...item, project } : item;
|
|
413
|
+
});
|
|
414
|
+
// Stated claims that are not rows: the org-chart draft (a local proposal set) and the confirmed chart (a company file).
|
|
415
|
+
const byName = new Map();
|
|
416
|
+
for (const person of people.values())
|
|
417
|
+
if (person.onRoster)
|
|
418
|
+
byName.set(normalizeName(person.name), person.ref);
|
|
419
|
+
if (options.view === "member") {
|
|
420
|
+
const draft = readOrgChartDraft(context);
|
|
421
|
+
for (const line of draft?.lines ?? []) {
|
|
422
|
+
const person = canon(line.person);
|
|
423
|
+
if (!people.has(person))
|
|
424
|
+
continue;
|
|
425
|
+
const fields = [["title", line.role], ["team", line.team], ["manager", line.manager]];
|
|
426
|
+
for (const [field, value] of fields) {
|
|
427
|
+
if (!value)
|
|
428
|
+
continue;
|
|
429
|
+
claim(person, {
|
|
430
|
+
field, value: value.value, ...(value.target ? { target: canon(value.target) } : {}),
|
|
431
|
+
src: value.evidence[0]?.src ?? "doc:org-chart-draft", by: "proposal (org chart draft, not confirmed)", conf: value.conf, open: true, audience: "local", via: "org-chart-draft",
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
// The member's own standup notes list an area beside each name: a claim the member wrote, not behavior.
|
|
436
|
+
for (const event of kept) {
|
|
437
|
+
if (event.cls !== "member-note" || event.type !== "standup")
|
|
438
|
+
continue;
|
|
439
|
+
for (const person of event.people)
|
|
440
|
+
claim(person, { field: "area", value: event.text, src: event.src, by: "member's standup notes", conf: 0.4, open: true, from: event.date, audience: event.audience, via: "member-note" });
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const confirmed = readConfirmedOrgChart(context.companyRoot);
|
|
444
|
+
for (const row of confirmed?.people ?? []) {
|
|
445
|
+
const person = byName.get(normalizeName(row.name));
|
|
446
|
+
if (!person)
|
|
447
|
+
continue;
|
|
448
|
+
const common = { src: "doc:people/org-chart.yaml", by: `human:${confirmed?.confirmedBy ?? ""}`, conf: 1, open: true, from: confirmed?.confirmedOn, audience: "company", via: "org-chart-confirmed" };
|
|
449
|
+
if (row.role)
|
|
450
|
+
claim(person, { field: "title", value: row.role, ...common });
|
|
451
|
+
if (row.team)
|
|
452
|
+
claim(person, { field: "team", value: row.team, ...common });
|
|
453
|
+
if (row.manager) {
|
|
454
|
+
const manager = byName.get(normalizeName(row.manager));
|
|
455
|
+
claim(person, { field: "manager", value: row.manager, ...(manager ? { target: manager } : {}), ...common });
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
view: options.view,
|
|
460
|
+
asOf,
|
|
461
|
+
audiences,
|
|
462
|
+
member: memberRef,
|
|
463
|
+
people,
|
|
464
|
+
foldedInto,
|
|
465
|
+
projects,
|
|
466
|
+
companies,
|
|
467
|
+
meetings,
|
|
468
|
+
decisions,
|
|
469
|
+
events: kept.sort((a, b) => (a.date !== b.date ? (a.date < b.date ? -1 : 1) : a.key < b.key ? -1 : 1)),
|
|
470
|
+
commits: commits.sort((a, b) => (a.date !== b.date ? (a.date < b.date ? -1 : 1) : a.src < b.src ? -1 : 1)),
|
|
471
|
+
stated,
|
|
472
|
+
duplicatesDropped,
|
|
473
|
+
rowsRead,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EntityRef, IsoDate, ModelStep, SourceRef } from "../types.js";
|
|
2
|
+
import { type Act } from "./derive.js";
|
|
3
|
+
import { type ActivityKind, type Area, type CitedSentence, type DirectsEdge, type Example, type ObservedRole, type OrgGraph, type OrgWindow, type WindowProfile } from "./types.js";
|
|
4
|
+
/** The role is described from the most recent window that holds this much evidence. */
|
|
5
|
+
export declare const ROLE_MIN_EVIDENCE = 5;
|
|
6
|
+
export declare function roleWindow(windows: Record<OrgWindow, WindowProfile>): OrgWindow;
|
|
7
|
+
export declare function mainAreas(profile: WindowProfile): {
|
|
8
|
+
area: Area;
|
|
9
|
+
share: number;
|
|
10
|
+
}[];
|
|
11
|
+
export interface RoleInput {
|
|
12
|
+
graph: OrgGraph;
|
|
13
|
+
person: EntityRef;
|
|
14
|
+
acts: readonly Act[];
|
|
15
|
+
windows: Record<OrgWindow, WindowProfile>;
|
|
16
|
+
/** Asymmetric edges out of this person, strongest first. */
|
|
17
|
+
directs: readonly DirectsEdge[];
|
|
18
|
+
}
|
|
19
|
+
export declare function buildRuleRole(input: RoleInput): ObservedRole;
|
|
20
|
+
/** Compares the last 90 days with the nine months before. Null when there is too little on either side or nothing moved. */
|
|
21
|
+
export declare function describeChange(input: RoleInput): CitedSentence | null;
|
|
22
|
+
export declare const ROLE_PROMPT_VERSION = "org-observed-role-v1";
|
|
23
|
+
export declare const ROLE_PROMPT: string;
|
|
24
|
+
export interface PhraseResult {
|
|
25
|
+
role: ObservedRole;
|
|
26
|
+
status: "ok" | "cached" | "pending" | "error" | "rejected";
|
|
27
|
+
}
|
|
28
|
+
/** Asks the model to rephrase a rule-built role. Returns the rule role unchanged unless the reply passes every check. */
|
|
29
|
+
export declare function phraseRole(step: ModelStep & {
|
|
30
|
+
model?: string;
|
|
31
|
+
}, name: string, rule: ObservedRole, examples: Partial<Record<ActivityKind, Example[]>>, day: IsoDate): Promise<PhraseResult>;
|
|
32
|
+
/** The checks a model reply must pass. Exported for tests. */
|
|
33
|
+
export declare function checkPhrasing(raw: Record<string, unknown>, ids: ReadonlyMap<string, SourceRef[]>): {
|
|
34
|
+
line: string;
|
|
35
|
+
sentences: CitedSentence[];
|
|
36
|
+
change: CitedSentence | null;
|
|
37
|
+
} | null;
|
|
38
|
+
//# sourceMappingURL=role.d.ts.map
|