@starci/hfs 4.8.0 → 4.9.1

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 (144) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/emit/operation-schemas.mjs +3 -0
  3. package/lint/bound-sys.cjs +2 -2
  4. package/package.json +1 -1
  5. package/runtime/engine/admission.mjs +1 -1
  6. package/runtime/engine/config.mjs +2 -2
  7. package/runtime/engine/db/machine.mjs +2 -3
  8. package/runtime/engine/invalid-config.mjs +1 -1
  9. package/runtime/knowledge/hfs/canon-pins.yaml +22 -14
  10. package/runtime/knowledge/hfs/rules.yaml +23 -0
  11. package/runtime/modules/kernel/failure-codes.yaml +10 -0
  12. package/runtime/scripts/guards/git-policy.mjs +2 -3
  13. package/runtime/scripts/hfs/rules/pipeline.mjs +5 -5
  14. package/runtime/scripts/lib/package-at.mjs +5 -6
  15. package/runtime/scripts/lib/roots.mjs +2 -2
  16. package/runtime/scripts/work/draw/draw-dna-findings.mjs +23 -12
  17. package/runtime/scripts/work/draw/draw-dna.mjs +14 -8
  18. package/scaffold/app.mjs +4 -4
  19. package/src/main.mjs +3 -3
  20. package/sync/index.mjs +14 -1
  21. package/sync/managed.mjs +3 -2
  22. package/templates/app/codegen-graphql.mjs.partial +4 -4
  23. package/templates/app/quality-config/sonar-project.properties +4 -2
  24. package/runtime/engine/canonical-json.mjs +0 -14
  25. package/runtime/engine/db/ledger-open.mjs +0 -38
  26. package/runtime/engine/db/ledger-paths.mjs +0 -87
  27. package/runtime/engine/db/ledger.mjs +0 -1068
  28. package/runtime/engine/db/provision-authority.mjs +0 -76
  29. package/runtime/engine/db/provision-operations.mjs +0 -146
  30. package/runtime/packages/grammar/scripts/build-stamp.mjs +0 -98
  31. package/runtime/scripts/agent/codex-app-server.mjs +0 -79
  32. package/runtime/scripts/agent/codex-mirror-source.mjs +0 -34
  33. package/runtime/scripts/agent/host-agents.mjs +0 -80
  34. package/runtime/scripts/agent/launch-trust-policy.mjs +0 -53
  35. package/runtime/scripts/agent/trust-launch.mjs +0 -191
  36. package/runtime/scripts/agent/trust.mjs +0 -523
  37. package/runtime/scripts/api/fs/temp-path.mjs +0 -8
  38. package/runtime/scripts/api/git/diff-names.mjs +0 -8
  39. package/runtime/scripts/api/git/head-time.mjs +0 -10
  40. package/runtime/scripts/api/git/index-lock.mjs +0 -78
  41. package/runtime/scripts/api/git/log.mjs +0 -5
  42. package/runtime/scripts/api/git/merge-tree.mjs +0 -5
  43. package/runtime/scripts/api/git/rev-list.mjs +0 -5
  44. package/runtime/scripts/api/git/rev-parse.mjs +0 -13
  45. package/runtime/scripts/api/git/status-query.mjs +0 -5
  46. package/runtime/scripts/api/git/worktree-list-query.mjs +0 -5
  47. package/runtime/scripts/api/node/spawn-node.mjs +0 -6
  48. package/runtime/scripts/api/npm/dist-tag.mjs +0 -8
  49. package/runtime/scripts/api/npm/lib.mjs +0 -32
  50. package/runtime/scripts/api/npm/pack-dry-run.mjs +0 -9
  51. package/runtime/scripts/api/npm/run-npm.mjs +0 -6
  52. package/runtime/scripts/api/npm/view.mjs +0 -30
  53. package/runtime/scripts/api/npm/whoami.mjs +0 -8
  54. package/runtime/scripts/api/process/hide-child-windows.mjs +0 -31
  55. package/runtime/scripts/api/process/kill-tree.mjs +0 -22
  56. package/runtime/scripts/api/process/lib.mjs +0 -125
  57. package/runtime/scripts/api/process/probe-guard-command.mjs +0 -74
  58. package/runtime/scripts/api/process/process-list.mjs +0 -28
  59. package/runtime/scripts/api/process/system-tool.mjs +0 -37
  60. package/runtime/scripts/gates/canon-digest.mjs +0 -81
  61. package/runtime/scripts/gates/canon-pins.mjs +0 -119
  62. package/runtime/scripts/gates/gate-input.mjs +0 -98
  63. package/runtime/scripts/gates/gate.mjs +0 -636
  64. package/runtime/scripts/gates/grammar-dist.mjs +0 -206
  65. package/runtime/scripts/gates/output.mjs +0 -40
  66. package/runtime/scripts/gates/runtime-package-selection.mjs +0 -27
  67. package/runtime/scripts/gates/test-world-run.mjs +0 -252
  68. package/runtime/scripts/gates/type-impact.mjs +0 -277
  69. package/runtime/scripts/gates/type-program.mjs +0 -113
  70. package/runtime/scripts/guards/assigned-command.mjs +0 -12
  71. package/runtime/scripts/guards/call-rights.mjs +0 -47
  72. package/runtime/scripts/guards/command-guard.mjs +0 -468
  73. package/runtime/scripts/guards/command-policy.mjs +0 -342
  74. package/runtime/scripts/guards/critic-reach.mjs +0 -82
  75. package/runtime/scripts/guards/deps-guard.mjs +0 -150
  76. package/runtime/scripts/guards/env-dump-verdict.mjs +0 -89
  77. package/runtime/scripts/guards/guards-root.mjs +0 -27
  78. package/runtime/scripts/guards/hook-install.mjs +0 -343
  79. package/runtime/scripts/guards/hook-verdict.mjs +0 -12
  80. package/runtime/scripts/guards/install-verdict.mjs +0 -41
  81. package/runtime/scripts/guards/kernel-seat.mjs +0 -63
  82. package/runtime/scripts/guards/launch-verdict.mjs +0 -74
  83. package/runtime/scripts/guards/op-starci.mjs +0 -16
  84. package/runtime/scripts/guards/op-write-scope.mjs +0 -27
  85. package/runtime/scripts/guards/orca-self-lifecycle.mjs +0 -39
  86. package/runtime/scripts/guards/process-kill-verdict.mjs +0 -106
  87. package/runtime/scripts/guards/protected-zone.mjs +0 -56
  88. package/runtime/scripts/guards/refusals.mjs +0 -27
  89. package/runtime/scripts/guards/rights.mjs +0 -268
  90. package/runtime/scripts/guards/seat-tools.mjs +0 -47
  91. package/runtime/scripts/guards/shell-commands.mjs +0 -328
  92. package/runtime/scripts/guards/supervisor-seat.mjs +0 -80
  93. package/runtime/scripts/guards/verdict-process.mjs +0 -81
  94. package/runtime/scripts/lib/app-data.mjs +0 -11
  95. package/runtime/scripts/lib/canon-binding-text.mjs +0 -129
  96. package/runtime/scripts/lib/check-format.mjs +0 -7
  97. package/runtime/scripts/lib/failure-code-reads.mjs +0 -100
  98. package/runtime/scripts/lib/failure-code-template-errors.mjs +0 -161
  99. package/runtime/scripts/lib/git-dir.mjs +0 -120
  100. package/runtime/scripts/lib/guard-command.mjs +0 -24
  101. package/runtime/scripts/lib/interrupt-cleanup.mjs +0 -38
  102. package/runtime/scripts/lib/json-formats.mjs +0 -34
  103. package/runtime/scripts/lib/managed-json.mjs +0 -51
  104. package/runtime/scripts/lib/menu-parts.mjs +0 -11
  105. package/runtime/scripts/lib/op-gate.mjs +0 -15
  106. package/runtime/scripts/lib/provision-control-failure.mjs +0 -32
  107. package/runtime/scripts/lib/release-version.mjs +0 -134
  108. package/runtime/scripts/lib/runtime-location.mjs +0 -21
  109. package/runtime/scripts/lib/runtime-package-inventory.mjs +0 -21
  110. package/runtime/scripts/lib/runtime-package-manifests.mjs +0 -84
  111. package/runtime/scripts/lib/runtime-publication-tags.mjs +0 -56
  112. package/runtime/scripts/lib/seat-env.mjs +0 -43
  113. package/runtime/scripts/lib/sonar-new-code.mjs +0 -58
  114. package/runtime/scripts/lib/source-package-imports.mjs +0 -111
  115. package/runtime/scripts/lib/tar-files.mjs +0 -39
  116. package/runtime/scripts/lib/uat-run-folder.mjs +0 -118
  117. package/runtime/scripts/lib/worktree-record.mjs +0 -14
  118. package/runtime/scripts/machine/ask-receipts.mjs +0 -113
  119. package/runtime/scripts/machine/evidence-store.mjs +0 -223
  120. package/runtime/scripts/machine/home.mjs +0 -216
  121. package/runtime/scripts/machine/host-lock.mjs +0 -184
  122. package/runtime/scripts/machine/lock-recovery.mjs +0 -55
  123. package/runtime/scripts/machine/roles-contract.mjs +0 -90
  124. package/runtime/scripts/machine/runtime-change.mjs +0 -20
  125. package/runtime/scripts/machine/workflow-tree.mjs +0 -122
  126. package/runtime/scripts/reconciler/checklist-items.mjs +0 -7
  127. package/runtime/scripts/reconciler/guard-row.mjs +0 -25
  128. package/runtime/scripts/work/brand/brand-colour.mjs +0 -125
  129. package/runtime/scripts/work/brand/brand-tokens.mjs +0 -167
  130. package/runtime/scripts/work/brand/brand-value-source.mjs +0 -106
  131. package/runtime/scripts/work/brand/brand.mjs +0 -892
  132. package/runtime/scripts/work/draw/draw-layer.mjs +0 -306
  133. package/runtime/scripts/work/draw/draw-rationale-page.mjs +0 -237
  134. package/runtime/scripts/work/draw/draw-rationale-ref.mjs +0 -14
  135. package/runtime/scripts/work/draw/draw-rationale.mjs +0 -353
  136. package/runtime/scripts/work/draw/draw-source.mjs +0 -412
  137. package/runtime/scripts/work/draw/draw-taste.mjs +0 -278
  138. package/runtime/scripts/work/draw/draw-typecheck.mjs +0 -72
  139. package/runtime/scripts/work/draw/rationale-findings.mjs +0 -205
  140. package/runtime/scripts/work/draw-grammar.mjs +0 -175
  141. package/runtime/scripts/work/draw-render-page.mjs +0 -188
  142. package/runtime/scripts/work/draw-render.mjs +0 -626
  143. package/runtime/scripts/work/png.mjs +0 -237
  144. package/runtime/scripts/work/render-tools.mjs +0 -64
@@ -1,14 +0,0 @@
1
- // canonical-json.mjs — the one canonical JSON the runtime digests structured values with: object keys
2
- // sorted, arrays in order, so two equal values always serialize to the same bytes. A leaf beside digest.mjs.
3
- import {byCodeUnit} from './by-code-unit.mjs';
4
- import {isPlainObject} from './plain-object.mjs';
5
-
6
- /** The canonical JSON text of `value`: keys sorted at every depth. */
7
- export function canonicalJSON(value) {
8
- if (Array.isArray(value)) return `[${value.map(canonicalJSON).join(',')}]`;
9
- if (isPlainObject(value)) {
10
- const members = Object.keys(value).sort(byCodeUnit).map(k => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`);
11
- return `{${members.join(',')}}`;
12
- }
13
- return JSON.stringify(value);
14
- }
@@ -1,38 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { createRequire } from 'node:module';
4
- import { installRefResolver } from './ref-value.mjs';
5
-
6
- // engine/db/ledger-open.mjs — how a ledger file is opened: bounded retry on a transient CANTOPEN, a reference-resolving handle.
7
- const require=createRequire(import.meta.url);
8
- export const need=(ok,message,code)=>{if(!ok)throw Object.assign(new Error(message),code?{code}:{});};
9
- export const applyPragmas=(db,pragmas)=>db.exec(Object.entries(pragmas).map(([k,v])=>`PRAGMA ${k}=${v};`).join(' '));
10
- const openSleep=ms=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,ms);
11
- // SQLITE_CANTOPEN is transient on Windows while a concurrent process closes the WAL files: a short bounded retry.
12
- const OPEN_RETRY_DELAYS_MS=[0,300,900];
13
- const cantOpen=error=>/unable to open/i.test(String(error?.message??''));
14
- export function openDb({file,busyTimeoutMs,journalMode='WAL',autoVacuum=false,label,pragmas}){
15
- const {DatabaseSync}=require('node:sqlite');
16
- need(typeof file==='string'&&file.trim(),`${label} needs a file`);
17
- fs.mkdirSync(path.dirname(path.resolve(file)),{recursive:true});
18
- let lastError;
19
- for(const delay of OPEN_RETRY_DELAYS_MS){
20
- if(delay)openSleep(delay);
21
- let db;
22
- try{
23
- db=installRefResolver(new DatabaseSync(file,{timeout:busyTimeoutMs}));
24
- // page_size/auto_vacuum only take on an empty database, before WAL and before the first table.
25
- if(autoVacuum&&Number(db.prepare('PRAGMA page_count').get().page_count)===0)db.exec('PRAGMA page_size=4096; PRAGMA auto_vacuum=INCREMENTAL;');
26
- const sqliteVersion=db.prepare('select sqlite_version() AS version').get().version;
27
- const actual=String(db.prepare(`PRAGMA journal_mode=${journalMode}`).get().journal_mode).toUpperCase();
28
- need(actual===String(journalMode).toUpperCase(),`${label}: SQLite selected journal mode ${actual}, expected ${journalMode} (a network or UNC path cannot hold WAL)`,'STARCI_LEDGER_NOT_WAL');
29
- applyPragmas(db,pragmas);
30
- return {db,sqliteVersion,journalMode:actual};
31
- }catch(error){
32
- try{db?.close();}catch{}
33
- if(!cantOpen(error))throw error;
34
- lastError=error;
35
- }
36
- }
37
- throw lastError;
38
- }
@@ -1,87 +0,0 @@
1
- // Ledger path identity and ownership resolution; connection policy and caches remain in ledger.mjs.
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import {sha256} from '../digest.mjs';
5
- import {isUnderTempDir,localProjectsRoot,readMachine} from './machine.mjs';
6
- import {isSpecRun} from '../../scripts/lib/env.mjs';
7
- import {pathKey} from '../../scripts/lib/path-key.mjs';
8
- import {byCodeUnit} from '../by-code-unit.mjs';
9
- import {tempRoot} from '../temp-root.mjs';
10
- /** Overrides the projects root (the directory holding <ledger_id>/runtime.sqlite) for this process tree; narrower than machine-db.mjs LOCAL_ROOT_ENV, which this still honors through starciLocalRoot when unset. */
11
- export const PROJECTS_ROOT_ENV='STARCI_PROJECTS_ROOT';
12
- const normDir=file=>pathKey(file);
13
- /** <runtime root>/.runtime/projects (starciLocalRoot, itself overridable by STARCI_LOCAL_ROOT; a node --test process tree gets one under the OS temp directory). */
14
- export const projectsRootFor=(env=process.env)=>{
15
- if(env[PROJECTS_ROOT_ENV])return path.resolve(env[PROJECTS_ROOT_ENV]);
16
- const root=localProjectsRoot(env);
17
- if(isSpecRun(env)&&!isUnderTempDir(root,{env}))return path.join(tempRoot({env}),'starci-test-projects');
18
- return root;
19
- };
20
- /** Repository identity: resolved/realpath, forward slashes, case-folded only on Windows. */
21
- export const repoRootKey=repoRoot=>{let root=path.resolve(repoRoot);try{root=fs.realpathSync.native(root);}catch{}return normDir(root);};
22
- /**
23
- * The ledger id of a repository root until the machine registry (a3-2 machine.ledgers) resolves it: a name-based
24
- * UUID of the normalized root, so the same root always names the same ledger and no side registry is needed.
25
- */
26
- const ledgerIdFromKey=key=>{
27
- const h=sha256(`starci-ledger:${key}`);
28
- return `${h.slice(0,8)}-${h.slice(8,12)}-5${h.slice(13,16)}-${(8|(Number.parseInt(h[16],16)&3)).toString(16)}${h.slice(17,20)}-${h.slice(20,32)}`;
29
- };
30
- export const ledgerIdForRepo=repoRoot=>ledgerIdFromKey(repoRootKey(repoRoot));
31
- /** The registered runtime.sqlite of `repoRoot` in machine.ledgers (a3-2 resolveLedger), or null. */
32
- function registeredLedgerFile(root,env,openReader){
33
- let row;try{row=readMachine(m=>m.resolveLedger({repoRoot:root}),null,{env});}catch{return null;}
34
- const file=row?.file&&row.state!=='retired'?path.resolve(row.file):null;
35
- if(file&&fs.existsSync(file))assertLedgerRoot(file,root,openReader);
36
- return file;
37
- }
38
- function assertLedgerRoot(file,root,openReader){
39
- const db=openReader(file);let own;try{own=db.prepare("SELECT value FROM meta WHERE key='repo_root'").get()?.value;}finally{db.close();}
40
- if(!own||repoRootKey(own)!==repoRootKey(root))throw Object.assign(new Error(`ledger-root-mismatch: ${file} belongs to another or unverified repository; preserve the database and resolve the owner binding with the owner`),{code:'STARCI_LEDGER_ROOT_MISMATCH'});
41
- }
42
- function unregisteredLedgerFile(root,env,openReader){
43
- const base=projectsRootFor(env),current=path.join(base,ledgerIdForRepo(root),'runtime.sqlite');
44
- if(fs.existsSync(current)){assertLedgerRoot(current,root,openReader);return current;}
45
- return current;
46
- }
47
- /** Resolve the registry or exact owned store; the ledger owner supplies its verified read-only opener. */
48
- export function resolveLedgerFile(root,{env,openReader}){
49
- return registeredLedgerFile(root,env,openReader)??unregisteredLedgerFile(root,env,openReader);
50
- }
51
-
52
- const SYNTHETIC_LEDGER_ID=/^00000000-0000-4000-8000-[0-9a-f]{12}$/;
53
- const fixtureRefused=message=>{throw new TypeError(`ledger-fixture-refused: ${message}`);};
54
- const assertFixtureIdentity=fixture=>{
55
- if(fixture.sqliteVersion!==undefined&&(typeof fixture.sqliteVersion!=='string'||!/^\d+\.\d+\.\d+(?:\.\d+)?$/.test(fixture.sqliteVersion)))fixtureRefused('sqliteVersion must be a dotted numeric version');
56
- if(typeof fixture.ledgerId!=='string'||!SYNTHETIC_LEDGER_ID.test(fixture.ledgerId))fixtureRefused('ledgerId must be a synthetic UUID');
57
- if(!Number.isSafeInteger(fixture.createdAt)||fixture.createdAt<=0||!Number.isFinite(new Date(fixture.createdAt).getTime()))fixtureRefused('createdAt must be a positive safe epoch millisecond');
58
- const root=fixture.blobRoot;
59
- if(typeof root!=='string'||!root||root.includes('\\')||root.trim()!==root||/[<>:"|?*\x00-\x1f]/.test(root)
60
- ||path.posix.isAbsolute(root)||root.split('/').some(p=>!p||p==='.'||p==='..'))fixtureRefused('blobRoot must be a portable relative path');
61
- };
62
- const assertFixtureFile=file=>{
63
- if(typeof file!=='string'||!path.isAbsolute(file)||path.basename(file)!=='runtime.sqlite')fixtureRefused('file must be an explicit absolute runtime.sqlite');
64
- for(const suffix of ['','-wal','-shm'])if(fs.lstatSync(file+suffix,{throwIfNoEntry:false}))fixtureRefused('file and WAL/SHM must be absent');
65
- const parent=path.dirname(file),stat=fs.lstatSync(parent,{throwIfNoEntry:false});
66
- if(!stat?.isDirectory()||stat.isSymbolicLink()||fs.realpathSync.native(parent)!==path.resolve(parent))fixtureRefused('sample parent must be an existing physical directory');
67
- };
68
- /** Validate a fresh, initialization-only sample identity. Samples carry portable metadata,
69
- * never a repository/machine binding; the ordinary project resolver is not bypassed. */
70
- export function ledgerFixtureInit(fixture,{file,repoRoot,product,machine,mapped,checkpointer,now}){
71
- if(fixture===null){
72
- if(typeof file==='string'&&SYNTHETIC_LEDGER_ID.test(path.basename(path.dirname(path.resolve(file)))))fixtureRefused('synthetic identity is reserved for a sample');
73
- return null;
74
- }
75
- if(!fixture||typeof fixture!=='object'||Array.isArray(fixture)
76
- ||![Object.prototype,null].includes(Object.getPrototypeOf(fixture))
77
- ||!['blobRoot,createdAt,ledgerId','blobRoot,createdAt,ledgerId,sqliteVersion'].includes(Object.keys(fixture).sort(byCodeUnit).join(',')))fixtureRefused('needs ledgerId, createdAt and blobRoot, and may state sqliteVersion');
78
- assertFixtureIdentity(fixture);
79
- if(repoRoot!==null||product!==null||machine!==null||mapped)fixtureRefused('a sample cannot bind a repository, product, machine or cached project path');
80
- if(!checkpointer||now!==Date.now)fixtureRefused('initialization owns its frozen clock and requires a checkpointer');
81
- assertFixtureFile(file);
82
- return Object.freeze({...fixture,marker:'starci/basic-runtime-fixture@1'});
83
- }
84
- /** Refuse sample bytes as an operational ledger before opening a writer or beginning a transaction. */
85
- export function assertOperationalLedger(meta){
86
- if(meta.fixture||SYNTHETIC_LEDGER_ID.test(meta.ledger_id??''))throw new Error('ledger-fixture-read-only: preserve the sample; initialize a new live project store');
87
- }