instar 1.3.1113 → 1.3.1115

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.
Files changed (46) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +157 -124
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/CartographerNavigator.d.ts.map +1 -1
  5. package/dist/core/CartographerNavigator.js +8 -3
  6. package/dist/core/CartographerNavigator.js.map +1 -1
  7. package/dist/core/CartographerRootAuthority.d.ts +143 -0
  8. package/dist/core/CartographerRootAuthority.d.ts.map +1 -0
  9. package/dist/core/CartographerRootAuthority.js +448 -0
  10. package/dist/core/CartographerRootAuthority.js.map +1 -0
  11. package/dist/core/CartographerRootRegistry.d.ts +100 -0
  12. package/dist/core/CartographerRootRegistry.d.ts.map +1 -0
  13. package/dist/core/CartographerRootRegistry.js +306 -0
  14. package/dist/core/CartographerRootRegistry.js.map +1 -0
  15. package/dist/core/CartographerSweepEngine.d.ts +12 -0
  16. package/dist/core/CartographerSweepEngine.d.ts.map +1 -1
  17. package/dist/core/CartographerSweepEngine.js +81 -1
  18. package/dist/core/CartographerSweepEngine.js.map +1 -1
  19. package/dist/core/CartographerTree.d.ts +6 -0
  20. package/dist/core/CartographerTree.d.ts.map +1 -1
  21. package/dist/core/CartographerTree.js +6 -1
  22. package/dist/core/CartographerTree.js.map +1 -1
  23. package/dist/core/ScopeVerifier.d.ts +2 -0
  24. package/dist/core/ScopeVerifier.d.ts.map +1 -1
  25. package/dist/core/ScopeVerifier.js +8 -1
  26. package/dist/core/ScopeVerifier.js.map +1 -1
  27. package/dist/data/standards-guard-index.json +1 -1
  28. package/dist/data/standards-guard-index.meta.json +2 -2
  29. package/dist/data/standards-registry.meta.json +1 -1
  30. package/dist/server/AgentServer.d.ts +2 -0
  31. package/dist/server/AgentServer.d.ts.map +1 -1
  32. package/dist/server/AgentServer.js +1 -0
  33. package/dist/server/AgentServer.js.map +1 -1
  34. package/dist/server/routes.d.ts +4 -0
  35. package/dist/server/routes.d.ts.map +1 -1
  36. package/dist/server/routes.js +133 -87
  37. package/dist/server/routes.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/data/builtin-manifest.json +47 -47
  40. package/src/data/standards-guard-index.json +1 -1
  41. package/src/data/standards-guard-index.meta.json +2 -2
  42. package/src/data/standards-registry.meta.json +1 -1
  43. package/upgrades/1.3.1114.md +46 -0
  44. package/upgrades/1.3.1115.md +62 -0
  45. package/upgrades/side-effects/cartographer-project-aware-navigation.md +189 -0
  46. package/upgrades/side-effects/cartographer-verified-root-authority.md +151 -0
@@ -0,0 +1,448 @@
1
+ /**
2
+ * CartographerRootAuthority — inert root-selection and verification substrate.
3
+ *
4
+ * This module deliberately does not wire itself into Cartographer routes or the
5
+ * freshness sweep. It separates three questions that the old projectDir
6
+ * singleton collapsed:
7
+ *
8
+ * 1. Which root did a provenance-bearing source select?
9
+ * 2. What repository identity and revision are actually present there?
10
+ * 3. Which operations are safe at the resulting trust level?
11
+ *
12
+ * A selected directory without a readable Git HEAD remains useful for the
13
+ * zero-cost structural hierarchy, but it is never eligible for paid authoring.
14
+ * Contradictory evidence (for example an expected-remote mismatch) refuses the
15
+ * root entirely. PR 11B-2 is the consumer boundary that will apply this contract
16
+ * to live navigation, reporting, and authoring.
17
+ */
18
+ import crypto from 'node:crypto';
19
+ import fs from 'node:fs';
20
+ import path from 'node:path';
21
+ import { SafeGitExecutor } from './SafeGitExecutor.js';
22
+ const GIT_OP = 'cartographer-root-authority';
23
+ /**
24
+ * Select a candidate only from an explicit, typed provenance source.
25
+ *
26
+ * In particular, a standalone active-project request never falls back to the
27
+ * agent home. That fallback is the wrong-root failure this contract exists to
28
+ * remove. Instar source is explicit-only: directory scanning and marker files
29
+ * may corroborate an identity later, but can never select it.
30
+ */
31
+ export function selectCartographerRootCandidate(request) {
32
+ if (request.kind === 'agent-home') {
33
+ return {
34
+ ok: true,
35
+ candidate: {
36
+ kind: request.kind,
37
+ requestedPath: request.agentHome,
38
+ provenance: { source: 'agent-home', agentName: request.agentName },
39
+ },
40
+ };
41
+ }
42
+ if (request.kind === 'instar-source-checkout') {
43
+ if (!request.binding?.projectDir || !request.binding.gitRemote) {
44
+ return {
45
+ ok: false,
46
+ code: 'instar-source-binding-required',
47
+ message: 'Instar source selection requires an explicit binding with a repository anchor',
48
+ };
49
+ }
50
+ return {
51
+ ok: true,
52
+ candidate: {
53
+ kind: request.kind,
54
+ requestedPath: request.binding.projectDir,
55
+ provenance: {
56
+ source: 'operator-binding',
57
+ bindingId: request.binding.bindingId,
58
+ projectName: request.binding.projectName,
59
+ },
60
+ expectedRemote: request.binding.gitRemote,
61
+ },
62
+ };
63
+ }
64
+ if (request.topicBinding) {
65
+ return {
66
+ ok: true,
67
+ candidate: {
68
+ kind: request.kind,
69
+ requestedPath: request.topicBinding.projectDir,
70
+ provenance: {
71
+ source: 'topic-binding',
72
+ topicId: request.topicBinding.topicId,
73
+ projectName: request.topicBinding.projectName,
74
+ },
75
+ expectedRemote: request.topicBinding.gitRemote,
76
+ },
77
+ };
78
+ }
79
+ if (request.standalone) {
80
+ return {
81
+ ok: false,
82
+ code: 'topic-binding-required',
83
+ message: 'A standalone active-project root requires a topic-project binding',
84
+ };
85
+ }
86
+ if (!request.serverProject) {
87
+ return {
88
+ ok: false,
89
+ code: 'server-project-required',
90
+ message: 'A project-bound active-project root requires the server project declaration',
91
+ };
92
+ }
93
+ return {
94
+ ok: true,
95
+ candidate: {
96
+ kind: request.kind,
97
+ requestedPath: request.serverProject.projectDir,
98
+ provenance: {
99
+ source: 'server-project',
100
+ projectName: request.serverProject.projectName,
101
+ },
102
+ expectedRemote: request.serverProject.gitRemote,
103
+ },
104
+ };
105
+ }
106
+ /** Normalize common HTTPS, SSH, and scp-like Git remote spellings for identity comparison. */
107
+ export function normalizeCartographerGitRemote(raw) {
108
+ let value = raw.trim();
109
+ while (value.endsWith('/'))
110
+ value = value.slice(0, -1);
111
+ if (/\.git$/i.test(value))
112
+ value = value.slice(0, -4);
113
+ const normalizePath = (host, rawPath) => {
114
+ const clean = rawPath
115
+ .replace(/^\/+/, '')
116
+ .replace(/\.git$/i, '')
117
+ .replace(/\/+$/, '');
118
+ // github.com documents repository URLs as case-insensitive. Preserve path
119
+ // case everywhere else: folding an unknown forge's path can collapse two
120
+ // genuinely different repositories into one trusted identity.
121
+ return host === 'github.com' ? clean.toLowerCase() : clean;
122
+ };
123
+ const scp = value.match(/^(?:[^@/]+@)?([^:/]+):(.+)$/);
124
+ if (scp && !value.includes('://')) {
125
+ const host = scp[1].toLowerCase();
126
+ return `${host}/${normalizePath(host, scp[2])}`;
127
+ }
128
+ try {
129
+ const parsed = new URL(value);
130
+ const host = parsed.hostname.toLowerCase();
131
+ const pathname = normalizePath(host, parsed.pathname);
132
+ if (parsed.protocol === 'file:')
133
+ return `file:${pathname}`;
134
+ const defaultPort = (parsed.protocol === 'ssh:' && parsed.port === '22') ||
135
+ (parsed.protocol === 'git:' && parsed.port === '9418') ||
136
+ (parsed.protocol === 'http:' && parsed.port === '80') ||
137
+ (parsed.protocol === 'https:' && parsed.port === '443');
138
+ const authority = parsed.port && !defaultPort ? `${host}:${parsed.port}` : host;
139
+ return `${authority}/${pathname}`;
140
+ }
141
+ catch {
142
+ // Unknown syntax is not safe to case-fold. Equality remains available for
143
+ // byte-equivalent anchors without manufacturing false equivalence.
144
+ return value;
145
+ }
146
+ }
147
+ function digest(value, length = 24) {
148
+ return crypto
149
+ .createHash('sha256')
150
+ .update(value, 'utf8')
151
+ .digest('hex')
152
+ .slice(0, length);
153
+ }
154
+ function provenanceKey(provenance) {
155
+ switch (provenance.source) {
156
+ case 'agent-home':
157
+ return `agent-home:${provenance.agentName}`;
158
+ case 'server-project':
159
+ return `server-project:${provenance.projectName}`;
160
+ case 'topic-binding':
161
+ return `topic-binding:${provenance.topicId}:${provenance.projectName}`;
162
+ case 'operator-binding':
163
+ return `operator-binding:${provenance.bindingId}:${provenance.projectName}`;
164
+ }
165
+ }
166
+ function readGit(cwd, args) {
167
+ try {
168
+ // Root verification must work against the Instar source checkout itself.
169
+ // SafeGitExecutor keeps this opt-in narrow: only its closed read-tier verb
170
+ // allowlist bypasses SourceTreeGuard; a destructive/differently-shaped call
171
+ // still cannot pass through this option.
172
+ const value = SafeGitExecutor.readSync(args, {
173
+ cwd,
174
+ operation: GIT_OP,
175
+ sourceTreeReadOk: true,
176
+ }).trim();
177
+ return value || null;
178
+ }
179
+ catch {
180
+ return null; /* @silent-fallback-ok — unreadable Git evidence becomes a required structured authority decision */
181
+ }
182
+ }
183
+ function readRemotes(cwd) {
184
+ // `remote -v` is on SafeGitExecutor's source-tree read-tier allowlist, while
185
+ // arbitrary config access intentionally is not. Parse fetch identities only:
186
+ // a push-only URL proves write destination, not which repository was checked out.
187
+ const raw = readGit(cwd, ['remote', '-v']);
188
+ if (!raw)
189
+ return [];
190
+ const remotes = [];
191
+ for (const line of raw.split('\n')) {
192
+ const match = line.match(/^(\S+)\s+(.+?)\s+\(fetch\)$/);
193
+ if (!match)
194
+ continue;
195
+ const url = match[2].trim();
196
+ if (!url)
197
+ continue;
198
+ remotes.push({
199
+ name: match[1],
200
+ url,
201
+ normalized: normalizeCartographerGitRemote(url),
202
+ });
203
+ }
204
+ return remotes;
205
+ }
206
+ function canonicalCommonGitDir(cwd) {
207
+ const raw = readGit(cwd, ['rev-parse', '--git-common-dir']);
208
+ if (!raw)
209
+ return null;
210
+ const absolute = path.isAbsolute(raw) ? raw : path.resolve(cwd, raw);
211
+ try {
212
+ return fs.realpathSync(absolute);
213
+ }
214
+ catch {
215
+ return path.resolve(absolute);
216
+ }
217
+ }
218
+ function identityFor(input) {
219
+ const remoteIdentity = input.remoteUrl
220
+ ? `remote:${normalizeCartographerGitRemote(input.remoteUrl)}`
221
+ : null;
222
+ const repositoryBasis = remoteIdentity ??
223
+ (input.commonGitDir ? `common-git-dir:${input.commonGitDir}` : null);
224
+ const repositoryId = repositoryBasis ? digest(repositoryBasis) : null;
225
+ const rootBasis = repositoryId
226
+ ? `${input.candidate.kind}\0${repositoryId}\0${input.canonicalPath}`
227
+ : `${input.candidate.kind}\0structural\0${provenanceKey(input.candidate.provenance)}\0${input.canonicalPath}`;
228
+ const rootId = digest(rootBasis);
229
+ return {
230
+ rootId,
231
+ repositoryId,
232
+ kind: input.candidate.kind,
233
+ canonicalPath: input.canonicalPath,
234
+ gitTopLevel: input.gitTopLevel,
235
+ remoteUrl: input.remoteUrl,
236
+ revision: input.revision,
237
+ stateNamespace: `root-${rootId}`,
238
+ };
239
+ }
240
+ function refused(candidate, reason, identity = null) {
241
+ return {
242
+ candidate,
243
+ trust: 'refused',
244
+ reason,
245
+ identity,
246
+ structuralPopulationAllowed: false,
247
+ paidAuthoringAllowed: false,
248
+ };
249
+ }
250
+ function structuralOnly(candidate, reason, identity) {
251
+ return {
252
+ candidate,
253
+ trust: 'structural-only',
254
+ reason,
255
+ identity,
256
+ structuralPopulationAllowed: true,
257
+ paidAuthoringAllowed: false,
258
+ };
259
+ }
260
+ export class CartographerRootAuthority {
261
+ recordDecision;
262
+ now;
263
+ constructor(options) {
264
+ this.recordDecision = options.recordDecision;
265
+ this.now = options.now ?? (() => new Date());
266
+ }
267
+ decide(assessment, operation, signals, rule = assessment.reason) {
268
+ // Do not return an authority outcome if its required audit sink fails. That
269
+ // keeps the future live consumer from silently acting on an unlogged trust
270
+ // decision and makes recorder availability part of the authority contract.
271
+ this.recordDecision({
272
+ schemaVersion: 1,
273
+ decidedAt: this.now().toISOString(),
274
+ operation,
275
+ context: {
276
+ candidate: {
277
+ ...assessment.candidate,
278
+ provenance: { ...assessment.candidate.provenance },
279
+ },
280
+ },
281
+ signals: { ...signals, observedRemotes: [...signals.observedRemotes] },
282
+ rule,
283
+ outcome: {
284
+ trust: assessment.trust,
285
+ structuralPopulationAllowed: assessment.structuralPopulationAllowed,
286
+ paidAuthoringAllowed: assessment.paidAuthoringAllowed,
287
+ rootId: assessment.identity?.rootId ?? null,
288
+ stateNamespace: assessment.identity?.stateNamespace ?? null,
289
+ },
290
+ });
291
+ return assessment;
292
+ }
293
+ evaluate(candidate, operation, expectedRootId) {
294
+ const signals = {
295
+ pathState: 'unreadable',
296
+ canonicalPath: null,
297
+ gitTopLevel: null,
298
+ expectedRemote: candidate.expectedRemote
299
+ ? normalizeCartographerGitRemote(candidate.expectedRemote)
300
+ : null,
301
+ observedRemotes: [],
302
+ expectedRevision: candidate.expectedRevision ?? null,
303
+ observedRevision: null,
304
+ };
305
+ let stat;
306
+ try {
307
+ stat = fs.statSync(candidate.requestedPath);
308
+ }
309
+ catch {
310
+ return this.decide(refused(candidate, 'path-missing'), operation, signals);
311
+ }
312
+ signals.pathState = stat.isDirectory() ? 'directory' : 'file';
313
+ if (!stat.isDirectory()) {
314
+ return this.decide(refused(candidate, 'path-not-directory'), operation, signals);
315
+ }
316
+ let canonicalPath;
317
+ try {
318
+ canonicalPath = fs.realpathSync(candidate.requestedPath);
319
+ }
320
+ catch {
321
+ return this.decide(refused(candidate, 'canonicalize-failed'), operation, signals);
322
+ }
323
+ signals.canonicalPath = canonicalPath;
324
+ const rawTopLevel = readGit(canonicalPath, [
325
+ 'rev-parse',
326
+ '--show-toplevel',
327
+ ]);
328
+ if (!rawTopLevel) {
329
+ return this.decide(structuralOnly(candidate, 'git-root-unreadable', identityFor({
330
+ candidate,
331
+ canonicalPath,
332
+ gitTopLevel: null,
333
+ remoteUrl: null,
334
+ commonGitDir: null,
335
+ revision: null,
336
+ })), operation, signals);
337
+ }
338
+ let gitTopLevel;
339
+ try {
340
+ gitTopLevel = fs.realpathSync(rawTopLevel);
341
+ }
342
+ catch {
343
+ return this.decide(structuralOnly(candidate, 'git-root-unreadable', identityFor({
344
+ candidate,
345
+ canonicalPath,
346
+ gitTopLevel: null,
347
+ remoteUrl: null,
348
+ commonGitDir: null,
349
+ revision: null,
350
+ })), operation, signals);
351
+ }
352
+ signals.gitTopLevel = gitTopLevel;
353
+ if (gitTopLevel !== canonicalPath) {
354
+ return this.decide(refused(candidate, 'candidate-not-git-root', identityFor({
355
+ candidate,
356
+ canonicalPath,
357
+ gitTopLevel,
358
+ remoteUrl: null,
359
+ commonGitDir: canonicalCommonGitDir(gitTopLevel),
360
+ revision: null,
361
+ })), operation, signals);
362
+ }
363
+ const remotes = readRemotes(canonicalPath);
364
+ signals.observedRemotes = remotes.map((remote) => remote.normalized);
365
+ const expectedRemote = signals.expectedRemote;
366
+ const matchedRemote = expectedRemote
367
+ ? (remotes.find((remote) => remote.normalized === expectedRemote) ?? null)
368
+ : (remotes.find((remote) => remote.name === 'origin') ??
369
+ remotes[0] ??
370
+ null);
371
+ const commonGitDir = canonicalCommonGitDir(canonicalPath);
372
+ const revision = readGit(canonicalPath, ['rev-parse', 'HEAD']);
373
+ signals.observedRevision = revision;
374
+ const provisionalIdentity = identityFor({
375
+ candidate,
376
+ canonicalPath,
377
+ gitTopLevel,
378
+ remoteUrl: matchedRemote?.url ?? null,
379
+ commonGitDir,
380
+ revision,
381
+ });
382
+ if (candidate.kind === 'instar-source-checkout' && !expectedRemote) {
383
+ return this.decide(structuralOnly(candidate, 'instar-source-expectation-missing', provisionalIdentity), operation, signals);
384
+ }
385
+ if (expectedRemote && remotes.length === 0) {
386
+ return this.decide(structuralOnly(candidate, 'remote-unreadable', provisionalIdentity), operation, signals);
387
+ }
388
+ if (expectedRemote && !matchedRemote) {
389
+ const actualIdentity = identityFor({
390
+ candidate,
391
+ canonicalPath,
392
+ gitTopLevel,
393
+ remoteUrl: remotes.find((remote) => remote.name === 'origin')?.url ??
394
+ remotes[0]?.url ??
395
+ null,
396
+ commonGitDir,
397
+ revision,
398
+ });
399
+ return this.decide(refused(candidate, 'remote-mismatch', actualIdentity), operation, signals);
400
+ }
401
+ if (!revision) {
402
+ return this.decide(structuralOnly(candidate, 'head-unreadable', provisionalIdentity), operation, signals);
403
+ }
404
+ if (candidate.expectedRevision && revision !== candidate.expectedRevision) {
405
+ return this.decide(refused(candidate, 'revision-mismatch', provisionalIdentity), operation, signals);
406
+ }
407
+ if (expectedRootId && provisionalIdentity.rootId !== expectedRootId) {
408
+ return this.decide(refused(candidate, 'root-identity-mismatch', provisionalIdentity), operation, signals);
409
+ }
410
+ return this.decide({
411
+ candidate,
412
+ trust: 'verified',
413
+ reason: 'verified',
414
+ identity: provisionalIdentity,
415
+ structuralPopulationAllowed: true,
416
+ // Agent home is an identity/state container, not an active project. Even
417
+ // when it is itself a valid Git repository, selecting it explicitly must
418
+ // not authorize the noisy-home paid sweep that exposed this failure.
419
+ paidAuthoringAllowed: candidate.kind !== 'agent-home',
420
+ }, operation, signals);
421
+ }
422
+ assess(candidate) {
423
+ return this.evaluate(candidate, 'assess');
424
+ }
425
+ /** Revalidate the same root identity and exact revision before a trusted operation. */
426
+ revalidate(assessment) {
427
+ if (assessment.trust !== 'verified' || !assessment.identity?.revision) {
428
+ return this.decide(assessment, 'revalidate', {
429
+ pathState: assessment.identity ? 'directory' : 'unreadable',
430
+ canonicalPath: assessment.identity?.canonicalPath ?? null,
431
+ gitTopLevel: assessment.identity?.gitTopLevel ?? null,
432
+ expectedRemote: assessment.candidate.expectedRemote
433
+ ? normalizeCartographerGitRemote(assessment.candidate.expectedRemote)
434
+ : null,
435
+ observedRemotes: assessment.identity?.remoteUrl
436
+ ? [normalizeCartographerGitRemote(assessment.identity.remoteUrl)]
437
+ : [],
438
+ expectedRevision: assessment.identity?.revision ?? null,
439
+ observedRevision: assessment.identity?.revision ?? null,
440
+ }, 'revalidation-not-applicable');
441
+ }
442
+ return this.evaluate({
443
+ ...assessment.candidate,
444
+ expectedRevision: assessment.identity.revision,
445
+ }, 'revalidate', assessment.identity.rootId);
446
+ }
447
+ }
448
+ //# sourceMappingURL=CartographerRootAuthority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CartographerRootAuthority.js","sourceRoot":"","sources":["../../src/core/CartographerRootAuthority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,MAAM,MAAM,aAAa,CAA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AAS,CAAC,cAAc,CACpC;oBACH,CAAC,CAAC,IAAI;gBACR,eAAe,EAAE,UAAU,CAAC,QAAQ,EAAE,SAAS;oBAC7C,CAAC,CAAC,CAAC,8BAA8B,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;oBACjE,CAAC,CAAC,EAAE;gBACN,gBAAgB,EAAE,UAAU,CAAC,QAAQ,EAAE,QAAQ,IAAI,IAAI;gBACvD,gBAAgB,EAAE,UAAU,CAAC,QAAQ,EAAE,QAAQ,IAAI,IAAI;aACxD,EACD,6BAA6B,CAC9B,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAClB;YACE,GAAG,UAAU,CAAC,SAAS;YACvB,gBAAgB,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ;SAC/C,EACD,YAAY,EACZ,UAAU,CAAC,QAAQ,CAAC,MAAM,CAC3B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,100 @@
1
+ import { CartographerTree } from './CartographerTree.js';
2
+ import { type CartographerRootAssessment, type CartographerRootProvenance } from './CartographerRootAuthority.js';
3
+ import { type CartographerPopulationConfig, type CartographerPopulationResult, type CartographerPopulationDeps } from './cartographerPopulation.js';
4
+ import type { TopicProjectBinding } from './ScopeVerifier.js';
5
+ import type { AgentType } from './types.js';
6
+ export interface CartographerRootReport {
7
+ rootId: string;
8
+ repositoryId: string | null;
9
+ kind: 'agent-home' | 'active-project-checkout' | 'instar-source-checkout';
10
+ canonicalPath: string;
11
+ revision: string | null;
12
+ provenance: CartographerRootProvenance;
13
+ verificationState: 'verified' | 'structural-only';
14
+ verificationReason: CartographerRootAssessment['reason'];
15
+ structuralPopulationAllowed: boolean;
16
+ paidAuthoringAllowed: boolean;
17
+ }
18
+ export interface CartographerResolvedRoot {
19
+ tree: CartographerTree;
20
+ assessment: CartographerRootAssessment;
21
+ report: CartographerRootReport;
22
+ }
23
+ export type CartographerRootResolution = {
24
+ ok: true;
25
+ root: CartographerResolvedRoot;
26
+ } | {
27
+ ok: false;
28
+ reason: string;
29
+ message: string;
30
+ report?: Omit<CartographerRootReport, 'verificationState'> & {
31
+ verificationState: 'refused';
32
+ };
33
+ };
34
+ export type CartographerAuthoringDecision = {
35
+ ok: true;
36
+ root: CartographerResolvedRoot;
37
+ } | {
38
+ ok: false;
39
+ reason: string;
40
+ message: string;
41
+ };
42
+ export interface CartographerBootPopulationResult extends CartographerPopulationResult {
43
+ rootAuthority: CartographerRootReport;
44
+ }
45
+ export interface CartographerRootRegistryOptions {
46
+ agentType: AgentType;
47
+ agentHome: string;
48
+ agentName: string;
49
+ stateDir: string;
50
+ serverProject?: {
51
+ projectDir: string;
52
+ projectName: string;
53
+ gitRemote?: string;
54
+ };
55
+ topicBindings: () => Record<string, TopicProjectBinding>;
56
+ population?: {
57
+ config?: CartographerPopulationConfig;
58
+ onYield?: CartographerPopulationDeps['onYield'];
59
+ /** Test seam only. Production always omits this and uses the real worker. */
60
+ runDetectWorker?: CartographerPopulationDeps['runDetectWorker'];
61
+ };
62
+ decisionLogPath?: string;
63
+ /** Active decision-log ceiling. Default 5 MiB. */
64
+ decisionLogMaxBytes?: number;
65
+ /** Rotated archives retained. Default 2. */
66
+ decisionLogKeepArchives?: number;
67
+ now?: () => Date;
68
+ log?: (message: string) => void;
69
+ }
70
+ /**
71
+ * Registry lifetime is one server boot. Assessments therefore pin the exact
72
+ * revision that produced the current hierarchy; paid writes revalidate against
73
+ * that pin instead of silently adopting a later HEAD.
74
+ */
75
+ export declare class CartographerRootRegistry {
76
+ private readonly options;
77
+ private readonly authority;
78
+ private readonly decisionLogPath;
79
+ private readonly decisionLogMaxBytes;
80
+ private readonly decisionLogKeepArchives;
81
+ private readonly now;
82
+ private readonly log;
83
+ private readonly cachedBySelection;
84
+ private readonly treesByRootId;
85
+ constructor(options: CartographerRootRegistryOptions);
86
+ private recordDecision;
87
+ private select;
88
+ private selectionSignature;
89
+ resolve(topicId?: number): CartographerRootResolution;
90
+ authorizePaidAuthoring(root: CartographerResolvedRoot): CartographerAuthoringDecision;
91
+ /**
92
+ * Per-root trees are regenerable caches, not history. At boot, remove only
93
+ * authority-shaped namespaces no longer selected by any live binding so old
94
+ * topic churn cannot accumulate an unbounded archive of project maps.
95
+ */
96
+ private pruneInactiveRootCaches;
97
+ /** Enumerate all explicit live roots and rebuild each hierarchy once per boot. */
98
+ populateOnBoot(): Promise<CartographerBootPopulationResult[]>;
99
+ }
100
+ //# sourceMappingURL=CartographerRootRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CartographerRootRegistry.d.ts","sourceRoot":"","sources":["../../src/core/CartographerRootRegistry.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAGL,KAAK,0BAA0B,EAG/B,KAAK,0BAA0B,EAEhC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAChC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,YAAY,GAAG,yBAAyB,GAAG,wBAAwB,CAAC;IAC1E,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,0BAA0B,CAAC;IACvC,iBAAiB,EAAE,UAAU,GAAG,iBAAiB,CAAC;IAClD,kBAAkB,EAAE,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IACzD,2BAA2B,EAAE,OAAO,CAAC;IACrC,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB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