@starci/hfs 4.7.47 → 4.9.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -9
  3. package/emit/operation-schemas.mjs +3 -0
  4. package/lint/bound-sys.cjs +2 -2
  5. package/package.json +11 -5
  6. package/runtime/engine/admission.mjs +1 -1
  7. package/runtime/engine/config.mjs +2 -2
  8. package/runtime/engine/db/machine.mjs +2 -3
  9. package/runtime/engine/invalid-config.mjs +1 -1
  10. package/runtime/knowledge/grammars/{starci → core}/playbook.yaml +3 -3
  11. package/runtime/knowledge/grammars/index.yaml +14 -23
  12. package/runtime/knowledge/grammars/offset-pop/playbook.yaml +2 -2
  13. package/runtime/knowledge/hfs/canon-pins.yaml +23 -23
  14. package/runtime/knowledge/hfs/fe-stack.yaml +1 -1
  15. package/runtime/knowledge/hfs/rules.yaml +83 -60
  16. package/runtime/modules/kernel/failure-codes.yaml +23 -13
  17. package/runtime/scripts/guards/git-policy.mjs +2 -3
  18. package/runtime/scripts/hfs/rule-catalog.mjs +2 -2
  19. package/runtime/scripts/hfs/rules/pipeline.mjs +5 -5
  20. package/runtime/scripts/lib/example-refs.mjs +10 -3
  21. package/runtime/scripts/lib/grammar-lint.mjs +16 -3
  22. package/runtime/scripts/lib/package-at.mjs +5 -6
  23. package/runtime/scripts/lib/roots.mjs +2 -2
  24. package/runtime/scripts/work/draw/draw-dna-findings.mjs +23 -12
  25. package/runtime/scripts/work/draw/draw-dna.mjs +14 -8
  26. package/scaffold/app.mjs +6 -6
  27. package/src/main.mjs +3 -3
  28. package/sync/hygiene.mjs +1 -1
  29. package/sync/index.mjs +15 -2
  30. package/sync/managed.mjs +3 -2
  31. package/templates/app/codegen-graphql.mjs.partial +4 -4
  32. package/templates/app/quality-config/sonar-project.properties +4 -2
  33. package/runtime/engine/canonical-json.mjs +0 -14
  34. package/runtime/engine/db/ledger-open.mjs +0 -38
  35. package/runtime/engine/db/ledger-paths.mjs +0 -87
  36. package/runtime/engine/db/ledger.mjs +0 -1068
  37. package/runtime/engine/db/provision-authority.mjs +0 -76
  38. package/runtime/engine/db/provision-operations.mjs +0 -146
  39. package/runtime/packages/grammar/scripts/build-stamp.mjs +0 -98
  40. package/runtime/scripts/agent/codex-app-server.mjs +0 -79
  41. package/runtime/scripts/agent/codex-mirror-source.mjs +0 -34
  42. package/runtime/scripts/agent/host-agents.mjs +0 -80
  43. package/runtime/scripts/agent/launch-trust-policy.mjs +0 -53
  44. package/runtime/scripts/agent/trust-launch.mjs +0 -191
  45. package/runtime/scripts/agent/trust.mjs +0 -523
  46. package/runtime/scripts/api/fs/temp-path.mjs +0 -8
  47. package/runtime/scripts/api/git/diff-names.mjs +0 -8
  48. package/runtime/scripts/api/git/head-time.mjs +0 -10
  49. package/runtime/scripts/api/git/index-lock.mjs +0 -78
  50. package/runtime/scripts/api/git/log.mjs +0 -5
  51. package/runtime/scripts/api/git/merge-tree.mjs +0 -5
  52. package/runtime/scripts/api/git/rev-list.mjs +0 -5
  53. package/runtime/scripts/api/git/rev-parse.mjs +0 -13
  54. package/runtime/scripts/api/git/status-query.mjs +0 -5
  55. package/runtime/scripts/api/git/worktree-list-query.mjs +0 -5
  56. package/runtime/scripts/api/node/spawn-node.mjs +0 -6
  57. package/runtime/scripts/api/npm/dist-tag.mjs +0 -8
  58. package/runtime/scripts/api/npm/lib.mjs +0 -32
  59. package/runtime/scripts/api/npm/pack-dry-run.mjs +0 -9
  60. package/runtime/scripts/api/npm/run-npm.mjs +0 -6
  61. package/runtime/scripts/api/npm/view.mjs +0 -30
  62. package/runtime/scripts/api/npm/whoami.mjs +0 -8
  63. package/runtime/scripts/api/process/hide-child-windows.mjs +0 -31
  64. package/runtime/scripts/api/process/kill-tree.mjs +0 -22
  65. package/runtime/scripts/api/process/lib.mjs +0 -125
  66. package/runtime/scripts/api/process/probe-guard-command.mjs +0 -74
  67. package/runtime/scripts/api/process/process-list.mjs +0 -28
  68. package/runtime/scripts/api/process/system-tool.mjs +0 -37
  69. package/runtime/scripts/gates/canon-digest.mjs +0 -81
  70. package/runtime/scripts/gates/canon-pins.mjs +0 -119
  71. package/runtime/scripts/gates/gate-input.mjs +0 -98
  72. package/runtime/scripts/gates/gate.mjs +0 -636
  73. package/runtime/scripts/gates/grammar-dist.mjs +0 -206
  74. package/runtime/scripts/gates/output.mjs +0 -40
  75. package/runtime/scripts/gates/runtime-package-selection.mjs +0 -27
  76. package/runtime/scripts/gates/test-world-run.mjs +0 -252
  77. package/runtime/scripts/gates/type-impact.mjs +0 -277
  78. package/runtime/scripts/gates/type-program.mjs +0 -113
  79. package/runtime/scripts/guards/assigned-command.mjs +0 -12
  80. package/runtime/scripts/guards/call-rights.mjs +0 -47
  81. package/runtime/scripts/guards/command-guard.mjs +0 -468
  82. package/runtime/scripts/guards/command-policy.mjs +0 -342
  83. package/runtime/scripts/guards/critic-reach.mjs +0 -82
  84. package/runtime/scripts/guards/deps-guard.mjs +0 -150
  85. package/runtime/scripts/guards/env-dump-verdict.mjs +0 -89
  86. package/runtime/scripts/guards/guards-root.mjs +0 -27
  87. package/runtime/scripts/guards/hook-install.mjs +0 -343
  88. package/runtime/scripts/guards/hook-verdict.mjs +0 -12
  89. package/runtime/scripts/guards/install-verdict.mjs +0 -41
  90. package/runtime/scripts/guards/kernel-seat.mjs +0 -63
  91. package/runtime/scripts/guards/launch-verdict.mjs +0 -74
  92. package/runtime/scripts/guards/op-starci.mjs +0 -16
  93. package/runtime/scripts/guards/op-write-scope.mjs +0 -27
  94. package/runtime/scripts/guards/orca-self-lifecycle.mjs +0 -39
  95. package/runtime/scripts/guards/process-kill-verdict.mjs +0 -106
  96. package/runtime/scripts/guards/protected-zone.mjs +0 -56
  97. package/runtime/scripts/guards/refusals.mjs +0 -27
  98. package/runtime/scripts/guards/rights.mjs +0 -268
  99. package/runtime/scripts/guards/seat-tools.mjs +0 -47
  100. package/runtime/scripts/guards/shell-commands.mjs +0 -328
  101. package/runtime/scripts/guards/supervisor-seat.mjs +0 -80
  102. package/runtime/scripts/guards/verdict-process.mjs +0 -81
  103. package/runtime/scripts/lib/app-data.mjs +0 -11
  104. package/runtime/scripts/lib/canon-binding-text.mjs +0 -129
  105. package/runtime/scripts/lib/check-format.mjs +0 -7
  106. package/runtime/scripts/lib/failure-code-reads.mjs +0 -100
  107. package/runtime/scripts/lib/failure-code-template-errors.mjs +0 -161
  108. package/runtime/scripts/lib/git-dir.mjs +0 -120
  109. package/runtime/scripts/lib/guard-command.mjs +0 -24
  110. package/runtime/scripts/lib/interrupt-cleanup.mjs +0 -38
  111. package/runtime/scripts/lib/json-formats.mjs +0 -34
  112. package/runtime/scripts/lib/managed-json.mjs +0 -51
  113. package/runtime/scripts/lib/menu-parts.mjs +0 -11
  114. package/runtime/scripts/lib/op-gate.mjs +0 -15
  115. package/runtime/scripts/lib/provision-control-failure.mjs +0 -32
  116. package/runtime/scripts/lib/release-version.mjs +0 -134
  117. package/runtime/scripts/lib/runtime-location.mjs +0 -21
  118. package/runtime/scripts/lib/runtime-package-inventory.mjs +0 -21
  119. package/runtime/scripts/lib/runtime-package-manifests.mjs +0 -84
  120. package/runtime/scripts/lib/runtime-publication-tags.mjs +0 -56
  121. package/runtime/scripts/lib/seat-env.mjs +0 -43
  122. package/runtime/scripts/lib/sonar-new-code.mjs +0 -58
  123. package/runtime/scripts/lib/source-package-imports.mjs +0 -111
  124. package/runtime/scripts/lib/tar-files.mjs +0 -39
  125. package/runtime/scripts/lib/uat-run-folder.mjs +0 -118
  126. package/runtime/scripts/lib/worktree-record.mjs +0 -14
  127. package/runtime/scripts/machine/ask-receipts.mjs +0 -113
  128. package/runtime/scripts/machine/evidence-store.mjs +0 -223
  129. package/runtime/scripts/machine/home.mjs +0 -216
  130. package/runtime/scripts/machine/host-lock.mjs +0 -184
  131. package/runtime/scripts/machine/lock-recovery.mjs +0 -55
  132. package/runtime/scripts/machine/roles-contract.mjs +0 -90
  133. package/runtime/scripts/machine/runtime-change.mjs +0 -20
  134. package/runtime/scripts/machine/workflow-tree.mjs +0 -122
  135. package/runtime/scripts/reconciler/checklist-items.mjs +0 -7
  136. package/runtime/scripts/reconciler/guard-row.mjs +0 -25
  137. package/runtime/scripts/work/brand/brand-colour.mjs +0 -125
  138. package/runtime/scripts/work/brand/brand-tokens.mjs +0 -167
  139. package/runtime/scripts/work/brand/brand-value-source.mjs +0 -106
  140. package/runtime/scripts/work/brand/brand.mjs +0 -892
  141. package/runtime/scripts/work/draw/draw-layer.mjs +0 -306
  142. package/runtime/scripts/work/draw/draw-rationale-page.mjs +0 -237
  143. package/runtime/scripts/work/draw/draw-rationale-ref.mjs +0 -14
  144. package/runtime/scripts/work/draw/draw-rationale.mjs +0 -353
  145. package/runtime/scripts/work/draw/draw-source.mjs +0 -412
  146. package/runtime/scripts/work/draw/draw-taste.mjs +0 -278
  147. package/runtime/scripts/work/draw/draw-typecheck.mjs +0 -72
  148. package/runtime/scripts/work/draw/rationale-findings.mjs +0 -205
  149. package/runtime/scripts/work/draw-grammar.mjs +0 -175
  150. package/runtime/scripts/work/draw-render-page.mjs +0 -188
  151. package/runtime/scripts/work/draw-render.mjs +0 -626
  152. package/runtime/scripts/work/png.mjs +0 -237
  153. package/runtime/scripts/work/render-tools.mjs +0 -64
@@ -1,191 +0,0 @@
1
- // scripts/agent/trust-launch.mjs — the launch-time trust flow: pre-trust the directory an agent starts in (see trust.mjs for the
2
- // writers and the scope rules), per provider, and report the receipt the launch event records.
3
- import path from 'node:path';
4
- import { probeGuardCommand } from '../api/process/probe-guard-command.mjs';
5
- import { toolGuardCommand } from '../lib/guard-command.mjs';
6
- import { codexLaunchHomes } from './codex-mirror-source.mjs';
7
- import { codexTrustPaths, launchTrustVerdict } from './launch-trust-policy.mjs';
8
- import {
9
- TOOL_GUARD_MATCHER, assertClaudeBypassConsent, assertClaudeSettingsEnv, assertJsonToolGuard, claudeKeyForms, claudeLaunchEnv,
10
- codexAppServer, codexKeyForms, codexProjectTables, excludeFromGit, jsonOf, projectTargets, readText, trustCodexToolGuard,
11
- trustTargets, writeClaudeTrust, writeCodexNoModelNudge, writeCodexNoUpdateCheck, writeCodexToolGuard, writeCodexTrust, writeDevinProfile,
12
- } from './trust.mjs';
13
-
14
- const TRUST_AGENTS = new Set(['claude', 'codex', 'devin']);
15
- // The Critic's own worktree also hooks the read tools: its guard confines them to its directory (scripts/guards/critic-reach.mjs).
16
- const CRITIC_TOOL_GUARD_MATCHER = `${TOOL_GUARD_MATCHER}|Read|Grep|Glob`;
17
-
18
- /**
19
- * Pre-trust `cwd` for `agent` before launch. Never throws; a failure is
20
- * recorded without a screen-only consent fallback. Returns null for
21
- * an agent with no trust prompt. A guard command no shell can run refuses the launch (status failed,
22
- * code guard-command-unresolvable) before any trust, settings or hook file is written (after the provider's own decline is read). Seam: `guardProbe`.
23
- */
24
- export function ensureLaunchTrust({ agent, cwd, config, role = null, env = process.env, platform = process.platform, hooks, codexAppServer: appServer = null, guardProbe = probeGuardCommand } = {}) {
25
- if (!TRUST_AGENTS.has(agent)) return null;
26
- const authorization = launchTrustVerdict({ cwd, config, platform });
27
- if (!authorization.ok) return { agent, paths: [], status: 'declined', reason: authorization.reason };
28
- const { dir } = authorization;
29
- const targets = trustTargets({ env, platform });
30
- if (targets.skipped) return { agent, paths: [dir], status: 'skipped', reason: targets.skipped };
31
- const project = projectTargets(dir);
32
- const receipt = { agent, paths: [dir], approval: authorization.approval, written: [], already: [], errors: [] };
33
- // Check explicit provider declines before writing any trust/settings/hook file.
34
- let declined;
35
- try { declined = ownerDeclineOf({ agent, platform, authorization, targets, project, receipt, env }); }
36
- catch (error) { return { ...receipt, status: 'failed', errors: [{ error: String(error.message) }] }; }
37
- if (declined) return declined;
38
- let command;
39
- try { command = toolGuardCommand({ home: targets.home }); }
40
- catch (error) { return unresolvedGuard({ ...receipt, command: 'linked runtime guard', resolved: { reason: String(error?.message ?? error) } }); }
41
- const resolved = guardProbe({ command, home: targets.home, platform, env });
42
- if (!resolved.ok) return unresolvedGuard({ ...receipt, command, resolved });
43
- const ctx = { dir, platform, hooks, env, appServer, targets, project, receipt, command, role };
44
- const early = trustFlowOf(agent)(ctx);
45
- if (early) return early;
46
- receipt.status = receipt.errors.length ? 'failed' : ['already', 'written'][Number(receipt.written.length > 0)];
47
- if (!receipt.errors.length) delete receipt.errors;
48
- return receipt;
49
- }
50
-
51
- // The refusal of a launch whose guard command no shell can run: nothing is written, the code is catalogued.
52
- const unresolvedGuard = ({ command, resolved, ...receipt }) => ({ ...receipt, status: 'failed', code: 'guard-command-unresolvable', reason: `the guard command ${command} cannot run: ${resolved.reason}`, errors: [{ error: resolved.reason }] });
53
-
54
- function trustFlowOf(agent) {
55
- if (agent === 'devin') return trustDevin;
56
- return agent === 'claude' ? trustClaude : trustCodex;
57
- }
58
-
59
- // The provider's own explicit decline of the project: the receipt that refuses the launch, or null.
60
- function ownerDeclineOf({ agent, platform, authorization, targets, project, receipt, env }) {
61
- if (agent === 'claude') return claudeDecline({ platform, authorization, targets, project, receipt });
62
- if (agent === 'codex') return codexDecline({ platform, authorization, targets, receipt, env });
63
- return null;
64
- }
65
-
66
- function claudeDecline({ platform, authorization, targets, project, receipt }) {
67
- const user = readText(targets.claudeJson), doc = user === null ? {} : jsonOf(user);
68
- const local = readText(project.claudeSettings), settings = local === null ? {} : jsonOf(local);
69
- if (!doc || !settings) throw new Error('Claude trust/settings file is unreadable');
70
- if (claudeKeyForms(authorization.dir, platform).some((key) => doc.projects?.[key]?.hasTrustDialogAccepted === false) || settings.skipDangerousModePermissionPrompt === false)
71
- return { ...receipt, status: 'declined', reason: 'owner declined Claude project trust or bypass consent' };
72
- return null;
73
- }
74
-
75
- function codexDecline({ platform, authorization, targets, receipt, env }) {
76
- const keys = authorization.paths.flatMap((p) => codexKeyForms(p, platform));
77
- for (const home of codexLaunchHomes({ homes: targets.codexHomes, env })) {
78
- const tables = codexProjectTables(readText(path.join(home.dir, 'config.toml')) ?? '');
79
- if (keys.some((key) => tables.get(key)?.trust != null && tables.get(key).trust !== 'trusted'))
80
- return { ...receipt, status: 'declined', reason: 'owner declined Codex project trust' };
81
- }
82
- return null;
83
- }
84
-
85
- function collectResult(receipt, r) {
86
- for (const key of r.written ?? []) receipt.written.push({ file: r.file, key });
87
- for (const key of r.already ?? []) receipt.already.push({ file: r.file, key });
88
- if (!r.ok) receipt.errors.push({ file: r.file, error: r.error });
89
- }
90
-
91
- const guarded = (file, fn) => { try { return fn(); } catch (e) { return { file, ok: false, error: String(e?.message ?? e) }; } };
92
-
93
- // A step that failed names its file and error (or its state) in the receipt.
94
- const noteFailure = (receipt, file, result) => {
95
- if (!result.ok) receipt.errors.push({ file, error: result.error ?? result.state });
96
- };
97
-
98
- // A project file the runtime wrote stays out of `git status` (the repository's own info/exclude).
99
- function excludeWritten({ receipt, dir }, file) {
100
- const x = guarded(file, () => excludeFromGit(dir, file));
101
- if (x) { receipt.gitExclude ??= []; receipt.gitExclude.push(x); }
102
- if (x?.ok === false) receipt.errors.push({ file, error: x.error });
103
- }
104
-
105
- // Devin's LOCAL project config (<dir>/.devin/config.local.json): the guard hook.
106
- function trustDevin(ctx) {
107
- const { receipt, project, command, hooks } = ctx;
108
- const file = project.devinConfig;
109
- const profile = guarded(file, () => writeDevinProfile({ file, command, hooks }));
110
- receipt.toolGuard = [{ file, state: profile.state ?? 'failed' }];
111
- noteFailure(receipt, file, profile);
112
- if (profile.ok) {
113
- receipt[profile.state === 'written' ? 'written' : 'already'].push({ file, key: 'hooks.PreToolUse' });
114
- excludeWritten(ctx, file);
115
- }
116
- return null;
117
- }
118
-
119
- // The directory trust record is Claude's own per-user state (~/.claude.json); everything else is the worktree's
120
- // local project settings (<dir>/.claude/settings.local.json), which Claude reads for the bypass consent, env and hooks.
121
- function trustClaude(ctx) {
122
- const { receipt, targets, project, dir, platform, command, hooks, role } = ctx;
123
- collectResult(receipt, guarded(targets.claudeJson, () => writeClaudeTrust({ file: targets.claudeJson, keys: claudeKeyForms(dir, platform), hooks })));
124
- if (receipt.errors.length) return { ...receipt, status: 'failed' };
125
- const file = project.claudeSettings;
126
- const consent = guarded(file, () => assertClaudeBypassConsent({ file, hooks }));
127
- receipt.bypassConsent = consent.state ?? 'failed';
128
- noteFailure(receipt, file, consent);
129
- if (receipt.errors.length) return { ...receipt, status: 'failed' };
130
- const launchEnv = guarded(file, () => assertClaudeSettingsEnv({ file, vars: claudeLaunchEnv(), hooks }));
131
- receipt.launchEnv = launchEnv.state ?? 'failed';
132
- noteFailure(receipt, file, launchEnv);
133
- const toolGuard = guarded(file, () => assertJsonToolGuard({ file, command, matcher: role === 'critic' ? CRITIC_TOOL_GUARD_MATCHER : TOOL_GUARD_MATCHER, hooks }));
134
- receipt.toolGuard = [{ file, state: toolGuard.state ?? 'failed' }];
135
- noteFailure(receipt, file, toolGuard);
136
- if (consent.ok || launchEnv.ok || toolGuard.ok) excludeWritten(ctx, file);
137
- return null;
138
- }
139
-
140
- // A Codex notice pinned off in one home: recorded under `field` with the verdict of its writer.
141
- function recordCodexNotice(receipt, field, file, result) {
142
- receipt[field] ??= [];
143
- receipt[field].push({ file, off: result.ok === true, ...(result.written ? { written: true } : {}), ...(result.ok ? {} : { error: result.error }) });
144
- if (!result.ok) receipt.errors.push({ file, error: result.error });
145
- }
146
-
147
- // The trust, update-check and nudge records of one Codex home; the failed receipt when the trust itself failed.
148
- function trustCodexHome(ctx, home, keys) {
149
- const { receipt, hooks } = ctx;
150
- const file = path.join(home.dir, 'config.toml');
151
- collectResult(receipt, guarded(file, () => writeCodexTrust({ file, keys, hooks })));
152
- if (receipt.errors.length) return { ...receipt, status: 'failed' };
153
- recordCodexNotice(receipt, 'updateCheck', file, guarded(file, () => writeCodexNoUpdateCheck({ file, hooks })));
154
- recordCodexNotice(receipt, 'modelNudge', file, guarded(file, () => writeCodexNoModelNudge({ file, hooks })));
155
- return null;
156
- }
157
-
158
- // The guard hook of one Codex home: the block in the home's config.toml, then the hash Codex trusts it by. The
159
- // receipt entry names the home's file, whether the block was written and the home's verdict.
160
- function codexGuardIn(ctx, home, server) {
161
- const { receipt, dir, command, hooks } = ctx;
162
- const file = path.join(home.dir, 'config.toml');
163
- const hook = guarded(file, () => writeCodexToolGuard({ file, command, hooks }));
164
- if (!hook.ok) receipt.errors.push({ file, error: hook.error });
165
- else receipt[hook.written ? 'written' : 'already'].push({ file, key: 'hooks.PreToolUse' });
166
- const trusted = hook.ok && server ? guarded(file, () => trustCodexToolGuard({ home: home.dir, cwd: dir, command, appServer: server })) : null;
167
- if (trusted && !trusted.ok) receipt.errors.push({ file, error: trusted.error });
168
- const verdict = trusted ? ['failed', trusted.trusted][Number(Boolean(trusted.ok))] : 'not-checked';
169
- return { file, ...(hook.written ? { written: true } : {}), trustedIn: [{ home: home.dir, trusted: verdict }] };
170
- }
171
-
172
- // Codex: the directory trust, the notices and the guard hook live in each Codex home the worker can start in. Codex
173
- // 0.160.0 loads a project layer's hooks only from the main checkout of a repository, never from a linked worktree
174
- // (every workflow launch directory), so a hook written to <dir>/.codex is never listed; the home's own config.toml is
175
- // the layer it lists for every directory, and `starci guard command` acts only for a terminal the launch bound a guard
176
- // to. The homes are Orca's managed home and the system home (codexLaunchHomes): Orca starts the worker in one of them
177
- // and rebuilds the managed config.toml from the system one at each launch, keeping only its project and hook-state tables.
178
- function trustCodex(ctx) {
179
- const { receipt, targets, dir, platform, env, appServer } = ctx;
180
- receipt.paths = codexTrustPaths(dir);
181
- const keys = [...new Set(receipt.paths.flatMap((p) => codexKeyForms(p, platform)))];
182
- const homes = codexLaunchHomes({ homes: targets.codexHomes, env });
183
- for (const home of homes) {
184
- const failed = trustCodexHome(ctx, home, keys);
185
- if (failed) return failed;
186
- }
187
- // A re-rooted trust home (specs) never starts the real Codex: its app-server is injected, else the hash step waits.
188
- const server = appServer ?? (env.STARCI_AGENT_TRUST_HOME ? null : codexAppServer);
189
- receipt.toolGuard = homes.map((home) => codexGuardIn(ctx, home, server));
190
- return null;
191
- }