@indigoai-us/hq-cloud 6.14.16 → 6.14.18
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/dist/active-company.d.ts +43 -0
- package/dist/active-company.d.ts.map +1 -0
- package/dist/active-company.js +132 -0
- package/dist/active-company.js.map +1 -0
- package/dist/active-company.test.d.ts +2 -0
- package/dist/active-company.test.d.ts.map +1 -0
- package/dist/active-company.test.js +149 -0
- package/dist/active-company.test.js.map +1 -0
- package/dist/bin/sync-runner-planning.d.ts +27 -1
- package/dist/bin/sync-runner-planning.d.ts.map +1 -1
- package/dist/bin/sync-runner-planning.js +33 -4
- package/dist/bin/sync-runner-planning.js.map +1 -1
- package/dist/bin/sync-runner-planning.test.d.ts +2 -0
- package/dist/bin/sync-runner-planning.test.d.ts.map +1 -0
- package/dist/bin/sync-runner-planning.test.js +115 -0
- package/dist/bin/sync-runner-planning.test.js.map +1 -0
- package/dist/bin/sync-runner.d.ts +22 -7
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +92 -16
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +357 -5
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/reindex.d.ts.map +1 -1
- package/dist/cli/reindex.js +127 -2
- package/dist/cli/reindex.js.map +1 -1
- package/dist/cli/reindex.test.js +88 -0
- package/dist/cli/reindex.test.js.map +1 -1
- package/dist/manifest-reconcile.d.ts +118 -5
- package/dist/manifest-reconcile.d.ts.map +1 -1
- package/dist/manifest-reconcile.js +319 -62
- package/dist/manifest-reconcile.js.map +1 -1
- package/dist/manifest-reconcile.test.js +824 -2
- package/dist/manifest-reconcile.test.js.map +1 -1
- package/dist/personal-vault-exclusions.d.ts +1 -6
- package/dist/personal-vault-exclusions.d.ts.map +1 -1
- package/dist/personal-vault-exclusions.js +34 -6
- package/dist/personal-vault-exclusions.js.map +1 -1
- package/dist/personal-vault-exclusions.test.js +22 -0
- package/dist/personal-vault-exclusions.test.js.map +1 -1
- package/dist/personal-vault.d.ts.map +1 -1
- package/dist/personal-vault.js +9 -1
- package/dist/personal-vault.js.map +1 -1
- package/dist/personal-vault.test.js +27 -1
- package/dist/personal-vault.test.js.map +1 -1
- package/dist/vault-client.d.ts +8 -1
- package/dist/vault-client.d.ts.map +1 -1
- package/dist/vault-client.js +29 -1
- package/dist/vault-client.js.map +1 -1
- package/dist/vault-client.test.js +10 -1
- package/dist/vault-client.test.js.map +1 -1
- package/package.json +1 -1
- package/pnpm-workspace.yaml +1 -1
- package/src/active-company.test.ts +188 -0
- package/src/active-company.ts +168 -0
- package/src/bin/sync-runner-planning.test.ts +131 -0
- package/src/bin/sync-runner-planning.ts +60 -7
- package/src/bin/sync-runner.test.ts +430 -10
- package/src/bin/sync-runner.ts +129 -23
- package/src/cli/reindex.test.ts +116 -0
- package/src/cli/reindex.ts +125 -2
- package/src/manifest-reconcile.test.ts +1019 -3
- package/src/manifest-reconcile.ts +424 -66
- package/src/personal-vault-exclusions.test.ts +24 -0
- package/src/personal-vault-exclusions.ts +35 -5
- package/src/personal-vault.test.ts +30 -0
- package/src/personal-vault.ts +9 -1
- package/src/vault-client.test.ts +12 -1
- package/src/vault-client.ts +44 -2
- package/test/joiner-manifest-reconcile.integration.test.ts +283 -0
|
@@ -5,23 +5,136 @@
|
|
|
5
5
|
* only after the complete fanout has settled. That makes the locally
|
|
6
6
|
* materialized cloud companies authoritative for their own manifest entries
|
|
7
7
|
* without discarding entries the personal vault already had.
|
|
8
|
+
*
|
|
9
|
+
* Two layers live here on purpose:
|
|
10
|
+
*
|
|
11
|
+
* - `reconcileManifest(hqRoot, targets)` is the pure reconciler. It takes
|
|
12
|
+
* already-resolved targets and does nothing but validate slugs, merge the
|
|
13
|
+
* fields it owns, and (only when something would actually change) write the
|
|
14
|
+
* manifest.
|
|
15
|
+
* - `reconcileCompanyManifest(options)` is the sync-runner adapter. It decides
|
|
16
|
+
* WHICH targets are eligible (personal mode, fanout completion, on-disk
|
|
17
|
+
* materialization, and — only when an entity resolver is injected — live
|
|
18
|
+
* entity resolution) and then delegates the mutation.
|
|
19
|
+
*
|
|
20
|
+
* The adapter keeps its name and options-object shape because `sync-runner`
|
|
21
|
+
* injects it through `deps.reconcileManifest`. That injection seam is an
|
|
22
|
+
* options-object callback with a different shape from the pure reconciler and
|
|
23
|
+
* must not be conflated with it — renaming the adapter would break the seam.
|
|
8
24
|
*/
|
|
9
|
-
import type
|
|
25
|
+
import { type EntityInfo } from "./vault-client.js";
|
|
10
26
|
export interface ManifestReconcileTarget {
|
|
11
27
|
uid: string;
|
|
12
28
|
slug: string;
|
|
29
|
+
/**
|
|
30
|
+
* Carried by the fanout plan, which already resolved the entity to build the
|
|
31
|
+
* target. Present so the adapter can write a manifest entry with zero extra
|
|
32
|
+
* API calls; still optional because a plan built from a degraded lookup keeps
|
|
33
|
+
* the uid as its only identifier.
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
bucketName?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Entity type/status as captured AT PLAN TIME. These are the liveness
|
|
39
|
+
* evidence for the no-`getEntity` path and are checked with exactly the same
|
|
40
|
+
* predicate the `getEntity` path applies to a freshly fetched entity. Both
|
|
41
|
+
* are optional in the type and REQUIRED in practice: a target that carries
|
|
42
|
+
* neither is "unknown", and unknown is rejected.
|
|
43
|
+
*/
|
|
44
|
+
entityType?: string;
|
|
45
|
+
entityStatus?: string;
|
|
13
46
|
personalMode?: boolean;
|
|
14
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Reported when the injected entity resolver fails in a way that is NOT an
|
|
50
|
+
* ordinary "this entity is gone" lookup outcome. The target is skipped either
|
|
51
|
+
* way; this exists so a systematic resolver failure cannot present as the
|
|
52
|
+
* silent "joiners never get manifest entries" bug this module was written to
|
|
53
|
+
* fix.
|
|
54
|
+
*/
|
|
55
|
+
export interface ManifestReconcileDiagnostic {
|
|
56
|
+
event: string;
|
|
57
|
+
message: string;
|
|
58
|
+
err: unknown;
|
|
59
|
+
context: Record<string, unknown>;
|
|
60
|
+
}
|
|
15
61
|
export interface ManifestReconcileOptions {
|
|
16
62
|
hqRoot: string;
|
|
17
63
|
targets: readonly ManifestReconcileTarget[];
|
|
18
64
|
completedCompanySlugs: ReadonlySet<string>;
|
|
19
|
-
|
|
65
|
+
/**
|
|
66
|
+
* OPTIONAL entity resolver.
|
|
67
|
+
*
|
|
68
|
+
* When supplied, every eligible target is re-verified against a freshly
|
|
69
|
+
* fetched entity ({@link isLiveCompany}) before it may contribute an entry.
|
|
70
|
+
*
|
|
71
|
+
* When omitted — the sync-runner path — each eligible target's entry is
|
|
72
|
+
* resolved from the plan-carried `uid`/`slug`/`name`/`bucketName`, costing
|
|
73
|
+
* zero API calls. This does NOT discharge the liveness requirement: the same
|
|
74
|
+
* type/status assertion still runs, against `entityType`/`entityStatus`
|
|
75
|
+
* captured by `buildFanoutPlan` at the moment it fetched the entity (see
|
|
76
|
+
* {@link isLiveTargetSnapshot}). The only thing given up is freshness — the
|
|
77
|
+
* evidence is from earlier in the same run rather than from a second fetch.
|
|
78
|
+
*
|
|
79
|
+
* A target carrying no liveness fields is REJECTED. Absence is treated as
|
|
80
|
+
* "unknown", never as "fine": the degraded lookup path in `buildFanoutPlan`
|
|
81
|
+
* produces exactly that shape, and admitting it would let an unverified
|
|
82
|
+
* entity into a vault-synced file.
|
|
83
|
+
*/
|
|
84
|
+
getEntity?: (uid: string) => Promise<EntityInfo>;
|
|
85
|
+
/**
|
|
86
|
+
* Optional sink for non-fatal problems. Never affects control flow.
|
|
87
|
+
*/
|
|
88
|
+
reportDiagnostic?: (diagnostic: ManifestReconcileDiagnostic) => void;
|
|
20
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A target that has already been resolved to the values the manifest should
|
|
92
|
+
* carry. `name` and `bucketName` are optional: a company that lacks either is
|
|
93
|
+
* still a real, routable company and must get its `cloud_uid` entry.
|
|
94
|
+
*/
|
|
95
|
+
export interface ManifestReconcileEntryTarget {
|
|
96
|
+
slug: string;
|
|
97
|
+
uid: string;
|
|
98
|
+
bucketName?: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* `added` — slugs newly inserted into `companies:`.
|
|
103
|
+
* `updated` — slugs whose pre-existing entry had a field changed.
|
|
104
|
+
* `skipped` — slugs rejected outright (unsafe slug, non-record existing entry).
|
|
105
|
+
* `written` — whether the manifest file was actually rewritten.
|
|
106
|
+
*/
|
|
107
|
+
export interface ManifestReconcileResult {
|
|
108
|
+
written: boolean;
|
|
109
|
+
added: string[];
|
|
110
|
+
updated: string[];
|
|
111
|
+
skipped: string[];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Merge resolved targets into `companies/manifest.yaml` and report what moved.
|
|
115
|
+
*
|
|
116
|
+
* Only the three fields this module owns are considered: `cloud_uid` (always
|
|
117
|
+
* written — it is the routing key), plus `name` and `bucket_name` when the
|
|
118
|
+
* target carries them. Omitting a field means "do not set this key"; it never
|
|
119
|
+
* means "delete it", so a manifest value already on disk survives a target that
|
|
120
|
+
* has nothing to say about it.
|
|
121
|
+
*
|
|
122
|
+
* The skip-if-unchanged comparison is load-bearing rather than an optimization.
|
|
123
|
+
* `yaml.dump` cannot round-trip comments, so an unconditional rewrite strips the
|
|
124
|
+
* manifest header — and because `manifest.yaml` rides the personal vault, that
|
|
125
|
+
* rewrite propagates to every machine and drives a recurring sync conflict loop.
|
|
126
|
+
* When nothing would change, the file is left byte-for-byte identical and its
|
|
127
|
+
* mtime untouched.
|
|
128
|
+
*/
|
|
129
|
+
export declare function reconcileManifest(hqRoot: string, targets: readonly ManifestReconcileEntryTarget[]): ManifestReconcileResult;
|
|
21
130
|
/**
|
|
22
131
|
* Atomically merge live, successfully pulled company targets into
|
|
23
|
-
* `companies/manifest.yaml`. Targets that are personal, incomplete,
|
|
24
|
-
*
|
|
132
|
+
* `companies/manifest.yaml`. Targets that are personal, incomplete, not
|
|
133
|
+
* materialized on disk, or not a verifiably active company are ignored.
|
|
134
|
+
*
|
|
135
|
+
* Every one of those filters applies on BOTH paths. The paths differ only in
|
|
136
|
+
* where the liveness evidence comes from: a fresh `getEntity` fetch when one is
|
|
137
|
+
* injected, or the type/status the fanout plan captured when it is not.
|
|
25
138
|
*/
|
|
26
|
-
export declare function reconcileCompanyManifest(options: ManifestReconcileOptions): Promise<
|
|
139
|
+
export declare function reconcileCompanyManifest(options: ManifestReconcileOptions): Promise<ManifestReconcileResult>;
|
|
27
140
|
//# sourceMappingURL=manifest-reconcile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-reconcile.d.ts","sourceRoot":"","sources":["../src/manifest-reconcile.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"manifest-reconcile.d.ts","sourceRoot":"","sources":["../src/manifest-reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC5C,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,2BAA2B,KAAK,IAAI,CAAC;CACtE;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AA6MD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,4BAA4B,EAAE,GAC/C,uBAAuB,CA4FzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA8DlC"}
|
|
@@ -5,85 +5,247 @@
|
|
|
5
5
|
* only after the complete fanout has settled. That makes the locally
|
|
6
6
|
* materialized cloud companies authoritative for their own manifest entries
|
|
7
7
|
* without discarding entries the personal vault already had.
|
|
8
|
+
*
|
|
9
|
+
* Two layers live here on purpose:
|
|
10
|
+
*
|
|
11
|
+
* - `reconcileManifest(hqRoot, targets)` is the pure reconciler. It takes
|
|
12
|
+
* already-resolved targets and does nothing but validate slugs, merge the
|
|
13
|
+
* fields it owns, and (only when something would actually change) write the
|
|
14
|
+
* manifest.
|
|
15
|
+
* - `reconcileCompanyManifest(options)` is the sync-runner adapter. It decides
|
|
16
|
+
* WHICH targets are eligible (personal mode, fanout completion, on-disk
|
|
17
|
+
* materialization, and — only when an entity resolver is injected — live
|
|
18
|
+
* entity resolution) and then delegates the mutation.
|
|
19
|
+
*
|
|
20
|
+
* The adapter keeps its name and options-object shape because `sync-runner`
|
|
21
|
+
* injects it through `deps.reconcileManifest`. That injection seam is an
|
|
22
|
+
* options-object callback with a different shape from the pure reconciler and
|
|
23
|
+
* must not be conflated with it — renaming the adapter would break the seam.
|
|
8
24
|
*/
|
|
9
25
|
import { randomUUID } from "node:crypto";
|
|
10
26
|
import * as fs from "node:fs";
|
|
11
27
|
import * as path from "node:path";
|
|
12
28
|
import yaml from "js-yaml";
|
|
29
|
+
import { VaultNotFoundError, VaultPermissionDeniedError, } from "./vault-client.js";
|
|
30
|
+
/**
|
|
31
|
+
* A PLAIN object, not merely "typeof object". js-yaml parses timestamp scalars
|
|
32
|
+
* into `Date`, and a looser check let a `Date` masquerade as the company map (or
|
|
33
|
+
* as an entry), which both defeated the non-record skip and silently destroyed
|
|
34
|
+
* the value via object spread. Arrays, Date, RegExp, and Map are all rejected.
|
|
35
|
+
*/
|
|
13
36
|
function isRecord(value) {
|
|
14
|
-
|
|
37
|
+
if (value === null || typeof value !== "object")
|
|
38
|
+
return false;
|
|
39
|
+
const proto = Object.getPrototypeOf(value);
|
|
40
|
+
return proto === Object.prototype || proto === null;
|
|
15
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Keys that would traverse or mutate the prototype chain rather than create an
|
|
44
|
+
* own property. `__proto__` in particular resolves to `Object.prototype` on read
|
|
45
|
+
* and invokes the prototype setter on write, so it never persists to YAML and
|
|
46
|
+
* therefore reported drift on every single run — an unbounded rewrite loop on a
|
|
47
|
+
* vault-synced file. None of these is ever a legitimate company directory name.
|
|
48
|
+
*/
|
|
49
|
+
const UNSAFE_SLUG_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
50
|
+
/** Own-property read; never falls through to the prototype chain. */
|
|
51
|
+
function ownEntry(companies, slug) {
|
|
52
|
+
return Object.prototype.hasOwnProperty.call(companies, slug) ? companies[slug] : undefined;
|
|
53
|
+
}
|
|
54
|
+
/** Own-property write; never invokes an inherited setter. */
|
|
55
|
+
function setEntry(companies, slug, value) {
|
|
56
|
+
Object.defineProperty(companies, slug, {
|
|
57
|
+
value,
|
|
58
|
+
enumerable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* THE liveness rule. Both eligibility paths route through this single function
|
|
65
|
+
* so they cannot drift: an entity qualifies for a manifest entry only if it is
|
|
66
|
+
* an active company.
|
|
67
|
+
*
|
|
68
|
+
* Written to fail closed on `undefined`. That is the whole point — the
|
|
69
|
+
* plan-carried path can legitimately have no idea what the entity was (the
|
|
70
|
+
* degraded lookup branch in `buildFanoutPlan` records nothing), and "no idea"
|
|
71
|
+
* must never read as "active company".
|
|
72
|
+
*/
|
|
73
|
+
function isLiveCompanyDescriptor(type, status) {
|
|
74
|
+
return type === "company" && status === "active";
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A company is live when the entity still resolves to the uid we routed on and
|
|
78
|
+
* is an active company. `name` and `bucketName` are deliberately NOT required:
|
|
79
|
+
* demanding them dropped otherwise-valid companies from the manifest entirely,
|
|
80
|
+
* which is exactly the joiner bug this module now guards against. Missing
|
|
81
|
+
* fields are omitted from the written entry instead of disqualifying it.
|
|
82
|
+
*/
|
|
16
83
|
function isLiveCompany(entity, uid) {
|
|
17
|
-
return
|
|
18
|
-
entity.type === "company" &&
|
|
19
|
-
entity.status === "active" &&
|
|
20
|
-
typeof entity.name === "string" &&
|
|
21
|
-
entity.name.length > 0 &&
|
|
22
|
-
typeof entity.bucketName === "string" &&
|
|
23
|
-
entity.bucketName.length > 0);
|
|
84
|
+
return entity.uid === uid && isLiveCompanyDescriptor(entity.type, entity.status);
|
|
24
85
|
}
|
|
25
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The same rule applied to liveness captured at plan time instead of to a
|
|
88
|
+
* freshly fetched entity. There is no uid re-check here because there is no
|
|
89
|
+
* second observation to reconcile against — the snapshot came off the very
|
|
90
|
+
* `entity.get(uid)` that produced this target.
|
|
91
|
+
*/
|
|
92
|
+
function isLiveTargetSnapshot(target) {
|
|
93
|
+
return isLiveCompanyDescriptor(target.entityType, target.entityStatus);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Is this entity-probe failure the routine kind?
|
|
97
|
+
*
|
|
98
|
+
* "The company is gone" (404) and "the caller can no longer see it" (403) are
|
|
99
|
+
* the two ordinary reasons a target stops resolving, and both correctly mean
|
|
100
|
+
* "skip, write nothing". Anything else — an auth failure, a 5xx, a network
|
|
101
|
+
* fault, or a plain programming error like a TypeError — shares the same
|
|
102
|
+
* control flow but is NOT routine, and swallowing it silently is how a broken
|
|
103
|
+
* resolver disguises itself as "joiners never get manifest entries".
|
|
104
|
+
*
|
|
105
|
+
* The duck-typed `statusCode` arm matters: `buildFanoutPlan` already classifies
|
|
106
|
+
* this same call's failures that way, so a bare `{ statusCode }` rejection is a
|
|
107
|
+
* shape this codebase genuinely produces, not a hypothetical.
|
|
108
|
+
*/
|
|
109
|
+
function isExpectedLookupFailure(err) {
|
|
110
|
+
if (err instanceof VaultNotFoundError)
|
|
111
|
+
return true;
|
|
112
|
+
if (err instanceof VaultPermissionDeniedError)
|
|
113
|
+
return true;
|
|
114
|
+
return (typeof err === "object" &&
|
|
115
|
+
err !== null &&
|
|
116
|
+
"statusCode" in err &&
|
|
117
|
+
typeof err.statusCode === "number");
|
|
118
|
+
}
|
|
119
|
+
/** Non-empty string, or undefined. Keys with no value are never written. */
|
|
120
|
+
function optionalField(value) {
|
|
121
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Pure path check — a slug must name a direct child of `companies/` and nothing
|
|
125
|
+
* else. This deliberately does NOT require the directory to exist; the on-disk
|
|
126
|
+
* stat check is an eligibility concern and lives in the adapter.
|
|
127
|
+
*/
|
|
128
|
+
function isSafeCompanySlug(companiesDir, slug) {
|
|
129
|
+
if (slug.length === 0)
|
|
130
|
+
return false;
|
|
131
|
+
if (slug.includes("/") || slug.includes("\\"))
|
|
132
|
+
return false;
|
|
133
|
+
if (slug === "." || slug === "..")
|
|
134
|
+
return false;
|
|
135
|
+
if (UNSAFE_SLUG_KEYS.has(slug))
|
|
136
|
+
return false;
|
|
26
137
|
const resolvedCompaniesDir = path.resolve(companiesDir);
|
|
27
138
|
const companyDir = path.resolve(resolvedCompaniesDir, slug);
|
|
28
|
-
|
|
139
|
+
return path.dirname(companyDir) === resolvedCompaniesDir;
|
|
140
|
+
}
|
|
141
|
+
function hasCompanyDirectory(companiesDir, slug) {
|
|
142
|
+
if (!isSafeCompanySlug(companiesDir, slug))
|
|
29
143
|
return false;
|
|
30
144
|
try {
|
|
31
|
-
return fs.statSync(
|
|
145
|
+
return fs.statSync(path.resolve(companiesDir, slug)).isDirectory();
|
|
32
146
|
}
|
|
33
147
|
catch {
|
|
34
148
|
return false;
|
|
35
149
|
}
|
|
36
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Read the manifest, or return null when there is nothing safe to merge into.
|
|
153
|
+
* A missing manifest is a no-op, NOT an invitation to create one: this module
|
|
154
|
+
* only ever restores entries into a manifest that already exists.
|
|
155
|
+
*/
|
|
37
156
|
function loadManifest(manifestPath) {
|
|
38
157
|
try {
|
|
39
|
-
const
|
|
40
|
-
const parsed = yaml.load(raw);
|
|
158
|
+
const parsed = yaml.load(fs.readFileSync(manifestPath, "utf8"));
|
|
41
159
|
return isRecord(parsed) ? parsed : null;
|
|
42
160
|
}
|
|
43
|
-
catch
|
|
44
|
-
if (err.code === "ENOENT")
|
|
45
|
-
return {};
|
|
161
|
+
catch {
|
|
46
162
|
return null;
|
|
47
163
|
}
|
|
48
164
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
fs.writeFileSync(temporaryPath, yaml.dump(document, { lineWidth: -1 }), "utf8");
|
|
52
|
-
fs.renameSync(temporaryPath, manifestPath);
|
|
165
|
+
function serializeManifest(document) {
|
|
166
|
+
return yaml.dump(document, { lineWidth: -1 });
|
|
53
167
|
}
|
|
54
168
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
169
|
+
* Temp-file + rename. The temp file is created in the SAME directory as the
|
|
170
|
+
* target so the rename is a true atomic same-filesystem operation.
|
|
171
|
+
*
|
|
172
|
+
* The `finally` is not cosmetic: without it, a failed write or rename stranded a
|
|
173
|
+
* uniquely-named `.manifest-*.yaml` inside `companies/`, which rides the personal
|
|
174
|
+
* vault to every machine and accumulates one file per failed run.
|
|
175
|
+
*
|
|
176
|
+
* A write failure deliberately PROPAGATES rather than being swallowed into
|
|
177
|
+
* `written: false`. The caller at `sync-runner.ts` already wraps this in a
|
|
178
|
+
* try/catch that emits a `runner.manifest_reconcile.failed` diagnostic; reporting
|
|
179
|
+
* a real I/O failure as a clean no-op would hide it. The AC's "never throws"
|
|
180
|
+
* clause covers manifest READ problems (missing/unreadable/unparseable), all of
|
|
181
|
+
* which are handled as no-ops in `loadManifest`.
|
|
58
182
|
*/
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
183
|
+
function writeManifestAtomically(manifestPath, serialized) {
|
|
184
|
+
const temporaryPath = path.join(path.dirname(manifestPath), `.manifest-${process.pid}-${randomUUID()}.yaml`);
|
|
185
|
+
try {
|
|
186
|
+
fs.writeFileSync(temporaryPath, serialized, "utf8");
|
|
187
|
+
fs.renameSync(temporaryPath, manifestPath);
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
// After a successful rename the temp path is already gone, so this is a
|
|
191
|
+
// no-op on the happy path and a cleanup on every failure path.
|
|
68
192
|
try {
|
|
69
|
-
|
|
70
|
-
if (isLiveCompany(entity, target.uid)) {
|
|
71
|
-
candidates.push({ slug: target.slug, entity });
|
|
72
|
-
}
|
|
193
|
+
fs.rmSync(temporaryPath, { force: true });
|
|
73
194
|
}
|
|
74
195
|
catch {
|
|
75
|
-
//
|
|
76
|
-
|
|
196
|
+
// Best effort — never mask the original error.
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function emptyResult(skipped = []) {
|
|
201
|
+
return { written: false, added: [], updated: [], skipped };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Merge resolved targets into `companies/manifest.yaml` and report what moved.
|
|
205
|
+
*
|
|
206
|
+
* Only the three fields this module owns are considered: `cloud_uid` (always
|
|
207
|
+
* written — it is the routing key), plus `name` and `bucket_name` when the
|
|
208
|
+
* target carries them. Omitting a field means "do not set this key"; it never
|
|
209
|
+
* means "delete it", so a manifest value already on disk survives a target that
|
|
210
|
+
* has nothing to say about it.
|
|
211
|
+
*
|
|
212
|
+
* The skip-if-unchanged comparison is load-bearing rather than an optimization.
|
|
213
|
+
* `yaml.dump` cannot round-trip comments, so an unconditional rewrite strips the
|
|
214
|
+
* manifest header — and because `manifest.yaml` rides the personal vault, that
|
|
215
|
+
* rewrite propagates to every machine and drives a recurring sync conflict loop.
|
|
216
|
+
* When nothing would change, the file is left byte-for-byte identical and its
|
|
217
|
+
* mtime untouched.
|
|
218
|
+
*/
|
|
219
|
+
export function reconcileManifest(hqRoot, targets) {
|
|
220
|
+
const companiesDir = path.join(hqRoot, "companies");
|
|
221
|
+
const skipped = [];
|
|
222
|
+
// Dedupe by slug, last-wins. Two targets for one slug used to flip the change
|
|
223
|
+
// flag on and then back off again, leaving it stuck true while the resulting
|
|
224
|
+
// content was identical — a write (and an mtime bump) on every single run.
|
|
225
|
+
const safeBySlug = new Map();
|
|
226
|
+
for (const target of targets) {
|
|
227
|
+
if (!isSafeCompanySlug(companiesDir, target.slug)) {
|
|
228
|
+
skipped.push(target.slug);
|
|
229
|
+
continue;
|
|
77
230
|
}
|
|
231
|
+
safeBySlug.set(target.slug, target);
|
|
78
232
|
}
|
|
79
|
-
if (
|
|
80
|
-
return;
|
|
233
|
+
if (safeBySlug.size === 0)
|
|
234
|
+
return emptyResult(skipped);
|
|
81
235
|
const manifestPath = path.join(companiesDir, "manifest.yaml");
|
|
82
236
|
const document = loadManifest(manifestPath);
|
|
83
237
|
if (!document)
|
|
84
|
-
return;
|
|
238
|
+
return emptyResult(skipped);
|
|
239
|
+
// Pre-image, in the SAME serialization the writer uses. Comparing against the
|
|
240
|
+
// raw file bytes would be wrong: raw text carries comments and formatting that
|
|
241
|
+
// `yaml.dump` cannot reproduce, so every commented manifest would look
|
|
242
|
+
// "changed" and rewrite on every single run.
|
|
243
|
+
const before = serializeManifest(document);
|
|
85
244
|
let companies;
|
|
86
|
-
if (document.companies === undefined) {
|
|
245
|
+
if (document.companies === undefined || document.companies === null) {
|
|
246
|
+
// A missing `companies:` key and a bare `companies:` (which YAML parses as
|
|
247
|
+
// null) mean the same thing — an empty map. Treating them differently would
|
|
248
|
+
// silently deny a joiner their entry on one of the two shapes.
|
|
87
249
|
companies = {};
|
|
88
250
|
document.companies = companies;
|
|
89
251
|
}
|
|
@@ -91,30 +253,125 @@ export async function reconcileCompanyManifest(options) {
|
|
|
91
253
|
companies = document.companies;
|
|
92
254
|
}
|
|
93
255
|
else {
|
|
94
|
-
//
|
|
95
|
-
// safer than losing a manifest that cannot
|
|
96
|
-
|
|
256
|
+
// Any other shape (array, scalar, timestamp, string) is malformed user
|
|
257
|
+
// state; refusing to replace it is safer than losing a manifest that cannot
|
|
258
|
+
// be interpreted unambiguously.
|
|
259
|
+
return emptyResult(skipped);
|
|
260
|
+
}
|
|
261
|
+
// Changes are STAGED rather than applied in place, so the pre-image can be
|
|
262
|
+
// serialized for comparison and so a pure no-op costs no serialization at all.
|
|
263
|
+
const pending = [];
|
|
264
|
+
for (const target of safeBySlug.values()) {
|
|
265
|
+
const existing = ownEntry(companies, target.slug);
|
|
266
|
+
if (existing !== undefined && !isRecord(existing)) {
|
|
267
|
+
skipped.push(target.slug);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
const desired = { cloud_uid: target.uid };
|
|
271
|
+
const name = optionalField(target.name);
|
|
272
|
+
if (name !== undefined)
|
|
273
|
+
desired.name = name;
|
|
274
|
+
const bucketName = optionalField(target.bucketName);
|
|
275
|
+
if (bucketName !== undefined)
|
|
276
|
+
desired.bucket_name = bucketName;
|
|
277
|
+
if (existing === undefined) {
|
|
278
|
+
pending.push({ slug: target.slug, entry: desired, isNew: true });
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
// Compare ONLY the fields we would write. Everything else on the entry is
|
|
282
|
+
// someone else's state and never participates in the change decision.
|
|
283
|
+
const drifted = Object.keys(desired).some((key) => existing[key] !== desired[key]);
|
|
284
|
+
if (!drifted)
|
|
285
|
+
continue;
|
|
286
|
+
pending.push({ slug: target.slug, entry: { ...existing, ...desired }, isNew: false });
|
|
97
287
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
288
|
+
if (pending.length === 0)
|
|
289
|
+
return emptyResult(skipped);
|
|
290
|
+
// Final-state guard. The write decision rests on the document itself, not on
|
|
291
|
+
// a flag the merge loop could have toggled: apply the staged changes, then
|
|
292
|
+
// write only if the serialized result genuinely differs from the `before`
|
|
293
|
+
// snapshot taken at load time. This is the backstop that stops any
|
|
294
|
+
// order-dependent bug — duplicate targets cancelling out, a sticky flag — from
|
|
295
|
+
// ever reaching a vault-synced file.
|
|
296
|
+
for (const change of pending)
|
|
297
|
+
setEntry(companies, change.slug, change.entry);
|
|
298
|
+
const serialized = serializeManifest(document);
|
|
299
|
+
if (serialized === before)
|
|
300
|
+
return emptyResult(skipped);
|
|
301
|
+
writeManifestAtomically(manifestPath, serialized);
|
|
302
|
+
return {
|
|
303
|
+
written: true,
|
|
304
|
+
added: pending.filter((change) => change.isNew).map((change) => change.slug),
|
|
305
|
+
updated: pending.filter((change) => !change.isNew).map((change) => change.slug),
|
|
306
|
+
skipped,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Atomically merge live, successfully pulled company targets into
|
|
311
|
+
* `companies/manifest.yaml`. Targets that are personal, incomplete, not
|
|
312
|
+
* materialized on disk, or not a verifiably active company are ignored.
|
|
313
|
+
*
|
|
314
|
+
* Every one of those filters applies on BOTH paths. The paths differ only in
|
|
315
|
+
* where the liveness evidence comes from: a fresh `getEntity` fetch when one is
|
|
316
|
+
* injected, or the type/status the fanout plan captured when it is not.
|
|
317
|
+
*/
|
|
318
|
+
export async function reconcileCompanyManifest(options) {
|
|
319
|
+
const companiesDir = path.join(options.hqRoot, "companies");
|
|
320
|
+
const resolvedTargets = [];
|
|
321
|
+
const getEntity = options.getEntity;
|
|
322
|
+
for (const target of options.targets) {
|
|
323
|
+
if (target.personalMode === true ||
|
|
324
|
+
!options.completedCompanySlugs.has(target.slug) ||
|
|
325
|
+
!hasCompanyDirectory(companiesDir, target.slug)) {
|
|
102
326
|
continue;
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
327
|
+
}
|
|
328
|
+
if (getEntity === undefined) {
|
|
329
|
+
// Plan-carried path. The liveness rule is NOT relaxed here — it is
|
|
330
|
+
// applied to the type/status the plan captured off `entity.get`. A target
|
|
331
|
+
// with no such evidence fails closed and never reaches the manifest.
|
|
332
|
+
if (!isLiveTargetSnapshot(target))
|
|
333
|
+
continue;
|
|
334
|
+
resolvedTargets.push({
|
|
335
|
+
slug: target.slug,
|
|
336
|
+
uid: target.uid,
|
|
337
|
+
...(target.name === undefined ? {} : { name: target.name }),
|
|
338
|
+
...(target.bucketName === undefined ? {} : { bucketName: target.bucketName }),
|
|
339
|
+
});
|
|
107
340
|
continue;
|
|
108
341
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
342
|
+
try {
|
|
343
|
+
const entity = await getEntity(target.uid);
|
|
344
|
+
if (isLiveCompany(entity, target.uid)) {
|
|
345
|
+
resolvedTargets.push({
|
|
346
|
+
slug: target.slug,
|
|
347
|
+
uid: entity.uid,
|
|
348
|
+
...(entity.name === undefined ? {} : { name: entity.name }),
|
|
349
|
+
...(entity.bucketName === undefined ? {} : { bucketName: entity.bucketName }),
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
catch (err) {
|
|
354
|
+
// The target is not presently a live, resolvable company. Never mint a
|
|
355
|
+
// manifest entry from stale fanout data — so the target is skipped
|
|
356
|
+
// regardless of WHY the probe failed.
|
|
357
|
+
//
|
|
358
|
+
// But "entity is gone" and "the resolver is broken" are different
|
|
359
|
+
// stories with identical control flow, and only the first is routine.
|
|
360
|
+
// Staying silent on the second is how a systematic resolver failure
|
|
361
|
+
// disguises itself as "joiners never get manifest entries" — the exact
|
|
362
|
+
// bug class this module exists to prevent.
|
|
363
|
+
if (!isExpectedLookupFailure(err)) {
|
|
364
|
+
options.reportDiagnostic?.({
|
|
365
|
+
event: "runner.manifest_reconcile.entity_probe_failed",
|
|
366
|
+
message: "unexpected error resolving company entity; target skipped",
|
|
367
|
+
err,
|
|
368
|
+
context: { slug: target.slug, uid: target.uid },
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
116
372
|
}
|
|
117
|
-
if (
|
|
118
|
-
|
|
373
|
+
if (resolvedTargets.length === 0)
|
|
374
|
+
return emptyResult();
|
|
375
|
+
return reconcileManifest(options.hqRoot, resolvedTargets);
|
|
119
376
|
}
|
|
120
377
|
//# sourceMappingURL=manifest-reconcile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-reconcile.js","sourceRoot":"","sources":["../src/manifest-reconcile.ts"],"names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