@telora/daemon 0.17.82 → 0.17.88
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/build-info.json +10 -3
- package/dist/audit-hooks.d.ts +24 -0
- package/dist/audit-hooks.d.ts.map +1 -1
- package/dist/audit-hooks.js +52 -1
- package/dist/audit-hooks.js.map +1 -1
- package/dist/audit-phase.d.ts +30 -6
- package/dist/audit-phase.d.ts.map +1 -1
- package/dist/audit-phase.js +46 -18
- package/dist/audit-phase.js.map +1 -1
- package/dist/cli/codex-provision.d.ts +28 -0
- package/dist/cli/codex-provision.d.ts.map +1 -1
- package/dist/cli/codex-provision.js +35 -1
- package/dist/cli/codex-provision.js.map +1 -1
- package/dist/completion/read-only-pristine.d.ts +63 -0
- package/dist/completion/read-only-pristine.d.ts.map +1 -0
- package/dist/completion/read-only-pristine.js +87 -0
- package/dist/completion/read-only-pristine.js.map +1 -0
- package/dist/completion/team-completion.d.ts.map +1 -1
- package/dist/completion/team-completion.js +20 -1
- package/dist/completion/team-completion.js.map +1 -1
- package/dist/condition-evaluators.d.ts.map +1 -1
- package/dist/condition-evaluators.js +36 -0
- package/dist/condition-evaluators.js.map +1 -1
- package/dist/discovery-poll.d.ts +50 -0
- package/dist/discovery-poll.d.ts.map +1 -0
- package/dist/discovery-poll.js +240 -0
- package/dist/discovery-poll.js.map +1 -0
- package/dist/focus-executor.d.ts +47 -1
- package/dist/focus-executor.d.ts.map +1 -1
- package/dist/focus-executor.js +95 -8
- package/dist/focus-executor.js.map +1 -1
- package/dist/focus-lifecycle.js +7 -7
- package/dist/focus-lifecycle.js.map +1 -1
- package/dist/focus-merge.d.ts +40 -0
- package/dist/focus-merge.d.ts.map +1 -1
- package/dist/focus-merge.js +84 -0
- package/dist/focus-merge.js.map +1 -1
- package/dist/focus-provisioning.js +7 -7
- package/dist/focus-provisioning.js.map +1 -1
- package/dist/focus-stage-lifecycle.d.ts +64 -1
- package/dist/focus-stage-lifecycle.d.ts.map +1 -1
- package/dist/focus-stage-lifecycle.js +140 -2
- package/dist/focus-stage-lifecycle.js.map +1 -1
- package/dist/listener.d.ts.map +1 -1
- package/dist/listener.js +9 -1
- package/dist/listener.js.map +1 -1
- package/dist/prompt-sections/role-sections.d.ts +8 -0
- package/dist/prompt-sections/role-sections.d.ts.map +1 -1
- package/dist/prompt-sections/role-sections.js +46 -11
- package/dist/prompt-sections/role-sections.js.map +1 -1
- package/dist/queries/deliveries.d.ts +17 -0
- package/dist/queries/deliveries.d.ts.map +1 -1
- package/dist/queries/deliveries.js +3 -0
- package/dist/queries/deliveries.js.map +1 -1
- package/dist/queries/focuses.d.ts +9 -0
- package/dist/queries/focuses.d.ts.map +1 -1
- package/dist/queries/focuses.js +14 -0
- package/dist/queries/focuses.js.map +1 -1
- package/dist/queries/local-models.d.ts +50 -0
- package/dist/queries/local-models.d.ts.map +1 -0
- package/dist/queries/local-models.js +57 -0
- package/dist/queries/local-models.js.map +1 -0
- package/dist/queries/schemas.d.ts +34 -0
- package/dist/queries/schemas.d.ts.map +1 -1
- package/dist/queries/schemas.js +36 -0
- package/dist/queries/schemas.js.map +1 -1
- package/dist/spawner/lifecycle.d.ts.map +1 -1
- package/dist/spawner/lifecycle.js +9 -6
- package/dist/spawner/lifecycle.js.map +1 -1
- package/dist/templates/claude-settings.d.ts +36 -1
- package/dist/templates/claude-settings.d.ts.map +1 -1
- package/dist/templates/claude-settings.js +63 -12
- package/dist/templates/claude-settings.js.map +1 -1
- package/package.json +2 -2
package/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commitSha": "
|
|
3
|
-
"builtAt": "2026-06-
|
|
2
|
+
"commitSha": "0f2fde1f",
|
|
3
|
+
"builtAt": "2026-06-16T04:14:48.203Z",
|
|
4
4
|
"expectedMigrations": [
|
|
5
5
|
"20250829113330_create_org_nodes_table.sql",
|
|
6
6
|
"20250829113402_fix_function_security_search_path.sql",
|
|
@@ -634,6 +634,13 @@
|
|
|
634
634
|
"20260614231203_product_requests_reopen_audit.sql",
|
|
635
635
|
"20260615103408_add_frt_statement_drafted.sql",
|
|
636
636
|
"20260615105344_add_verify_classification.sql",
|
|
637
|
-
"20260615132122_add_work_facing_to_org_nodes.sql"
|
|
637
|
+
"20260615132122_add_work_facing_to_org_nodes.sql",
|
|
638
|
+
"20260615222011_audit_playbooks_tree_authoring_discipline.sql",
|
|
639
|
+
"20260615225446_add_focus_ratification_signal.sql",
|
|
640
|
+
"20260615235758_local_models_registry.sql",
|
|
641
|
+
"20260616000657_focus_local_model_overrides.sql",
|
|
642
|
+
"20260616005744_harden_local_model_rpc_auth.sql",
|
|
643
|
+
"20260616032848_local_model_discovery_requests.sql",
|
|
644
|
+
"20260616035220_discovery_requests_claim_and_constraints.sql"
|
|
638
645
|
]
|
|
639
646
|
}
|
package/dist/audit-hooks.d.ts
CHANGED
|
@@ -9,4 +9,28 @@
|
|
|
9
9
|
* Used for read-only audit sessions.
|
|
10
10
|
*/
|
|
11
11
|
export declare function installAuditPreCommitHook(worktreePath: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Write (or merge into) the worktree's `.claude/settings.json` a write-deny
|
|
14
|
+
* overlay so a read-only audit team physically cannot Write/Edit or run
|
|
15
|
+
* write-shaped Bash.
|
|
16
|
+
*
|
|
17
|
+
* The daemon spawns agents with `--dangerously-skip-permissions
|
|
18
|
+
* --setting-sources project,local`, which (a) reads the worktree's
|
|
19
|
+
* `.claude/settings.json` (project source) and (b) still HARD-ENFORCES explicit
|
|
20
|
+
* `permissions.deny` entries (the bypass only auto-approves the *ask* tier).
|
|
21
|
+
* So a deny overlay here is the tool-layer enforcement of read-only mode --
|
|
22
|
+
* the pre-commit hook (installAuditPreCommitHook) is retained as
|
|
23
|
+
* defense-in-depth on top of it.
|
|
24
|
+
*
|
|
25
|
+
* Idempotent: re-running merges the deny list, deduplicated, producing no diff.
|
|
26
|
+
* MUST only be called for read-only focuses -- a writable focus's settings
|
|
27
|
+
* must never carry a `deny` key.
|
|
28
|
+
*/
|
|
29
|
+
export declare function writeReadOnlyDenyOverlay(worktreePath: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Install all read-only audit enforcement in a worktree: the commit-blocking
|
|
32
|
+
* pre-commit hook AND the write-deny settings overlay. Single entry point so
|
|
33
|
+
* every read-only worktree-setup site gets identical coverage.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installReadOnlyAuditGuards(worktreePath: string): void;
|
|
12
36
|
//# sourceMappingURL=audit-hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-hooks.d.ts","sourceRoot":"","sources":["../src/audit-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"audit-hooks.d.ts","sourceRoot":"","sources":["../src/audit-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAiCpE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CA0BnE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAGrE"}
|
package/dist/audit-hooks.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Installs a git pre-commit hook in a worktree that blocks all commits,
|
|
5
5
|
* providing an informative message about the read-only audit mode.
|
|
6
6
|
*/
|
|
7
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { runGitSync } from './git-types.js';
|
|
10
|
+
import { buildClaudeSettings, mergeClaudeSettings } from './templates/claude-settings.js';
|
|
10
11
|
/**
|
|
11
12
|
* Install a pre-commit hook in a worktree that blocks all commits.
|
|
12
13
|
* Used for read-only audit sessions.
|
|
@@ -42,4 +43,54 @@ export function installAuditPreCommitHook(worktreePath) {
|
|
|
42
43
|
// Point this worktree's git config at the custom hooks directory
|
|
43
44
|
runGitSync(['config', 'core.hooksPath', hooksDir], worktreePath);
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Write (or merge into) the worktree's `.claude/settings.json` a write-deny
|
|
48
|
+
* overlay so a read-only audit team physically cannot Write/Edit or run
|
|
49
|
+
* write-shaped Bash.
|
|
50
|
+
*
|
|
51
|
+
* The daemon spawns agents with `--dangerously-skip-permissions
|
|
52
|
+
* --setting-sources project,local`, which (a) reads the worktree's
|
|
53
|
+
* `.claude/settings.json` (project source) and (b) still HARD-ENFORCES explicit
|
|
54
|
+
* `permissions.deny` entries (the bypass only auto-approves the *ask* tier).
|
|
55
|
+
* So a deny overlay here is the tool-layer enforcement of read-only mode --
|
|
56
|
+
* the pre-commit hook (installAuditPreCommitHook) is retained as
|
|
57
|
+
* defense-in-depth on top of it.
|
|
58
|
+
*
|
|
59
|
+
* Idempotent: re-running merges the deny list, deduplicated, producing no diff.
|
|
60
|
+
* MUST only be called for read-only focuses -- a writable focus's settings
|
|
61
|
+
* must never carry a `deny` key.
|
|
62
|
+
*/
|
|
63
|
+
export function writeReadOnlyDenyOverlay(worktreePath) {
|
|
64
|
+
const dir = join(worktreePath, '.claude');
|
|
65
|
+
if (!existsSync(dir)) {
|
|
66
|
+
mkdirSync(dir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
const settingsPath = join(dir, 'settings.json');
|
|
69
|
+
let existing = null;
|
|
70
|
+
if (existsSync(settingsPath)) {
|
|
71
|
+
try {
|
|
72
|
+
const parsed = JSON.parse(readFileSync(settingsPath, 'utf-8'));
|
|
73
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
74
|
+
existing = parsed;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
// Corrupt settings file -- log and overwrite with the deny overlay rather
|
|
79
|
+
// than leave a read-only worktree without enforcement.
|
|
80
|
+
console.warn(`[audit-hooks] Existing ${settingsPath} is not valid JSON, overwriting with read-only overlay: ` +
|
|
81
|
+
`${err instanceof Error ? err.message : String(err)}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const merged = mergeClaudeSettings(existing, buildClaudeSettings({ readOnly: true }));
|
|
85
|
+
writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + '\n');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Install all read-only audit enforcement in a worktree: the commit-blocking
|
|
89
|
+
* pre-commit hook AND the write-deny settings overlay. Single entry point so
|
|
90
|
+
* every read-only worktree-setup site gets identical coverage.
|
|
91
|
+
*/
|
|
92
|
+
export function installReadOnlyAuditGuards(worktreePath) {
|
|
93
|
+
installAuditPreCommitHook(worktreePath);
|
|
94
|
+
writeReadOnlyDenyOverlay(worktreePath);
|
|
95
|
+
}
|
|
45
96
|
//# sourceMappingURL=audit-hooks.js.map
|
package/dist/audit-hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-hooks.js","sourceRoot":"","sources":["../src/audit-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"audit-hooks.js","sourceRoot":"","sources":["../src/audit-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1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AAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;YAC/D,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnE,QAAQ,GAAG,MAAiC,CAAC;YAC/C,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,0EAA0E;YAC1E,uDAAuD;YACvD,OAAO,CAAC,IAAI,CACV,0BAA0B,YAAY,0DAA0D;gBAC9F,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtF,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,YAAoB;IAC7D,yBAAyB,CAAC,YAAY,CAAC,CAAC;IACxC,wBAAwB,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/audit-phase.d.ts
CHANGED
|
@@ -22,10 +22,25 @@ import type { DaemonConfig } from './types.js';
|
|
|
22
22
|
* code-level diff, then the live graph it must reconcile.
|
|
23
23
|
*/
|
|
24
24
|
export declare const AUDIT_ASSEMBLY_RECIPE: readonly string[];
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* MCP tool names the assessor session is permitted to call.
|
|
27
|
+
*
|
|
28
|
+
* The audit is READ-ONLY w.r.t. code but AUTHORS intent structure: a CRT
|
|
29
|
+
* (entities + UDEs) plus an FRT of injections, self-validated via
|
|
30
|
+
* telora_reality_tree action=derive_frt (read-only, carried on the
|
|
31
|
+
* telora_reality_tree tool), then anchored to planning deliveries via
|
|
32
|
+
* telora_product_delivery create (injectionNodeId + executionStatus). It must
|
|
33
|
+
* NOT touch workflow state otherwise, and must NOT file remediation issues.
|
|
34
|
+
*/
|
|
26
35
|
export declare const AUDIT_MCP_TOOLS: readonly string[];
|
|
27
|
-
/**
|
|
28
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Default Claude model for the audit assessor. Override via deps.
|
|
38
|
+
* Opus: the audit authors a navigable causal tree + injection plan a human
|
|
39
|
+
* reviews before any fix runs -- the reasoning depth (root-cause attribution,
|
|
40
|
+
* FRT self-validation) warrants the stronger model. Matched as a substring by
|
|
41
|
+
* the telemetry pricing table (see spawner/lifecycle AUDIT_CAPTURE_MODEL).
|
|
42
|
+
*/
|
|
43
|
+
export declare const AUDIT_DEFAULT_MODEL = "opus";
|
|
29
44
|
/** Default timeout for the assessor session (15 minutes). */
|
|
30
45
|
export declare const AUDIT_DEFAULT_TIMEOUT_MS: number;
|
|
31
46
|
/**
|
|
@@ -35,9 +50,18 @@ export declare const AUDIT_DEFAULT_TIMEOUT_MS: number;
|
|
|
35
50
|
*/
|
|
36
51
|
export declare const AUDIT_LINEAGE = "audit";
|
|
37
52
|
/**
|
|
38
|
-
* Audit prompt
|
|
39
|
-
*
|
|
40
|
-
*
|
|
53
|
+
* Audit prompt: the tree-authoring discipline for the read-only audit
|
|
54
|
+
* assessor. The assessor authors a CRT + an FRT of injections and anchors a
|
|
55
|
+
* navigable plan a human reviews BEFORE any fix runs -- it never emits a flat
|
|
56
|
+
* remediation task checklist.
|
|
57
|
+
*
|
|
58
|
+
* CANONICAL SOURCE OF TRUTH for this guidance is the MCP-package constant
|
|
59
|
+
* AUDIT_TREE_AUTHORING_GUIDE in
|
|
60
|
+
* mcp/telora-products/src/handlers/auditTreeAuthoringGuide.ts (surfaced inline
|
|
61
|
+
* by telora_discover when the reality-tree domain loads). The daemon cannot
|
|
62
|
+
* runtime-import the MCP package (no cross-package runtime import), so the
|
|
63
|
+
* prose is duplicated here; keep the two in sync. The audit-summary tail block
|
|
64
|
+
* is daemon-specific (parsed by parseAuditSummary) and lives only here.
|
|
41
65
|
*/
|
|
42
66
|
export declare const AUDIT_PROMPT: string;
|
|
43
67
|
export interface AuditPhaseResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-phase.d.ts","sourceRoot":"","sources":["../src/audit-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3F,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAQlD,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"audit-phase.d.ts","sourceRoot":"","sources":["../src/audit-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3F,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C;;;;;GAKG;AACH,eAAO,MAAM,qBA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AAY,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9I,qBAAqB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,eAAe,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACxE,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC;IACrD,SAAS,EAAE,MAAM,YAAY,CAAC;IAC9B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClF,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3F;AAMD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CA4C9D;AA+BD,eAAO,MAAM,gBAAgB,EAAE,cAkB9B,CAAC;AAMF;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,cAAiC,GACtC,OAAO,CAAC,gBAAgB,CAAC,CA2H3B"}
|
package/dist/audit-phase.js
CHANGED
|
@@ -37,15 +37,31 @@ export const AUDIT_ASSEMBLY_RECIPE = [
|
|
|
37
37
|
'agent_escalations',
|
|
38
38
|
'reality_tree.snapshot',
|
|
39
39
|
];
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* MCP tool names the assessor session is permitted to call.
|
|
42
|
+
*
|
|
43
|
+
* The audit is READ-ONLY w.r.t. code but AUTHORS intent structure: a CRT
|
|
44
|
+
* (entities + UDEs) plus an FRT of injections, self-validated via
|
|
45
|
+
* telora_reality_tree action=derive_frt (read-only, carried on the
|
|
46
|
+
* telora_reality_tree tool), then anchored to planning deliveries via
|
|
47
|
+
* telora_product_delivery create (injectionNodeId + executionStatus). It must
|
|
48
|
+
* NOT touch workflow state otherwise, and must NOT file remediation issues.
|
|
49
|
+
*/
|
|
41
50
|
export const AUDIT_MCP_TOOLS = [
|
|
42
51
|
'mcp__telora-products__telora_reality_tree',
|
|
43
52
|
'mcp__telora-products__telora_reality_tree_node',
|
|
44
53
|
'mcp__telora-products__telora_reality_tree_edge',
|
|
45
54
|
'mcp__telora-products__telora_reality_tree_link',
|
|
55
|
+
'mcp__telora-products__telora_product_delivery',
|
|
46
56
|
];
|
|
47
|
-
/**
|
|
48
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Default Claude model for the audit assessor. Override via deps.
|
|
59
|
+
* Opus: the audit authors a navigable causal tree + injection plan a human
|
|
60
|
+
* reviews before any fix runs -- the reasoning depth (root-cause attribution,
|
|
61
|
+
* FRT self-validation) warrants the stronger model. Matched as a substring by
|
|
62
|
+
* the telemetry pricing table (see spawner/lifecycle AUDIT_CAPTURE_MODEL).
|
|
63
|
+
*/
|
|
64
|
+
export const AUDIT_DEFAULT_MODEL = 'opus';
|
|
49
65
|
/** Default timeout for the assessor session (15 minutes). */
|
|
50
66
|
export const AUDIT_DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
51
67
|
/**
|
|
@@ -55,25 +71,37 @@ export const AUDIT_DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
|
55
71
|
*/
|
|
56
72
|
export const AUDIT_LINEAGE = 'audit';
|
|
57
73
|
/**
|
|
58
|
-
* Audit prompt
|
|
59
|
-
*
|
|
60
|
-
*
|
|
74
|
+
* Audit prompt: the tree-authoring discipline for the read-only audit
|
|
75
|
+
* assessor. The assessor authors a CRT + an FRT of injections and anchors a
|
|
76
|
+
* navigable plan a human reviews BEFORE any fix runs -- it never emits a flat
|
|
77
|
+
* remediation task checklist.
|
|
78
|
+
*
|
|
79
|
+
* CANONICAL SOURCE OF TRUTH for this guidance is the MCP-package constant
|
|
80
|
+
* AUDIT_TREE_AUTHORING_GUIDE in
|
|
81
|
+
* mcp/telora-products/src/handlers/auditTreeAuthoringGuide.ts (surfaced inline
|
|
82
|
+
* by telora_discover when the reality-tree domain loads). The daemon cannot
|
|
83
|
+
* runtime-import the MCP package (no cross-package runtime import), so the
|
|
84
|
+
* prose is duplicated here; keep the two in sync. The audit-summary tail block
|
|
85
|
+
* is daemon-specific (parsed by parseAuditSummary) and lives only here.
|
|
61
86
|
*/
|
|
62
87
|
export const AUDIT_PROMPT = [
|
|
63
|
-
'You are the
|
|
88
|
+
'You are the read-only reality-tree audit assessor for a Telora focus.',
|
|
89
|
+
'',
|
|
90
|
+
'A safe audit emits a TREE and a PLAN, never a task checklist. You are READ-ONLY with respect to code: discovery only. You author the intent structure -- the current reality, its root causes, and the leverage points -- and you anchor a plan a human reviews BEFORE any fix runs. You do NOT fix anything, and you do NOT file remediation Task or Bug issues. Remediation is scoped LATER, one root cause at a time, from the injections you anchor here -- so there is no flat checklist to complete with completion-vigor and churn stays bounded to the real defects.',
|
|
91
|
+
'',
|
|
92
|
+
'Work in rounds:',
|
|
93
|
+
'',
|
|
94
|
+
'1. Facts -> CRT. Author the current reality. Create the focus reality tree if none exists (telora_reality_tree action=create), then add an entity node per real component/observation and an undesired_effect (UDE) node per observed problem (telora_reality_tree_node action=create). State what IS, in evidence terms -- not a fix.',
|
|
95
|
+
'',
|
|
96
|
+
'2. Relationships -> causal edges. Wire cause -> effect with telora_reality_tree_edge action=create (cause node -> effect node). This is the load-bearing round: edges turn a list of symptoms into a causal structure, so a single deep cause feeding many surface UDEs across different audit areas becomes visible as ONE root in ONE tree -- which stops "one delivery per area" sprawl.',
|
|
64
97
|
'',
|
|
65
|
-
'
|
|
98
|
+
'3. Leverage -> injections. Propose injection nodes at the LOWEST / root causes (the nodes with the most downstream UDEs), not at the symptoms. One injection at a root can clear a whole subtree of UDEs.',
|
|
66
99
|
'',
|
|
67
|
-
'
|
|
100
|
+
'4. Self-validate -> derive_frt. Call telora_reality_tree action=derive_frt with the treeId. This is read-only: it returns the cleared/flipped UDE sets the injections produce. Confirm each injection flips the UDEs you targeted. If a UDE is left unresolved by your injection set, REPORT it in the summary -- do not hide it and do not lower the bar to make the tree look clean.',
|
|
68
101
|
'',
|
|
69
|
-
'
|
|
70
|
-
'- Add or refresh evidence on an entity node when the diff shows a related change.',
|
|
71
|
-
'- Retire an injection node (set status=verified, run reality_tree_node verify) when the FRT overlay is observably true.',
|
|
72
|
-
'- Add a new entity node for an observation the tree does not yet capture.',
|
|
73
|
-
'- Flip a UDE to a desired_effect via the verify mutation when the targeted injection has retired and reality has shifted.',
|
|
74
|
-
'- Adjust an edge when a dependency appears or dissolves.',
|
|
102
|
+
'5. Anchor the plan -> injection-anchored deliveries. For each injection, create a remediation delivery with telora_product_delivery action=create, passing injectionNodeId=<the injection node> and executionStatus="planning". Set its acceptance to the FRT desired effect -- the future-state the injection produces (what becomes true once the root cause is cleared), NOT a list of edits. This is the navigable plan the human reviews before anything executes.',
|
|
75
103
|
'',
|
|
76
|
-
'Do NOT
|
|
104
|
+
'Explicitly: your output is the tree + the anchored planning deliveries ONLY. Do NOT create remediation Task or Bug issues during the audit. Do NOT create one delivery per audit area -- unify the audit into ONE focus tree and let each injection (each root cause) anchor exactly one planning delivery. Do NOT mutate workflow state beyond creating those planning deliveries, and do NOT attempt fixes.',
|
|
77
105
|
'',
|
|
78
106
|
'When you are done, emit ONE fenced markdown block as the very last thing in your output, exactly in this shape (do not skip any field):',
|
|
79
107
|
'',
|
|
@@ -81,10 +109,10 @@ export const AUDIT_PROMPT = [
|
|
|
81
109
|
'nodes_touched: <integer>',
|
|
82
110
|
'edges_touched: <integer>',
|
|
83
111
|
'summary: |',
|
|
84
|
-
' <markdown narrative -- one bullet per
|
|
112
|
+
' <markdown narrative -- one bullet per UDE/injection/anchored delivery, with seq numbers; call out any UDE left unresolved by derive_frt>',
|
|
85
113
|
'```',
|
|
86
114
|
'',
|
|
87
|
-
'If you
|
|
115
|
+
'If you author nothing (the tree already reflects reality and needs no new injections), still emit the block with nodes_touched: 0 / edges_touched: 0 and a one-line summary explaining why.',
|
|
88
116
|
].join('\n');
|
|
89
117
|
// ---------------------------------------------------------------------------
|
|
90
118
|
// Summary parser
|
package/dist/audit-phase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-phase.js","sourceRoot":"","sources":["../src/audit-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,sBAAsB,CAAC;AACnF,oEAAoE;AACpE,OAAO,yBAAyB,CAAC;AACjC,OAAO,EACL,6BAA6B,GAE9B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACL,eAAe,IAAI,sBAAsB,GAG1C,MAAM,oBAAoB,CAAC;AAG5B,8EAA8E;AAC9E,0CAA0C;AAC1C,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,eAAe;IACf,oBAAoB;IACpB,+CAA+C;IAC/C,uBAAuB;IACvB,yBAAyB;IACzB,mBAAmB;IACnB,uBAAuB;CACxB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"audit-phase.js","sourceRoot":"","sources":["../src/audit-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,sBAAsB,CAAC;AACnF,oEAAoE;AACpE,OAAO,yBA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,SAAS,KAAK,IAAI,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;IACD,QAAQ,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC7C,QAAQ,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAE7C,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,cAAc,CAAC;gBACxB,UAAU;gBACV,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,YAAY,EAAE,OAAO,CAAC,YAAY;aACnC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,qBAAsB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,OAAO;YACL,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE,eAAe,WAAW,mBAAmB,MAAM,CAAC,MAAM,WAAW;YAChF,QAAQ;SACT,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,UAAU;QACnB,SAAS,EAAE,eAAe,WAAW,OAAO,OAAO,CAAC,YAAY,mBAAmB,OAAO,CAAC,YAAY,gBAAgB;QACvH,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -39,6 +39,14 @@ export interface CodexLocalCoords {
|
|
|
39
39
|
* 0.133 dropped chat-completions, so we always emit "responses".
|
|
40
40
|
*/
|
|
41
41
|
wireApi?: string;
|
|
42
|
+
/**
|
|
43
|
+
* NAME of the env var holding this server's API key. The VALUE is never
|
|
44
|
+
* written -- only this name lands in config.toml's env_key, so Codex resolves
|
|
45
|
+
* the secret from the environment. Defaults to TELORA_LOCAL_API_KEY_ENV when
|
|
46
|
+
* absent (single-server back-compat). A registry with many servers each set
|
|
47
|
+
* their own name so different servers resolve different keys.
|
|
48
|
+
*/
|
|
49
|
+
apiKeyEnv?: string;
|
|
42
50
|
}
|
|
43
51
|
export interface CodexProvisionIO {
|
|
44
52
|
out?: (msg: string) => void;
|
|
@@ -65,6 +73,26 @@ export declare function resolveProductCodexHome(productId: string): string;
|
|
|
65
73
|
* Throws if baseUrl or model contains a double-quote, backslash, or newline.
|
|
66
74
|
*/
|
|
67
75
|
export declare function renderCodexConfigToml(coords: CodexLocalCoords): string;
|
|
76
|
+
/**
|
|
77
|
+
* The env var NAME to write into config.toml's env_key. A registry model's
|
|
78
|
+
* api_key_env (when set) wins so each server resolves its own key; absent =>
|
|
79
|
+
* the single-server default (TELORA_LOCAL_API_KEY). Empty/blank => default.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveApiKeyEnv(apiKeyEnv?: string | null): string;
|
|
82
|
+
/**
|
|
83
|
+
* Resolve the ISOLATED per-model CODEX_HOME directory under the daemon's global
|
|
84
|
+
* state dir: `<stateDir>/codex/models/<localModelId>`. CWD-independent; honors
|
|
85
|
+
* $TELORA_STATE_DIR via resolveGlobalStateDir(). Keyed by the local_models row
|
|
86
|
+
* id so two passes selecting the same model share one home and different models
|
|
87
|
+
* get distinct homes. Does NOT create the directory.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveLocalModelCodexHome(localModelId: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Write the rendered config.toml into a per-model CODEX_HOME (keyed by the
|
|
92
|
+
* local_models row id). Same security invariants as writeProductCodexHome:
|
|
93
|
+
* 0700 dir, 0600 file, key VALUE never written. Idempotent.
|
|
94
|
+
*/
|
|
95
|
+
export declare function writeLocalModelCodexHome(localModelId: string, coords: CodexLocalCoords, io?: CodexProvisionIO): WriteProductCodexHomeResult;
|
|
68
96
|
/**
|
|
69
97
|
* Write the rendered config.toml into the per-product CODEX_HOME.
|
|
70
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-provision.d.ts","sourceRoot":"","sources":["../../src/cli/codex-provision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"codex-provision.d.ts","sourceRoot":"","sources":["../../src/cli/codex-provision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,2BAA2B;IAC1C,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;CACpB;AAeD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgBtE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGlE;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,gBAAgB,EACxB,EAAE,CAAC,EAAE,gBAAgB,GACpB,2BAA2B,CAU7B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,EACxB,EAAE,CAAC,EAAE,gBAAgB,GACpB,2BAA2B,CAU7B;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAczE"}
|
|
@@ -58,6 +58,8 @@ export function resolveProductCodexHome(productId) {
|
|
|
58
58
|
export function renderCodexConfigToml(coords) {
|
|
59
59
|
assertTomlSafe('baseUrl', coords.baseUrl);
|
|
60
60
|
assertTomlSafe('model', coords.model);
|
|
61
|
+
const envKey = resolveApiKeyEnv(coords.apiKeyEnv);
|
|
62
|
+
assertTomlSafe('apiKeyEnv', envKey);
|
|
61
63
|
return (`model = "${coords.model}"\n` +
|
|
62
64
|
`model_provider = "${TELORA_LOCAL_PROVIDER_ID}"\n` +
|
|
63
65
|
`\n` +
|
|
@@ -65,7 +67,39 @@ export function renderCodexConfigToml(coords) {
|
|
|
65
67
|
`name = "Telora Local"\n` +
|
|
66
68
|
`base_url = "${coords.baseUrl}"\n` +
|
|
67
69
|
`wire_api = "responses"\n` +
|
|
68
|
-
`env_key = "${
|
|
70
|
+
`env_key = "${envKey}"\n`);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The env var NAME to write into config.toml's env_key. A registry model's
|
|
74
|
+
* api_key_env (when set) wins so each server resolves its own key; absent =>
|
|
75
|
+
* the single-server default (TELORA_LOCAL_API_KEY). Empty/blank => default.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveApiKeyEnv(apiKeyEnv) {
|
|
78
|
+
const trimmed = typeof apiKeyEnv === 'string' ? apiKeyEnv.trim() : '';
|
|
79
|
+
return trimmed.length > 0 ? trimmed : TELORA_LOCAL_API_KEY_ENV;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the ISOLATED per-model CODEX_HOME directory under the daemon's global
|
|
83
|
+
* state dir: `<stateDir>/codex/models/<localModelId>`. CWD-independent; honors
|
|
84
|
+
* $TELORA_STATE_DIR via resolveGlobalStateDir(). Keyed by the local_models row
|
|
85
|
+
* id so two passes selecting the same model share one home and different models
|
|
86
|
+
* get distinct homes. Does NOT create the directory.
|
|
87
|
+
*/
|
|
88
|
+
export function resolveLocalModelCodexHome(localModelId) {
|
|
89
|
+
return resolve(resolveGlobalStateDir(), 'codex', 'models', localModelId);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Write the rendered config.toml into a per-model CODEX_HOME (keyed by the
|
|
93
|
+
* local_models row id). Same security invariants as writeProductCodexHome:
|
|
94
|
+
* 0700 dir, 0600 file, key VALUE never written. Idempotent.
|
|
95
|
+
*/
|
|
96
|
+
export function writeLocalModelCodexHome(localModelId, coords, io) {
|
|
97
|
+
const codexHome = resolveLocalModelCodexHome(localModelId);
|
|
98
|
+
mkdirSync(codexHome, { recursive: true, mode: 0o700 });
|
|
99
|
+
const configPath = resolve(codexHome, 'config.toml');
|
|
100
|
+
writeFileSync(configPath, renderCodexConfigToml(coords), { mode: 0o600 });
|
|
101
|
+
io?.out?.(`Wrote Codex profile to ${configPath} (CODEX_HOME=${codexHome}).\n`);
|
|
102
|
+
return { codexHome, configPath };
|
|
69
103
|
}
|
|
70
104
|
/**
|
|
71
105
|
* Write the rendered config.toml into the per-product CODEX_HOME.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-provision.js","sourceRoot":"","sources":["../../src/cli/codex-provision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"codex-provision.js","sourceRoot":"","sources":["../../src/cli/codex-provision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC;AAqCvD;;;;GAIG;AACH,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IAClD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAChG,MAAM,IAAI,KAAK,CACb,WAAW,KAAK,2DAA2D,CAC5E,CAAC;IAC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A+B;QACjE,IAAI;QACJ,oFAAoF;QACpF,iFAAiF;QACjF,4BAA4B,CAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pristine-at-exit assertion for read-only audit focuses.
|
|
3
|
+
*
|
|
4
|
+
* A read-only audit focus is supposed to leave the worktree exactly as it found
|
|
5
|
+
* it -- discovery only, no file modifications. The write-deny settings overlay
|
|
6
|
+
* (templates/claude-settings -> audit-hooks) makes this physically true at the
|
|
7
|
+
* tool layer, and the pre-commit hook blocks commits. This module is the
|
|
8
|
+
* completion-side backstop: when a read-only team exits, assert the worktree is
|
|
9
|
+
* pristine; if it is NOT, file a (dedup-aware) escalation so an operator sees
|
|
10
|
+
* that a read-only audit modified files it shouldn't have.
|
|
11
|
+
*
|
|
12
|
+
* Modeled on delivery-advance-block.ts `ensureWorktreeCommittedBeforeAdvance`:
|
|
13
|
+
* dependency-injected collaborators, durable dedup via
|
|
14
|
+
* `hasOpenEscalationForDelivery`, fail-open lookup.
|
|
15
|
+
*
|
|
16
|
+
* @module completion/read-only-pristine
|
|
17
|
+
*/
|
|
18
|
+
import { createEscalation, hasOpenEscalationForDelivery } from '../supabase.js';
|
|
19
|
+
import { worktreeHasUncommittedChanges } from '../worktree-safety.js';
|
|
20
|
+
/**
|
|
21
|
+
* escalation_kind discriminator for the read-only-pristine violation.
|
|
22
|
+
*
|
|
23
|
+
* Reuses ADVANCE_BLOCKED -- the violation is "the daemon refuses to advance /
|
|
24
|
+
* merge this focus because its worktree is not in the expected (pristine)
|
|
25
|
+
* state", the same class as the uncommitted-changes advance block. Keeps the
|
|
26
|
+
* dedup keyed on a kind already in the escalation_kind CHECK set without a
|
|
27
|
+
* schema change.
|
|
28
|
+
*/
|
|
29
|
+
export declare const READ_ONLY_PRISTINE_ESCALATION_KIND: "advance_blocked";
|
|
30
|
+
/**
|
|
31
|
+
* Injectable collaborators for assertReadOnlyWorktreePristine. Defaults to the
|
|
32
|
+
* real implementations; tests override them to drive the violation path without
|
|
33
|
+
* a live worktree or Supabase.
|
|
34
|
+
*/
|
|
35
|
+
export interface AssertReadOnlyPristineDeps {
|
|
36
|
+
worktreeHasUncommittedChanges?: typeof worktreeHasUncommittedChanges;
|
|
37
|
+
createEscalation?: typeof createEscalation;
|
|
38
|
+
hasOpenEscalationForDelivery?: typeof hasOpenEscalationForDelivery;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Assert that a read-only focus's worktree is pristine at team exit.
|
|
42
|
+
*
|
|
43
|
+
* Returns pristine=true when the worktree has no uncommitted changes (or no
|
|
44
|
+
* worktree path is known). Returns pristine=false and files a dedup-aware
|
|
45
|
+
* escalation when uncommitted changes are present -- the caller then reverts the
|
|
46
|
+
* dirty tree and skips the merge.
|
|
47
|
+
*
|
|
48
|
+
* Dedup: at most ONE open escalation per delivery (queried via
|
|
49
|
+
* hasOpenEscalationForDelivery on the ADVANCE_BLOCKED kind). Fail-open on the
|
|
50
|
+
* lookup so a genuine first violation is never silently swallowed.
|
|
51
|
+
*/
|
|
52
|
+
export declare function assertReadOnlyWorktreePristine(params: {
|
|
53
|
+
worktreePath: string | null | undefined;
|
|
54
|
+
organizationId: string;
|
|
55
|
+
sessionId: string | null;
|
|
56
|
+
deliveryId: string;
|
|
57
|
+
focusId: string;
|
|
58
|
+
focusName: string;
|
|
59
|
+
branchName: string;
|
|
60
|
+
}, deps?: AssertReadOnlyPristineDeps): Promise<{
|
|
61
|
+
pristine: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
//# sourceMappingURL=read-only-pristine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-only-pristine.d.ts","sourceRoot":"","sources":["../../src/completion/read-only-pristine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,mBAAmC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,6BAA6B,CAAC,EAAE,OAAO,6BAA6B,CAAC;IACrE,gBAAgB,CAAC,EAAE,OAAO,gBAAgB,CAAC;IAC3C,4BAA4B,CAAC,EAAE,OAAO,4BAA4B,CAAC;CACpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE;IACN,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,EACD,IAAI,GAAE,0BAA+B,GACpC,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CA0DhC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pristine-at-exit assertion for read-only audit focuses.
|
|
3
|
+
*
|
|
4
|
+
* A read-only audit focus is supposed to leave the worktree exactly as it found
|
|
5
|
+
* it -- discovery only, no file modifications. The write-deny settings overlay
|
|
6
|
+
* (templates/claude-settings -> audit-hooks) makes this physically true at the
|
|
7
|
+
* tool layer, and the pre-commit hook blocks commits. This module is the
|
|
8
|
+
* completion-side backstop: when a read-only team exits, assert the worktree is
|
|
9
|
+
* pristine; if it is NOT, file a (dedup-aware) escalation so an operator sees
|
|
10
|
+
* that a read-only audit modified files it shouldn't have.
|
|
11
|
+
*
|
|
12
|
+
* Modeled on delivery-advance-block.ts `ensureWorktreeCommittedBeforeAdvance`:
|
|
13
|
+
* dependency-injected collaborators, durable dedup via
|
|
14
|
+
* `hasOpenEscalationForDelivery`, fail-open lookup.
|
|
15
|
+
*
|
|
16
|
+
* @module completion/read-only-pristine
|
|
17
|
+
*/
|
|
18
|
+
import { createEscalation, hasOpenEscalationForDelivery } from '../supabase.js';
|
|
19
|
+
import { withRetry, ESCALATION_REASONS, ESCALATION_DISPOSITIONS, ESCALATION_KINDS } from '@telora/daemon-core';
|
|
20
|
+
import { worktreeHasUncommittedChanges } from '../worktree-safety.js';
|
|
21
|
+
/**
|
|
22
|
+
* escalation_kind discriminator for the read-only-pristine violation.
|
|
23
|
+
*
|
|
24
|
+
* Reuses ADVANCE_BLOCKED -- the violation is "the daemon refuses to advance /
|
|
25
|
+
* merge this focus because its worktree is not in the expected (pristine)
|
|
26
|
+
* state", the same class as the uncommitted-changes advance block. Keeps the
|
|
27
|
+
* dedup keyed on a kind already in the escalation_kind CHECK set without a
|
|
28
|
+
* schema change.
|
|
29
|
+
*/
|
|
30
|
+
export const READ_ONLY_PRISTINE_ESCALATION_KIND = ESCALATION_KINDS.ADVANCE_BLOCKED;
|
|
31
|
+
/**
|
|
32
|
+
* Assert that a read-only focus's worktree is pristine at team exit.
|
|
33
|
+
*
|
|
34
|
+
* Returns pristine=true when the worktree has no uncommitted changes (or no
|
|
35
|
+
* worktree path is known). Returns pristine=false and files a dedup-aware
|
|
36
|
+
* escalation when uncommitted changes are present -- the caller then reverts the
|
|
37
|
+
* dirty tree and skips the merge.
|
|
38
|
+
*
|
|
39
|
+
* Dedup: at most ONE open escalation per delivery (queried via
|
|
40
|
+
* hasOpenEscalationForDelivery on the ADVANCE_BLOCKED kind). Fail-open on the
|
|
41
|
+
* lookup so a genuine first violation is never silently swallowed.
|
|
42
|
+
*/
|
|
43
|
+
export async function assertReadOnlyWorktreePristine(params, deps = {}) {
|
|
44
|
+
const hasUncommitted = deps.worktreeHasUncommittedChanges ?? worktreeHasUncommittedChanges;
|
|
45
|
+
const createEsc = deps.createEscalation ?? createEscalation;
|
|
46
|
+
const hasOpenEsc = deps.hasOpenEscalationForDelivery ?? hasOpenEscalationForDelivery;
|
|
47
|
+
const { worktreePath, organizationId, sessionId, deliveryId, focusId, focusName, branchName } = params;
|
|
48
|
+
if (!worktreePath || !hasUncommitted(worktreePath)) {
|
|
49
|
+
return { pristine: true };
|
|
50
|
+
}
|
|
51
|
+
console.warn(`[focus-executor] READ-ONLY PRISTINE VIOLATION: audit "${focusName}" left uncommitted changes in ${worktreePath}.`);
|
|
52
|
+
// Durable dedup: skip filing if an open escalation already exists for this
|
|
53
|
+
// delivery. Fail open -- a lookup error proceeds to file.
|
|
54
|
+
let alreadyOpen = false;
|
|
55
|
+
try {
|
|
56
|
+
alreadyOpen = await hasOpenEsc(deliveryId, READ_ONLY_PRISTINE_ESCALATION_KIND);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.warn(`[focus-executor] Open read-only-pristine escalation lookup failed for "${focusName}", proceeding to file: ${err.message}`);
|
|
60
|
+
}
|
|
61
|
+
if (alreadyOpen) {
|
|
62
|
+
return { pristine: false };
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
await withRetry(() => createEsc({
|
|
66
|
+
organizationId,
|
|
67
|
+
sessionId: sessionId ?? '',
|
|
68
|
+
issueId: null,
|
|
69
|
+
reasonType: ESCALATION_REASONS.ERROR_ENCOUNTERED,
|
|
70
|
+
disposition: ESCALATION_DISPOSITIONS.NEEDS_OPERATOR,
|
|
71
|
+
escalationKind: READ_ONLY_PRISTINE_ESCALATION_KIND,
|
|
72
|
+
anchor: { deliveryId, focusId, branch: branchName },
|
|
73
|
+
description: `Read-only audit "${focusName}" left uncommitted changes in its worktree.\n\n` +
|
|
74
|
+
`A read-only audit focus must leave the worktree pristine (discovery ` +
|
|
75
|
+
`only -- no file modifications). The daemon has reverted the changes ` +
|
|
76
|
+
`and will NOT merge this focus. Review what the audit modified.`,
|
|
77
|
+
whatWasTried: 'On read-only team exit the daemon ran `git status --porcelain` and found uncommitted changes in the focus worktree, which a read-only audit must never produce.',
|
|
78
|
+
helpNeeded: `Inspect the audit session for "${focusName}"; the worktree at ${worktreePath} has been reverted. No merge was performed.`,
|
|
79
|
+
}), { maxAttempts: 3, label: 'escalation-read-only-pristine' });
|
|
80
|
+
console.log(`[focus-executor] Filed read-only-pristine escalation for "${focusName}"`);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
console.error(`[focus-executor] Failed to file read-only-pristine escalation for "${focusName}": ${err.message}`);
|
|
84
|
+
}
|
|
85
|
+
return { pristine: false };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=read-only-pristine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-only-pristine.js","sourceRoot":"","sources":["../../src/completion/read-only-pristine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/G,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,gBAAgB,CAAC,eAAe,CAAC;AAanF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,MAQC,EACD,OAAmC,EAAE;IAErC,MAAM,cAAc,GAAG,IAAI,CAAC,6BAA6B,IAAI,6BAA6B,CAAC;IAC3F,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC;IAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,4BAA4B,IAAI,4BAA4B,CAAC;IAErF,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAEvG,IAAI,C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