@intentic/sandbox-contract 1.422.0 → 1.424.0
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/chores/chores.d.ts.map +1 -1
- package/dist/chores/chores.js +1 -48
- package/dist/chores/chores.js.map +1 -1
- package/dist/chores/index.d.ts +1 -1
- package/dist/chores/index.d.ts.map +1 -1
- package/dist/chores/index.js +1 -1
- package/dist/chores/index.js.map +1 -1
- package/dist/chores/prompt.d.ts +0 -1
- package/dist/chores/prompt.d.ts.map +1 -1
- package/dist/chores/prompt.js +0 -2
- package/dist/chores/prompt.js.map +1 -1
- package/dist/contracts/capabilities.contract.d.ts +0 -28
- package/dist/contracts/capabilities.contract.d.ts.map +1 -1
- package/dist/contracts/issues.contract.d.ts +6 -0
- package/dist/contracts/issues.contract.d.ts.map +1 -1
- package/dist/contracts/offload.contract.d.ts +14 -14
- package/dist/contracts/panels.contract.d.ts +0 -7
- package/dist/contracts/panels.contract.d.ts.map +1 -1
- package/dist/contracts/seal.contract.d.ts +1 -25
- package/dist/contracts/seal.contract.d.ts.map +1 -1
- package/dist/contracts/seal.contract.js +3 -14
- package/dist/contracts/seal.contract.js.map +1 -1
- package/dist/contracts/secrets.contract.d.ts +2 -17
- package/dist/contracts/secrets.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.js +2 -2
- package/dist/contracts/secrets.contract.js.map +1 -1
- package/dist/contracts/settings.contract.d.ts +0 -135
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +18 -18
- package/dist/contracts/workspace.contract.d.ts +0 -60
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.js +1 -11
- package/dist/contracts/workspace.contract.js.map +1 -1
- package/dist/ids/project-id.d.ts +3 -0
- package/dist/ids/project-id.d.ts.map +1 -0
- package/dist/ids/project-id.js +25 -0
- package/dist/ids/project-id.js.map +1 -0
- package/dist/ids/tunnel-ids.d.ts +0 -1
- package/dist/ids/tunnel-ids.d.ts.map +1 -1
- package/dist/ids/tunnel-ids.js +0 -1
- package/dist/ids/tunnel-ids.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/models/model-roles.d.ts +1 -1
- package/dist/models/model-roles.d.ts.map +1 -1
- package/dist/models/model-roles.js +1 -1
- package/dist/models/model-roles.js.map +1 -1
- package/dist/protocol/doors/sandbox-pass.d.ts +22 -0
- package/dist/protocol/doors/sandbox-pass.d.ts.map +1 -0
- package/dist/protocol/doors/sandbox-pass.js +72 -0
- package/dist/protocol/doors/sandbox-pass.js.map +1 -0
- package/dist/protocol/raw/raw-json-routes.d.ts +92 -9
- package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-json-routes.js +6 -2
- package/dist/protocol/raw/raw-json-routes.js.map +1 -1
- package/dist/protocol/raw/raw-routes.d.ts +16 -7
- package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-routes.js +4 -2
- package/dist/protocol/raw/raw-routes.js.map +1 -1
- package/dist/schemas/capabilities.d.ts +0 -14
- package/dist/schemas/capabilities.d.ts.map +1 -1
- package/dist/schemas/capabilities.js +0 -4
- package/dist/schemas/capabilities.js.map +1 -1
- package/dist/schemas/certificate-request.d.ts +0 -2
- package/dist/schemas/certificate-request.d.ts.map +1 -1
- package/dist/schemas/issues.d.ts +133 -0
- package/dist/schemas/issues.d.ts.map +1 -1
- package/dist/schemas/issues.js +34 -0
- package/dist/schemas/issues.js.map +1 -1
- package/dist/schemas/maintenance.d.ts.map +1 -1
- package/dist/schemas/maintenance.js +16 -10
- package/dist/schemas/maintenance.js.map +1 -1
- package/dist/schemas/metrics.d.ts.map +1 -1
- package/dist/schemas/metrics.js.map +1 -1
- package/dist/schemas/panels.d.ts +0 -14
- package/dist/schemas/panels.d.ts.map +1 -1
- package/dist/schemas/panels.js +0 -6
- package/dist/schemas/panels.js.map +1 -1
- package/dist/schemas/personas.d.ts.map +1 -1
- package/dist/schemas/personas.js +0 -6
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/providers/usage.d.ts +0 -12
- package/dist/schemas/providers/usage.d.ts.map +1 -1
- package/dist/schemas/providers/usage.js +0 -5
- package/dist/schemas/providers/usage.js.map +1 -1
- package/dist/schemas/seal.d.ts +2 -21
- package/dist/schemas/seal.d.ts.map +1 -1
- package/dist/schemas/seal.js +1 -16
- package/dist/schemas/seal.js.map +1 -1
- package/dist/schemas/secrets.d.ts +1 -22
- package/dist/schemas/secrets.d.ts.map +1 -1
- package/dist/schemas/secrets.js +3 -13
- package/dist/schemas/secrets.js.map +1 -1
- package/dist/schemas/settings-experiments.d.ts +0 -4
- package/dist/schemas/settings-experiments.d.ts.map +1 -1
- package/dist/schemas/settings-experiments.js +0 -12
- package/dist/schemas/settings-experiments.js.map +1 -1
- package/dist/schemas/settings-history.d.ts +1 -1
- package/dist/schemas/settings-history.d.ts.map +1 -1
- package/dist/schemas/settings-history.js +1 -0
- package/dist/schemas/settings-history.js.map +1 -1
- package/dist/schemas/settings-savings.d.ts +0 -144
- package/dist/schemas/settings-savings.d.ts.map +1 -1
- package/dist/schemas/settings-savings.js +1 -3
- package/dist/schemas/settings-savings.js.map +1 -1
- package/dist/schemas/settings.d.ts +0 -4
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +2 -3
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/short-codes.d.ts +0 -10
- package/dist/schemas/short-codes.d.ts.map +1 -1
- package/dist/schemas/short-codes.js +1 -9
- package/dist/schemas/short-codes.js.map +1 -1
- package/dist/schemas/workspace/workspace-search.d.ts +0 -12
- package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
- package/dist/schemas/workspace/workspace-search.js +5 -12
- package/dist/schemas/workspace/workspace-search.js.map +1 -1
- package/dist/state/definition.d.ts +0 -24
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/update-probation.d.ts +1 -1
- package/dist/state/update-probation.d.ts.map +1 -1
- package/dist/state/update-probation.js +1 -1
- package/dist/state/update-probation.js.map +1 -1
- package/dist/state/workspace-state.d.ts +6 -1
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +7 -1
- package/dist/state/workspace-state.js.map +1 -1
- package/package.json +27 -5
- package/src/chores/chores.test.ts +1 -2
- package/src/chores/chores.ts +2 -62
- package/src/chores/index.ts +1 -1
- package/src/chores/prompt.ts +1 -6
- package/src/chores/verdict.test.ts +3 -44
- package/src/contracts/seal.contract.ts +3 -18
- package/src/contracts/secrets.contract.ts +4 -5
- package/src/contracts/workspace.contract.ts +2 -14
- package/src/events/system-events.ts +2 -2
- package/src/ids/project-id.test.ts +26 -0
- package/src/ids/project-id.ts +34 -0
- package/src/ids/tunnel-ids.test.ts +2 -23
- package/src/ids/tunnel-ids.ts +0 -4
- package/src/index.ts +0 -6
- package/src/models/model-roles.ts +3 -1
- package/src/policy/persona-capability.ts +1 -1
- package/src/protocol/doors/sandbox-pass.test.ts +51 -0
- package/src/protocol/doors/sandbox-pass.ts +119 -0
- package/src/protocol/headers.ts +2 -2
- package/src/protocol/member-reach.test.ts +0 -1
- package/src/protocol/raw/raw-json-routes.ts +14 -2
- package/src/protocol/raw/raw-routes.ts +9 -5
- package/src/protocol/routes.test.ts +0 -4
- package/src/schemas/capabilities.ts +0 -6
- package/src/schemas/issues.ts +54 -0
- package/src/schemas/maintenance.ts +20 -12
- package/src/schemas/metrics.ts +2 -0
- package/src/schemas/panels.ts +0 -8
- package/src/schemas/personas.ts +2 -6
- package/src/schemas/providers/usage.ts +5 -14
- package/src/schemas/seal.ts +5 -30
- package/src/schemas/secrets.ts +8 -20
- package/src/schemas/settings-experiments.ts +0 -17
- package/src/schemas/settings-history.ts +3 -0
- package/src/schemas/settings-savings.ts +2 -9
- package/src/schemas/settings.test.ts +16 -9
- package/src/schemas/settings.ts +4 -4
- package/src/schemas/short-codes.ts +2 -14
- package/src/schemas/version-seam.test.ts +2 -2
- package/src/schemas/workspace/workspace-search.ts +12 -25
- package/src/state/update-probation.ts +4 -3
- package/src/state/workspace-state.test.ts +2 -2
- package/src/state/workspace-state.ts +10 -1
- package/src/text/path-refs.test.ts +1 -1
- package/dist/contracts/intentic.contract.d.ts +0 -30
- package/dist/contracts/intentic.contract.d.ts.map +0 -1
- package/dist/contracts/intentic.contract.js +0 -34
- package/dist/contracts/intentic.contract.js.map +0 -1
- package/dist/contracts/inventory.contract.d.ts +0 -138
- package/dist/contracts/inventory.contract.d.ts.map +0 -1
- package/dist/contracts/inventory.contract.js +0 -31
- package/dist/contracts/inventory.contract.js.map +0 -1
- package/dist/schemas/codebase-health.d.ts +0 -56
- package/dist/schemas/codebase-health.d.ts.map +0 -1
- package/dist/schemas/codebase-health.js +0 -43
- package/dist/schemas/codebase-health.js.map +0 -1
- package/dist/schemas/intentic.d.ts +0 -5
- package/dist/schemas/intentic.d.ts.map +0 -1
- package/dist/schemas/intentic.js +0 -3
- package/dist/schemas/intentic.js.map +0 -1
- package/dist/schemas/inventory.d.ts +0 -175
- package/dist/schemas/inventory.d.ts.map +0 -1
- package/dist/schemas/inventory.js +0 -62
- package/dist/schemas/inventory.js.map +0 -1
- package/dist/schemas/seal-proof.d.ts +0 -20
- package/dist/schemas/seal-proof.d.ts.map +0 -1
- package/dist/schemas/seal-proof.js +0 -8
- package/dist/schemas/seal-proof.js.map +0 -1
- package/src/contracts/intentic.contract.ts +0 -45
- package/src/contracts/inventory.contract.ts +0 -35
- package/src/schemas/codebase-health.ts +0 -60
- package/src/schemas/intentic.ts +0 -2
- package/src/schemas/inventory.ts +0 -83
- package/src/schemas/seal-proof.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentic/sandbox-contract",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.424.0",
|
|
4
4
|
"description": "oRPC wire contract for the intentic sandbox daemon, shared by the daemon and its browser client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -239,6 +239,28 @@
|
|
|
239
239
|
"default": "./dist/policy/identity-assertion.js"
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
|
+
"./sandbox-pass": {
|
|
243
|
+
"types": "./dist/protocol/doors/sandbox-pass.d.ts",
|
|
244
|
+
"import": {
|
|
245
|
+
"@intentic/src": "./src/protocol/doors/sandbox-pass.ts",
|
|
246
|
+
"default": "./dist/protocol/doors/sandbox-pass.js"
|
|
247
|
+
},
|
|
248
|
+
"require": {
|
|
249
|
+
"@intentic/src": "./src/protocol/doors/sandbox-pass.ts",
|
|
250
|
+
"default": "./dist/protocol/doors/sandbox-pass.js"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"./project-id": {
|
|
254
|
+
"types": "./dist/ids/project-id.d.ts",
|
|
255
|
+
"import": {
|
|
256
|
+
"@intentic/src": "./src/ids/project-id.ts",
|
|
257
|
+
"default": "./dist/ids/project-id.js"
|
|
258
|
+
},
|
|
259
|
+
"require": {
|
|
260
|
+
"@intentic/src": "./src/ids/project-id.ts",
|
|
261
|
+
"default": "./dist/ids/project-id.js"
|
|
262
|
+
}
|
|
263
|
+
},
|
|
242
264
|
"./keyring-seal": {
|
|
243
265
|
"types": "./dist/policy/keyring-seal.d.ts",
|
|
244
266
|
"import": {
|
|
@@ -373,10 +395,10 @@
|
|
|
373
395
|
}
|
|
374
396
|
},
|
|
375
397
|
"dependencies": {
|
|
376
|
-
"@intentic/base": "1.
|
|
377
|
-
"@intentic/constants": "1.
|
|
378
|
-
"@intentic/extension-manifest": "1.
|
|
379
|
-
"@intentic/registry": "1.
|
|
398
|
+
"@intentic/base": "1.424.0",
|
|
399
|
+
"@intentic/constants": "1.424.0",
|
|
400
|
+
"@intentic/extension-manifest": "1.424.0",
|
|
401
|
+
"@intentic/registry": "1.424.0",
|
|
380
402
|
"@orpc/contract": "1.16.1",
|
|
381
403
|
"zod": "4.6.7"
|
|
382
404
|
},
|
|
@@ -11,9 +11,8 @@ describe(`the chore book's order`, () => {
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it(`keeps every chore in the book`, () => {
|
|
14
|
-
// Counted by id, not just length, so a dropped chore says which one.
|
|
15
14
|
expect(new Set(CHORES.map((chore) => chore.id)).size).toBe(CHORES.length);
|
|
16
|
-
expect(CHORES.length).toBe(
|
|
15
|
+
expect(CHORES.length).toBe(17);
|
|
17
16
|
});
|
|
18
17
|
|
|
19
18
|
it(`says "surveying" exactly when a chore is a survey`, () => {
|
package/src/chores/chores.ts
CHANGED
|
@@ -446,65 +446,6 @@ const documentation: Chore = {
|
|
|
446
446
|
done: `Done when every package you named has a document that a newcomer could use to find the file they need, and no other file changed.`,
|
|
447
447
|
};
|
|
448
448
|
|
|
449
|
-
// Reports only the two shapes worth arguing about in a hotspot ranking:
|
|
450
|
-
// - volatile and depended-on: a hotspot that is also a key module, every edit ripples outward.
|
|
451
|
-
// - out of proportion: branching three times the median of its own ranking.
|
|
452
|
-
const COMPLEXITY_MULTIPLE = 3;
|
|
453
|
-
|
|
454
|
-
const median = (values: readonly number[]): number => {
|
|
455
|
-
if (values.length === 0) {
|
|
456
|
-
return 0;
|
|
457
|
-
}
|
|
458
|
-
const sorted = values.toSorted((left, right) => left - right);
|
|
459
|
-
const middle = Math.floor(sorted.length / 2);
|
|
460
|
-
return sorted.length % 2 === 0 ? ((sorted[middle - 1] ?? 0) + (sorted[middle] ?? 0)) / 2 : (sorted[middle] ?? 0);
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
const complexity: Chore = {
|
|
464
|
-
id: `complexity`,
|
|
465
|
-
title: `Simplify what everything waits on`,
|
|
466
|
-
icon: `wave-pulse`,
|
|
467
|
-
description: `Files that both churn and carry the repository, where edits are slow and ripple outward.`,
|
|
468
|
-
kind: `accruing`,
|
|
469
|
-
criterion: `A file in the hotspot ranking is also a key module, or its branching is three times the median of that ranking.`,
|
|
470
|
-
stance: `act`,
|
|
471
|
-
needs: [],
|
|
472
|
-
cadenceMs: 30 * DAY_MS,
|
|
473
|
-
assess: (context) => {
|
|
474
|
-
// A half-built index ranks whatever it has finished reading, not the repository; better to say nothing than
|
|
475
|
-
// target the wrong file.
|
|
476
|
-
if (!context.signals.indexed || context.signals.hotspots.length === 0) {
|
|
477
|
-
return undefined;
|
|
478
|
-
}
|
|
479
|
-
const keyModules = new Set(context.signals.keyModules.map((module) => module.path));
|
|
480
|
-
const middle = median(context.signals.hotspots.map((hotspot) => hotspot.complexity));
|
|
481
|
-
const found = context.signals.hotspots.filter(
|
|
482
|
-
(hotspot) => keyModules.has(hotspot.path) || hotspot.complexity >= middle * COMPLEXITY_MULTIPLE,
|
|
483
|
-
);
|
|
484
|
-
if (found.length === 0) {
|
|
485
|
-
return undefined;
|
|
486
|
-
}
|
|
487
|
-
const reason = (path: string, branches: number): string =>
|
|
488
|
-
keyModules.has(path) ? `churns and the rest of the repository imports it` : `${branches} branch points against a median of ${middle}`;
|
|
489
|
-
return {
|
|
490
|
-
headline: `${plural(found.length, `file`)} where every edit is slow and ripples outward`,
|
|
491
|
-
detail: found.map((hotspot) => `${hotspot.path}, ${hotspot.commits} commits, ${reason(hotspot.path, hotspot.complexity)}`),
|
|
492
|
-
digest: digestOf(...found.map((hotspot) => hotspot.path).toSorted()),
|
|
493
|
-
severity: `info`,
|
|
494
|
-
why:
|
|
495
|
-
`${plural(found.length, `file`)} in ${repoLabel(context.repo)} are both change magnets and structurally tangled: ` +
|
|
496
|
-
`${found.map((hotspot) => `${hotspot.path} (${hotspot.commits} commits, ${hotspot.complexity} branch points)`).join(`; `)}.`,
|
|
497
|
-
};
|
|
498
|
-
},
|
|
499
|
-
diagnosis: `A file that changes constantly and branches heavily makes every edit near it slow and easy to get wrong.`,
|
|
500
|
-
goal:
|
|
501
|
-
`Take ONE file: the worst of them, and no more. Read it first. If the rest of the repository imports it, separate the stable ` +
|
|
502
|
-
`contract from the churn: a narrow surface for importers, the volatile implementation private behind it. If it is simply ` +
|
|
503
|
-
`tangled, flatten it where it stands: edge cases as early returns, compound conditions behind named predicates, long chains as ` +
|
|
504
|
-
`lookups, and extract a unit only if a cohesive one falls out. Behaviour stays identical, and no re-export shims are left behind.`,
|
|
505
|
-
done: `Done when \`iq hotspots\` reports materially fewer branch points for that file, the checks of what it changed pass, and no importer changed meaning.`,
|
|
506
|
-
};
|
|
507
|
-
|
|
508
449
|
// A static table, current only as of this file's last edit; no network call. Source: nodejs/Release.
|
|
509
450
|
const NODE_EOL: Readonly<Record<number, string>> = {
|
|
510
451
|
16: `2023-09-11`,
|
|
@@ -937,7 +878,7 @@ const survey = ({ id, title, icon, description, diagnosis, goal, done, cadenceDa
|
|
|
937
878
|
done,
|
|
938
879
|
});
|
|
939
880
|
|
|
940
|
-
// Below this a repo is too small for cross-cutting patterns to have diverged; counted in
|
|
881
|
+
// Below this a repo is too small for cross-cutting patterns to have diverged; counted in code files so a config-only
|
|
941
882
|
// scaffold doesn't pass by accident.
|
|
942
883
|
const PATTERNS_FLOOR = 25;
|
|
943
884
|
|
|
@@ -956,7 +897,7 @@ const patterns = survey({
|
|
|
956
897
|
cadenceDays: 90,
|
|
957
898
|
// The one cause that is a measurement, not an absence; every size-gated chore uses this same string so they group
|
|
958
899
|
// together.
|
|
959
|
-
applies: (signals) => (signals.totals.files >= PATTERNS_FLOOR ? undefined : `only ${signals.totals.files}
|
|
900
|
+
applies: (signals) => (signals.totals.files >= PATTERNS_FLOOR ? undefined : `only ${signals.totals.files} code files`),
|
|
960
901
|
});
|
|
961
902
|
|
|
962
903
|
const deprecated = survey({
|
|
@@ -1051,7 +992,6 @@ const BOOK: readonly Chore[] = [
|
|
|
1051
992
|
runtime,
|
|
1052
993
|
dependencies,
|
|
1053
994
|
deadCode,
|
|
1054
|
-
complexity,
|
|
1055
995
|
testStrength,
|
|
1056
996
|
bundleWeight,
|
|
1057
997
|
frameworkIdiom,
|
package/src/chores/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CHORE_KINDS, CHORES, choreAutomationPrompt, choreById, chorePrompt, repoLabel, repoName } from "./chores.js";
|
|
2
2
|
export type { Chore, ChoreContext, ChoreFinding, ChoreKind, ChoreKindSpec, ChoreStance } from "./chores.js";
|
|
3
3
|
export { bucketOf, digestOf } from "./digest.js";
|
|
4
|
-
export { CHORE_INVARIANTS, composeAsk,
|
|
4
|
+
export { CHORE_INVARIANTS, composeAsk, REPORT_INVARIANTS, TRIAGE_NOTE } from "./prompt.js";
|
|
5
5
|
export type { Ask } from "./prompt.js";
|
|
6
6
|
export { updateBrief } from "./extension-update.js";
|
|
7
7
|
export type { UpdateBrief } from "./extension-update.js";
|
package/src/chores/prompt.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// subject — what is being worked on.
|
|
3
3
|
// why — the measurement's numbers, quoted exactly, then what they mean.
|
|
4
4
|
// goal — a direction to move in, not a prescribed design.
|
|
5
|
-
// done — falsifiable; checkable
|
|
5
|
+
// done — falsifiable; checkable in the agent's own worktree.
|
|
6
6
|
// Invariants sit between goal and done: constraints on how, restated in full each time.
|
|
7
7
|
|
|
8
8
|
export interface Ask {
|
|
@@ -34,8 +34,3 @@ export const CHORE_INVARIANTS =
|
|
|
34
34
|
export const REPORT_INVARIANTS =
|
|
35
35
|
`Change nothing. This is a survey: the output is your findings, cited file:line, and a recommendation the owner ` +
|
|
36
36
|
`can act on or dismiss. Where you would propose an edit, describe it and where it would go instead of making it.`;
|
|
37
|
-
|
|
38
|
-
// Constraints for a one-file refactor turn; scope covers whatever it splits into, not just this one file.
|
|
39
|
-
export const REFACTOR_INVARIANTS =
|
|
40
|
-
`Read it first. Behaviour stays identical. Changes affect only this file, whatever it splits into, and the ` +
|
|
41
|
-
`importers that must follow. Leave no re-export shims behind.`;
|
|
@@ -44,8 +44,8 @@ const signals = (over: Partial<ChoreSignals> = {}): ChoreSignals => ({
|
|
|
44
44
|
shape: shape(),
|
|
45
45
|
hotspots: [],
|
|
46
46
|
keyModules: [],
|
|
47
|
-
totals: { files: 100, symbols:
|
|
48
|
-
indexed:
|
|
47
|
+
totals: { files: 100, symbols: 0, complexity: 0, hotspots: 0 },
|
|
48
|
+
indexed: false,
|
|
49
49
|
...over,
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -305,47 +305,6 @@ describe(`the badge speaks about transitions, not about statistics`, () => {
|
|
|
305
305
|
});
|
|
306
306
|
|
|
307
307
|
describe(`the findings themselves`, () => {
|
|
308
|
-
test(`complexity reports only files that are load-bearing or out of proportion, never just the ranking's top`, () => {
|
|
309
|
-
const hotspot = (path: string, complexity: number) => ({
|
|
310
|
-
path,
|
|
311
|
-
commits: 20,
|
|
312
|
-
adds: 100,
|
|
313
|
-
dels: 50,
|
|
314
|
-
complexity,
|
|
315
|
-
score: complexity * 20,
|
|
316
|
-
latestMs: NOW,
|
|
317
|
-
});
|
|
318
|
-
// An even ranking has no outlier and no key module: a healthy repository, an empty finding.
|
|
319
|
-
const even = report({
|
|
320
|
-
repos: [{ repo: `app`, probes: [], signals: signals({ hotspots: [hotspot(`a.ts`, 30), hotspot(`b.ts`, 28), hotspot(`c.ts`, 26)] }) }],
|
|
321
|
-
});
|
|
322
|
-
expect(verdictFor(even, `complexity`).state).toBe(`clear`);
|
|
323
|
-
|
|
324
|
-
const outlier = report({
|
|
325
|
-
repos: [{ repo: `app`, probes: [], signals: signals({ hotspots: [hotspot(`a.ts`, 200), hotspot(`b.ts`, 28), hotspot(`c.ts`, 26)] }) }],
|
|
326
|
-
});
|
|
327
|
-
const verdict = verdictFor(outlier, `complexity`);
|
|
328
|
-
expect(verdict.state).toBe(`due`);
|
|
329
|
-
expect(verdict.detail).toHaveLength(1);
|
|
330
|
-
expect(verdict.detail[0]).toContain(`a.ts`);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
test(`a half-built index says nothing rather than ranking what it has read so far`, () => {
|
|
334
|
-
const partial = report({
|
|
335
|
-
repos: [
|
|
336
|
-
{
|
|
337
|
-
repo: `app`,
|
|
338
|
-
probes: [],
|
|
339
|
-
signals: signals({
|
|
340
|
-
indexed: false,
|
|
341
|
-
hotspots: [{ path: `a.ts`, commits: 9, adds: 1, dels: 1, complexity: 900, score: 8100, latestMs: NOW }],
|
|
342
|
-
}),
|
|
343
|
-
},
|
|
344
|
-
],
|
|
345
|
-
});
|
|
346
|
-
expect(verdictFor(partial, `complexity`).state).toBe(`clear`);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
308
|
test(`two libraries for one job is the finding; one is not`, () => {
|
|
350
309
|
const one = report({ repos: [{ repo: `app`, probes: [], signals: signals({ packages: [pkg({ dependencies: [`zod`] })] }) }] });
|
|
351
310
|
expect(verdictFor(one, `library-overlap`).state).toBe(`clear`);
|
|
@@ -481,7 +440,7 @@ describe(`what does not apply here`, () => {
|
|
|
481
440
|
test(`a tiny repository is not surveyed for cross-cutting patterns it cannot have`, () => {
|
|
482
441
|
const fileCount = 4;
|
|
483
442
|
const tiny = report({
|
|
484
|
-
repos: [{ repo: `app`, probes: [], signals: signals({ totals: { files: fileCount, symbols:
|
|
443
|
+
repos: [{ repo: `app`, probes: [], signals: signals({ totals: { files: fileCount, symbols: 0, complexity: 0, hotspots: 0 } }) }],
|
|
485
444
|
});
|
|
486
445
|
const verdict = verdictFor(tiny, `standardize-patterns`);
|
|
487
446
|
expect(verdict.state).toBe(`not-applicable`);
|
|
@@ -5,13 +5,11 @@ import {
|
|
|
5
5
|
SealApproveSchema,
|
|
6
6
|
SealHouseSchema,
|
|
7
7
|
SealIdSchema,
|
|
8
|
-
|
|
9
|
-
SealOpenPrepareSchema,
|
|
8
|
+
SealOpenRequestSchema,
|
|
10
9
|
SealSetDefaultSchema,
|
|
11
10
|
SealSetHouseSchema,
|
|
12
11
|
SealSetSchema,
|
|
13
12
|
} from "../schemas/seal.js";
|
|
14
|
-
import { SealOpenProofSchema } from "../schemas/seal-proof.js";
|
|
15
13
|
|
|
16
14
|
// PRIVATE CONVERSATIONS (schemas/seal.ts). Every route here is a person's: none is open to the agent token, a panel or a
|
|
17
15
|
// control token, so no agent ever makes, reads past or opens a seal, the owner's own agents included. Each route
|
|
@@ -79,29 +77,16 @@ export const sealContract = {
|
|
|
79
77
|
.meta({ floor: "viewer", guest: true })
|
|
80
78
|
.input(SealAnswerSchema)
|
|
81
79
|
.output(AgentSummarySchema),
|
|
82
|
-
// The document is prepared here rather than in the browser so its nonce and expiry are the daemon's, and the reason
|
|
83
|
-
// the author is shown is exactly the one that was signed.
|
|
84
|
-
prepareOpen: procedure
|
|
85
|
-
.route({
|
|
86
|
-
method: "POST",
|
|
87
|
-
path: "/seal/{id}/open/prepare",
|
|
88
|
-
summary: "Prepare to open a private conversation without asking",
|
|
89
|
-
description:
|
|
90
|
-
"For the sandbox owner alone: writes the document their passkey signs to open a private conversation without asking its author, with the reason they gave. Nothing opens yet.",
|
|
91
|
-
})
|
|
92
|
-
.meta({ floor: "owner" })
|
|
93
|
-
.input(SealOpenPrepareSchema)
|
|
94
|
-
.output(SealOpenCeremonySchema),
|
|
95
80
|
open: procedure
|
|
96
81
|
.route({
|
|
97
82
|
method: "POST",
|
|
98
83
|
path: "/seal/{id}/open",
|
|
99
84
|
summary: "Open a private conversation without asking",
|
|
100
85
|
description:
|
|
101
|
-
"For the sandbox owner alone, with
|
|
86
|
+
"For the sandbox owner alone, with a written reason: lets them read a private conversation for a day without its author's yes. It is read-only, its author is told at once, and the reason stays on the conversation for good. Where an organisation asks for two people, it waits for a second person with Full access to agree.",
|
|
102
87
|
})
|
|
103
88
|
.meta({ floor: "owner" })
|
|
104
|
-
.input(
|
|
89
|
+
.input(SealOpenRequestSchema)
|
|
105
90
|
.output(AgentSummarySchema),
|
|
106
91
|
approveOpen: procedure
|
|
107
92
|
.route({
|
|
@@ -36,9 +36,8 @@ const secretRoute = procedure.meta({ floor: "maintainer", control: "never", righ
|
|
|
36
36
|
// someone does not reach them, and the handlers hold them to the owner.
|
|
37
37
|
const ownerKeyringRoute = procedure.meta({ floor: "maintainer", control: "never" });
|
|
38
38
|
|
|
39
|
-
// User-supplied secrets, in the
|
|
40
|
-
//
|
|
41
|
-
// returns a value, owner-only, POST so the key avoids the URL.
|
|
39
|
+
// User-supplied secrets, in the sandbox's own store; a set value resolves with no restart. `inventory` aggregates every
|
|
40
|
+
// store (never values) and always answers. `reveal` alone returns a value, owner-only, POST so the key avoids the URL.
|
|
42
41
|
export const secretsContract = {
|
|
43
42
|
set: secretRoute
|
|
44
43
|
.route({
|
|
@@ -46,7 +45,7 @@ export const secretsContract = {
|
|
|
46
45
|
path: "/secrets",
|
|
47
46
|
summary: "Store a secret",
|
|
48
47
|
description:
|
|
49
|
-
"Writes one name and value where the agent's references resolve it, without a restart
|
|
48
|
+
"Writes one name and value into the sandbox's own secret store, where the agent's references resolve it, without a restart.",
|
|
50
49
|
})
|
|
51
50
|
.input(SecretSetSchema)
|
|
52
51
|
.output(OkSchema),
|
|
@@ -95,7 +94,7 @@ export const secretsContract = {
|
|
|
95
94
|
path: "/secrets/inventory",
|
|
96
95
|
summary: "Every secret this sandbox holds, from everywhere",
|
|
97
96
|
description:
|
|
98
|
-
"One view across all the places secrets live here: what exists, where it came from and whether it is working. Never any values. This one always answers, even before
|
|
97
|
+
"One view across all the places secrets live here: what exists, where it came from and whether it is working. Never any values. This one always answers, even before anything has been stored.",
|
|
99
98
|
})
|
|
100
99
|
.output(SecretInventorySchema),
|
|
101
100
|
reveal: secretRoute
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { procedure } from "../protocol/route-meta.js";
|
|
2
2
|
import { streamOf } from "../protocol/stream-of.js";
|
|
3
|
-
import { WorkspaceHealthQuerySchema, WorkspaceHealthSchema } from "../schemas/codebase-health.js";
|
|
4
3
|
import { WorkspaceModulesSchema } from "../schemas/git/git.js";
|
|
5
4
|
import { OkSchema } from "../schemas/shared.js";
|
|
6
5
|
import {
|
|
@@ -194,14 +193,14 @@ export const workspaceContract = {
|
|
|
194
193
|
.meta({ guest: true })
|
|
195
194
|
.input(WorkspaceResolveQuerySchema)
|
|
196
195
|
.output(WorkspaceResolveSchema),
|
|
197
|
-
// `mode`
|
|
196
|
+
// `mode` picks text (the default) or file names; both are ripgrep walks of the tree as it is on disk.
|
|
198
197
|
search: procedure
|
|
199
198
|
.route({
|
|
200
199
|
method: "GET",
|
|
201
200
|
path: "/workspace/search",
|
|
202
201
|
summary: "Search the code",
|
|
203
202
|
description:
|
|
204
|
-
"
|
|
203
|
+
"Matching lines across the whole workspace grouped by file, or with the files mode the files whose names match, best first. Both read the tree as it is on disk, with no index in between. Long result sets resume from the cursor it hands back.",
|
|
205
204
|
})
|
|
206
205
|
.meta({ guest: true, control: "editor" })
|
|
207
206
|
.input(WorkspaceSearchQuerySchema)
|
|
@@ -219,17 +218,6 @@ export const workspaceContract = {
|
|
|
219
218
|
.meta({ floor: "viewer", guest: true, stream: true, control: "editor" })
|
|
220
219
|
.input(WorkspaceSearchQuerySchema)
|
|
221
220
|
.output(streamOf(WorkspaceSearchFrameSchema)),
|
|
222
|
-
// Per-file churn × complexity, index totals, top modules; scoped to a repo, not the whole /work drop.
|
|
223
|
-
health: procedure
|
|
224
|
-
.route({
|
|
225
|
-
method: "GET",
|
|
226
|
-
path: "/workspace/health",
|
|
227
|
-
summary: "A repo's shape in numbers",
|
|
228
|
-
description:
|
|
229
|
-
"Where one repo's risk sits: the files that change often and are complicated at once, what the index holds, and which modules the rest of the code leans on most. Scoped to a repo, because a codebase is a repo rather than the whole drop.",
|
|
230
|
-
})
|
|
231
|
-
.input(WorkspaceHealthQuerySchema)
|
|
232
|
-
.output(WorkspaceHealthSchema),
|
|
233
221
|
// Deterministic, no-LLM classification into coarse buckets; read-only, applied only via the move route.
|
|
234
222
|
classify: procedure
|
|
235
223
|
.route({
|
|
@@ -8,8 +8,8 @@ import { WorkspaceTreeDeltaSchema } from "../schemas/workspace/workspace-tree.js
|
|
|
8
8
|
// Frames about the sandbox rather than a turn: liveness, boot progress, what moved (repos, refs, running processes,
|
|
9
9
|
// presence, the fleet), and account headroom. One stream carries them all.
|
|
10
10
|
|
|
11
|
-
// One
|
|
12
|
-
//
|
|
11
|
+
// One progress line a streamed run yields (a capability's apply, an exit's start, a disk's mount); open-ended, so any
|
|
12
|
+
// string `kind` plus extra fields pass through.
|
|
13
13
|
export const IntenticLineSchema = z.looseObject({ kind: z.string() });
|
|
14
14
|
export type IntenticLine = z.infer<typeof IntenticLineSchema>;
|
|
15
15
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { normalizeProjectId } from "./project-id.js";
|
|
2
|
+
|
|
3
|
+
describe("project id", () => {
|
|
4
|
+
it("reads every remote spelling of one repository as one project", () => {
|
|
5
|
+
for (const remote of [
|
|
6
|
+
"git@github.com:Acme/App.git",
|
|
7
|
+
"https://github.com/acme/app",
|
|
8
|
+
"https://user:token@github.com/acme/app.git",
|
|
9
|
+
"ssh://git@github.com:22/acme/app.git",
|
|
10
|
+
"github.com/acme/app/",
|
|
11
|
+
" GitHub.com/Acme/App ",
|
|
12
|
+
]) {
|
|
13
|
+
expect(normalizeProjectId(remote)).toBe("github.com/acme/app");
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("keeps nested groups", () => {
|
|
18
|
+
expect(normalizeProjectId("git@gitlab.com:group/sub/repo.git")).toBe("gitlab.com/group/sub/repo");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("refuses what names no repository", () => {
|
|
22
|
+
for (const text of ["", "app", "github.com", "/local/path/repo", "file:///tmp/repo", "github.com/acme app"]) {
|
|
23
|
+
expect(normalizeProjectId(text)).toBeUndefined();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// One spelling for "a project" across account-level report routing: the platform keys claims by it, the sending daemon
|
|
2
|
+
// resolves by it, the receiving daemon checks a pass against it. A project is a repository, named the way its remote
|
|
3
|
+
// names it, so `git@github.com:Acme/App.git`, `https://github.com/acme/app` and `github.com/acme/app/` are one project:
|
|
4
|
+
// `github.com/acme/app`. Host and path are lowercased; the hosts people use are case-insensitive about owners and repos.
|
|
5
|
+
|
|
6
|
+
// host + at least one path segment, each a conservative charset; nothing that could be a URL with a query or a port.
|
|
7
|
+
const PROJECT_ID = /^[a-z0-9.-]+\.[a-z]{2,}(\/[a-z0-9._~-]+)+$/;
|
|
8
|
+
|
|
9
|
+
export const PROJECT_ID_MAX = 200;
|
|
10
|
+
|
|
11
|
+
// The normalized id, or undefined when the text does not name a repository.
|
|
12
|
+
export const normalizeProjectId = (raw: string): string | undefined => {
|
|
13
|
+
let text = raw.trim();
|
|
14
|
+
if (text === "") {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
// scp-like ssh: user@host:path
|
|
18
|
+
const scp = /^[^@/\s]+@([^:/\s]+):(.+)$/.exec(text);
|
|
19
|
+
if (scp !== null) {
|
|
20
|
+
text = `${scp[1]}/${scp[2]}`;
|
|
21
|
+
} else {
|
|
22
|
+
text = text.replace(/^[a-z+]+:\/\//i, "");
|
|
23
|
+
// credentials and ports never belong to a project's identity
|
|
24
|
+
text = text.replace(/^[^@/]*@/, "");
|
|
25
|
+
text = text.replace(/^([^/:]+):\d+\//, "$1/");
|
|
26
|
+
}
|
|
27
|
+
text = text
|
|
28
|
+
.replace(/[?#].*$/, "")
|
|
29
|
+
.replace(/\/+$/, "")
|
|
30
|
+
.replace(/\.git$/i, "")
|
|
31
|
+
.replace(/\/+/g, "/")
|
|
32
|
+
.toLowerCase();
|
|
33
|
+
return text.length <= PROJECT_ID_MAX && PROJECT_ID.test(text) ? text : undefined;
|
|
34
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { repoRoot } from "@intentic/constants/node";
|
|
4
|
-
import {
|
|
4
|
+
import { PORT_SLOT_COUNT, portSlotsFromToken, sandboxIdFromToken } from "./tunnel-ids.js";
|
|
5
5
|
|
|
6
|
-
// The digests every language spells again (ic's util.rs,
|
|
6
|
+
// The digests every language spells again (ic's util.rs, sandbox-run's Web Crypto twin) are held to the
|
|
7
7
|
// run contract's names.fixture.json, which each of them is tested against. SAFETY: the fixture is this repository's own
|
|
8
8
|
// file; the assertions below fail on any field it lacks.
|
|
9
9
|
const SHARED = JSON.parse(readFileSync(join(repoRoot(import.meta.url), "_shared/sandbox-run/src/names.fixture.json"), "utf8")) as {
|
|
10
10
|
readonly sandboxIds: { readonly vectors: { readonly token: string; readonly id: string }[] };
|
|
11
|
-
readonly hostSshIds: { readonly vectors: { readonly token: string; readonly hostName: string; readonly id: string }[] };
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
const TOKEN = "connect-token-one";
|
|
@@ -21,11 +20,6 @@ test("the sandbox id is a stable 12-hex digest of the connect token, and absent
|
|
|
21
20
|
expect(sandboxIdFromToken("")).toBeUndefined();
|
|
22
21
|
});
|
|
23
22
|
|
|
24
|
-
test("a host ssh id is salted per host, so two deploy targets never collide", () => {
|
|
25
|
-
expect(hostSshIdFromToken(TOKEN, "web-1")).toMatch(/^[0-9a-f]{12}$/);
|
|
26
|
-
expect(hostSshIdFromToken(TOKEN, "web-1")).not.toBe(hostSshIdFromToken(TOKEN, "web-2"));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
23
|
test("port slots are a fixed-size pool of DNS-safe labels, stable per token", () => {
|
|
30
24
|
const slots = portSlotsFromToken(TOKEN);
|
|
31
25
|
expect(slots).toHaveLength(PORT_SLOT_COUNT);
|
|
@@ -50,18 +44,3 @@ test("slots are not derivable from the sandbox id: only from the token behind it
|
|
|
50
44
|
test.each(SHARED.sandboxIds.vectors)("the sandbox id of $token is $id, the digest ic and the browser derive too", ({ token, id }) => {
|
|
51
45
|
expect(sandboxIdFromToken(token)).toBe(id);
|
|
52
46
|
});
|
|
53
|
-
|
|
54
|
-
test.each(SHARED.hostSshIds.vectors)("the host ssh id of $token on $hostName is $id", ({ token, hostName, id }) => {
|
|
55
|
-
expect(hostSshIdFromToken(token, hostName)).toBe(id);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// connect-host.ps1 digests a server's id itself when a code's answer carries no HOST_ID, and no PowerShell runs in the
|
|
59
|
-
// suites. What can be held is its source: the same salted input (`<token>:<host name>`), the same hash, the same cut, over
|
|
60
|
-
// UTF-8 bytes, so a change to one half reads as a change to the other here.
|
|
61
|
-
test("connect-host.ps1 digests the host ssh id the way hostSshIdFromToken does", () => {
|
|
62
|
-
const script = readFileSync(join(repoRoot(import.meta.url), "_site/site/public/scripts/connect-host.ps1"), "utf8");
|
|
63
|
-
expect(script).toContain("$slugInput = '{0}:{1}' -f $ConnectToken, $HostName");
|
|
64
|
-
expect(script).toContain("[System.Security.Cryptography.SHA256]::Create()");
|
|
65
|
-
expect(script).toContain("[System.Text.Encoding]::UTF8.GetBytes($slugInput)");
|
|
66
|
-
expect(script).toContain("-replace '-', '').Substring(0, 12).ToLower()");
|
|
67
|
-
});
|
package/src/ids/tunnel-ids.ts
CHANGED
|
@@ -11,10 +11,6 @@ export { SANDBOX_ID } from "./sandbox-id.js";
|
|
|
11
11
|
export const sandboxIdFromToken = (connectToken: string): string | undefined =>
|
|
12
12
|
connectToken === "" ? undefined : sha256Hex(connectToken).slice(0, 12);
|
|
13
13
|
|
|
14
|
-
// A per-host SSH tunnel's stable 12-hex id, salted with the host name so each enrolled deploy target gets its own
|
|
15
|
-
// ssh-<id>.<zone>. Shared by the CLI and the platform API, which must derive the identical id.
|
|
16
|
-
export const hostSshIdFromToken = (connectToken: string, hostName: string): string => sha256Hex(`${connectToken}:${hostName}`).slice(0, 12);
|
|
17
|
-
|
|
18
14
|
// Eight is enough for a monorepo's dev servers, and the hard cap on preview DNS records one sandbox can cost.
|
|
19
15
|
export const PORT_SLOT_COUNT = 8;
|
|
20
16
|
|
package/src/index.ts
CHANGED
|
@@ -23,8 +23,6 @@ import { extensionsContract } from "./contracts/extensions.contract.js";
|
|
|
23
23
|
import { gitContract } from "./contracts/git.contract.js";
|
|
24
24
|
import { historyContract } from "./contracts/history.contract.js";
|
|
25
25
|
import { hubContract } from "./contracts/hub.contract.js";
|
|
26
|
-
import { intenticContract } from "./contracts/intentic.contract.js";
|
|
27
|
-
import { inventoryContract } from "./contracts/inventory.contract.js";
|
|
28
26
|
import { issuesContract } from "./contracts/issues.contract.js";
|
|
29
27
|
import { logsContract } from "./contracts/logs.contract.js";
|
|
30
28
|
import { loopsContract } from "./contracts/loops.contract.js";
|
|
@@ -82,8 +80,6 @@ export const sandboxContract: {
|
|
|
82
80
|
git: typeof gitContract;
|
|
83
81
|
history: typeof historyContract;
|
|
84
82
|
hub: typeof hubContract;
|
|
85
|
-
intentic: typeof intenticContract;
|
|
86
|
-
inventory: typeof inventoryContract;
|
|
87
83
|
issues: typeof issuesContract;
|
|
88
84
|
logs: typeof logsContract;
|
|
89
85
|
loops: typeof loopsContract;
|
|
@@ -135,8 +131,6 @@ export const sandboxContract: {
|
|
|
135
131
|
git: gitContract,
|
|
136
132
|
history: historyContract,
|
|
137
133
|
hub: hubContract,
|
|
138
|
-
intentic: intenticContract,
|
|
139
|
-
inventory: inventoryContract,
|
|
140
134
|
issues: issuesContract,
|
|
141
135
|
logs: logsContract,
|
|
142
136
|
loops: loopsContract,
|
|
@@ -142,7 +142,9 @@ export const MODEL_ROLES = [
|
|
|
142
142
|
{
|
|
143
143
|
id: "refactor-run",
|
|
144
144
|
label: "Refactors",
|
|
145
|
-
|
|
145
|
+
// Started from the Health tab, removed with iq (2026-11-18). The id stays: every saved roleSetups names it, and a
|
|
146
|
+
// newer editor reads an older daemon's settings with this enum.
|
|
147
|
+
blurb: "Kept so settings saved before the Health tab was removed still read; nothing starts a refactor run now.",
|
|
146
148
|
kind: "run",
|
|
147
149
|
icon: "hammer",
|
|
148
150
|
setup: "high",
|
|
@@ -30,7 +30,7 @@ const listed = (list: readonly string[] | undefined, id: string): boolean => lis
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Whether a persona carrying these accounts (its `capabilities`) and these shelves may act through a capability. A kind
|
|
33
|
-
* absent from the switch (an agent runtime, a
|
|
33
|
+
* absent from the switch (an agent runtime, a VPN) passes untouched, so a new kind is never silently
|
|
34
34
|
* denied.
|
|
35
35
|
*/
|
|
36
36
|
export const personaAllowsCapability = (capability: CapabilityRef, accounts: readonly string[], shelves: PersonaShelves): boolean => {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { generateKeyPairSync } from "node:crypto";
|
|
2
|
+
import { mintIdentityAssertion, verifyIdentityAssertion } from "../../policy/identity-assertion.js";
|
|
3
|
+
import { isSandboxPass, mintSandboxPass, SANDBOX_PASS_MAX_TTL_MS, SANDBOX_PASS_TTL_MS, verifySandboxPass } from "./sandbox-pass.js";
|
|
4
|
+
|
|
5
|
+
const pemPair = (): { privateKey: string; publicKey: string } =>
|
|
6
|
+
generateKeyPairSync("ed25519", { publicKeyEncoding: { type: "spki", format: "pem" }, privateKeyEncoding: { type: "pkcs8", format: "pem" } });
|
|
7
|
+
const { privateKey: privatePem, publicKey: publicPem } = pemPair();
|
|
8
|
+
const NOW = 1_800_000_000_000;
|
|
9
|
+
const A = "0123456789ab";
|
|
10
|
+
const B = "ba9876543210";
|
|
11
|
+
|
|
12
|
+
const mint = (overrides: Partial<Parameters<typeof mintSandboxPass>[1]> = {}): string =>
|
|
13
|
+
mintSandboxPass(privatePem, { from: A, fromName: "ops", to: B, project: "github.com/acme/app", issuedAtMs: NOW, ...overrides });
|
|
14
|
+
|
|
15
|
+
describe("sandbox pass", () => {
|
|
16
|
+
it("round-trips the claim and expires when it says", () => {
|
|
17
|
+
const pass = mint();
|
|
18
|
+
expect(isSandboxPass(pass)).toBe(true);
|
|
19
|
+
expect(verifySandboxPass(publicPem, pass, NOW + 1_000)).toEqual({
|
|
20
|
+
from: A,
|
|
21
|
+
fromName: "ops",
|
|
22
|
+
to: B,
|
|
23
|
+
project: "github.com/acme/app",
|
|
24
|
+
issuedAt: NOW / 1000,
|
|
25
|
+
expiresAt: (NOW + SANDBOX_PASS_TTL_MS) / 1000,
|
|
26
|
+
});
|
|
27
|
+
expect(verifySandboxPass(publicPem, pass, NOW + SANDBOX_PASS_TTL_MS)).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("refuses another key, a tampered payload, and a claim from the future", () => {
|
|
31
|
+
expect(verifySandboxPass(pemPair().publicKey, mint(), NOW)).toBeUndefined();
|
|
32
|
+
const [prefix, payload, signature] = mint().split(".");
|
|
33
|
+
const forged = Buffer.from(Buffer.from(payload ?? "", "base64url").toString("utf8").replace(B, A.replace("0", "f")), "utf8").toString("base64url");
|
|
34
|
+
expect(verifySandboxPass(publicPem, `${prefix}.${forged}.${signature}`, NOW)).toBeUndefined();
|
|
35
|
+
expect(verifySandboxPass(publicPem, mint({ issuedAtMs: NOW + 120_000 }), NOW)).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("is never an identity assertion, nor the reverse, under the same key", () => {
|
|
39
|
+
const pass = mint();
|
|
40
|
+
expect(verifyIdentityAssertion(publicPem, pass, NOW)).toBeUndefined();
|
|
41
|
+
const assertion = mintIdentityAssertion(privatePem, { sandboxId: B, email: "a@b.org", method: "email", issuedAtMs: NOW });
|
|
42
|
+
expect(verifySandboxPass(publicPem, assertion, NOW)).toBeUndefined();
|
|
43
|
+
expect(verifySandboxPass(publicPem, assertion.replace(/^pa1/, "sp1"), NOW)).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("refuses to mint a pass to itself or one that lives too long", () => {
|
|
47
|
+
expect(() => mint({ to: A })).toThrow();
|
|
48
|
+
expect(() => mint({ ttlMs: SANDBOX_PASS_MAX_TTL_MS + 1 })).toThrow();
|
|
49
|
+
expect(() => mint({ project: " " })).toThrow();
|
|
50
|
+
});
|
|
51
|
+
});
|