@starci/hfs 4.11.20 → 4.11.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.11.22 - 2026-10-30
4
+
5
+ - Changed: `starci app check` and `starci app lint` are green while fewer than 20 error findings remain and none is a hard blocker (owner ruling gate-threshold-20, contexts/harness/decisions.md; `runtime/scripts/hfs/gate-threshold.mjs` `gateVerdict`): a plaintext secret (HFS_PLAINTEXT_SECRET and its family), the boot proof (BE_APP_BOOT_PROOF_MISSING) or a migration finding (DB_MIGRATION_SHAPE, DB_MIGRATION_DESTRUCTIVE, LITE_DB_MIGRATION, BE_MIGRATION_REVERSIBLE) blocks at any count. Every finding is still printed and kept in the report (`gate` carries the verdict); typecheck, build and the tests are not judged by it. Specs: `src/gate-threshold.spec.mjs`; `src/check-eslint.spec.mjs` now expects green for one or two ordinary findings.
6
+ - Changed: the bundled canon pins name eslint-canon-be 3.8.21, eslint-canon-fe 9.5.23 and the Grammar family 0.15.34.
7
+
8
+ ## 4.11.21 - 2026-10-30
9
+
10
+ - Changed: an urgent release runs typecheck and the build only (owner ruling urgent-typecheck-build, contexts/harness/decisions.md): `URGENT_CHECKS` are the release gates `typecheck`, `build`, `build-be` and `build-fe` the app declares (`release/urgent.mjs`); app check, lint and the tests wait for the back-fill. `--lint-baseline` is retired with lint itself and refused (`RELEASE_URGENT_LINT_BASELINE_RETIRED`); `release/lint-baseline.mjs` is gone.
11
+ - Added: the one-command urgent release. `starci app stack deploy --env <env> --urgent --reason "<text>" --execute` with no `--image` and no `--source-sha` releases HEAD (unless it already has a pushed urgent record; a tag already on HEAD is adopted), builds and pushes its images on this machine before the deploy's Docker transport reaches the server, and deploys their digests under the unchanged floor (`stack/urgent-release.mjs`, wired in `stack/cli.mjs`; `--reason` and `--remote` belong to it; `STACK_URGENT_REASON_MISSING`). A dry run plans the release and the build and stops. Specs: `src/stack-urgent-release.spec.mjs`, `src/release-urgent.spec.mjs`.
12
+ - Changed: `deploy.remote.sealed` is one member name (`sealed: vps`: `vps.enc.yaml` holds VPS_HOST, VPS_USER, `privateKey` and `knownHosts`), read as the member of all three SSH roles (`stack-deploy-config.mjs`, schema `deployRemote.sealed`). The three-role object `{ ops, sshKey, knownHosts }` is refused (STACKS_DEPLOY_CONFIG_INVALID), its message naming `starci app secret migrate <env> <member> --to vps --into-existing` to fold a member per role into one (owner, 2026-10-30: one form only). Spec: `src/hfs-stacks-deploy-schema.spec.mjs`.
13
+ - Changed: `secret audit` takes a grouped member as declared, not MIXED_PROVIDERS: the member `deploy.remote.sealed` names groups VPS_HOST, VPS_USER, privateKey and knownHosts, and a `secrets:` entry naming a member may list the keys it groups (`keys: [...]`, schema `secret.keys`) instead of an entry per key; the stacks gate refuses a listed key the envelope does not hold, and an entry with both `key` and `keys` (`secret-standard.mjs` `declaredGroup`, `stacks-gate.mjs`). Spec: `src/hfs-secret-standard.spec.mjs`.
14
+ - Changed: the bundled canon pins name eslint-canon-be 3.8.20, eslint-canon-fe 9.5.22 and the Grammar family 0.15.33.
15
+
3
16
  ## 4.11.20 - 2026-10-30
4
17
 
5
18
  - Added: a slot may declare the files of its own that carry logic: `logic: [file, ...]` (owner ruling slot-declared-logic, contexts/decisions/rulings.yaml), valid only on a tracked be directory slot with `coverage: required` and `tests: unit-beside`, each a `<name>.<part>.ts` the slot requires or allows and not already a logic-role file (`manifest-shape.mjs` `slotLogicProblems`, `declaredLogicOf`). A declared file is measured at 100 per file like a logic role (`coverage-scope.mjs` `files` and `measuredBy`, `rules/coverage-below.mjs`, `sync/index.mjs` renders `files` into be/jest.config.js, Sonar no longer excludes it), and its colocated `.spec.ts` is admitted unlisted (`allows.mjs`). `be.integrations.passport` declares `passport.tokens.ts`, `passport.password.ts` and `passport.cookie.ts`; the lite skeleton ships their specs in the testing-module form (`passport.password.spec.ts` and `passport.cookie.spec.ts` are new), each file at 100. Specs: `src/slot-declared-logic.spec.mjs`; `codecov-scope` and `scaffold-template-canon-be` follow.
package/lint/run.mjs CHANGED
@@ -27,6 +27,7 @@ import { STYLE_GLOB } from '../sync/index.mjs';
27
27
  import { byCodeUnit } from '../report/order.mjs';
28
28
  import { braceVariants, globExpression } from '../runtime/scripts/lib/glob.mjs';
29
29
  import { grammarLintFor } from '../runtime/scripts/lib/grammar-lint.mjs';
30
+ import { gateVerdict } from '../runtime/scripts/hfs/gate-threshold.mjs';
30
31
 
31
32
  // --side judges only that side; root HFS findings belong to be, its Sonar report stays on that side.
32
33
  export const LINT_SCHEMA = 'starci/lint@1';
@@ -436,8 +437,10 @@ export async function lintRepository({ repoRoot, opts, hfsCheck, trackedFiles =
436
437
  linterReport('eslint', raw.eslint, { root: repoRoot, sourceRoots, tracked }),
437
438
  linterReport('stylelint', raw.stylelint, { root: repoRoot, sourceRoots, tracked }),
438
439
  ]);
439
- const report = { schema: LINT_SCHEMA, ok: findings.length === 0 && errors.length === 0, repoRoot, changed: changed ? [...changed].sort(byCodeUnit) : null, workspace, ...(opts.side === undefined ? {} : { side: opts.side }), counts: { error: findings.length }, engines, errors, findings };
440
- return { report, sonar, exit: errors.length ? 2 : findings.length ? 1 : 0 };
440
+ // Green under the threshold (gate-threshold.mjs): every finding is still reported, only the verdict changes.
441
+ const gate = gateVerdict(findings);
442
+ const report = { schema: LINT_SCHEMA, ok: gate.pass && errors.length === 0, repoRoot, changed: changed ? [...changed].sort(byCodeUnit) : null, workspace, ...(opts.side === undefined ? {} : { side: opts.side }), counts: { error: findings.length }, engines, errors, findings, gate };
443
+ return { report, sonar, exit: errors.length ? 2 : gate.pass ? 0 : 1 };
441
444
  }
442
445
 
443
446
  export function printLintText(report, out) {
@@ -445,4 +448,5 @@ export function printLintText(report, out) {
445
448
  for (const e of report.errors) out(`ERROR ${e}\n`);
446
449
  const per = Object.keys(report.engines).map((engine) => `${engine} ${report.findings.filter((f) => f.engine === engine).length}`).join(', ');
447
450
  out(`\nstarci app lint: ${report.counts.error} finding${report.counts.error === 1 ? '' : 's'} (${per})${report.errors.length ? `, ${report.errors.length} tool error${report.errors.length === 1 ? '' : 's'}` : ''}\n`);
451
+ if (report.gate?.line) out(`${report.gate.line}\n`);
448
452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/hfs",
3
- "version": "4.11.20",
3
+ "version": "4.11.22",
4
4
  "description": "The StarCi app command implementation for scaffolding, linting, checking and synchronizing one product repository.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/release/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // index.mjs - `starci app release <gate|push>` and the plumbing the release and database verbs share: the context built from the app's IO, strict flag
2
2
  // parsing, the optional `release:` / `database:` blocks of .starcistacks/application-stacks.yaml, text and --json output and the exit-code mapping.
3
3
  // starci app release gate [--execute] [--sonar] [--source <ref>] [--tag-prefix <prefix>] [--backfill <tag>] [--json]
4
- // starci app release push [--execute] [--remote <name>] [--urgent --reason <text> [--lint-baseline <tag>]] [--json]
4
+ // starci app release push [--execute] [--remote <name>] [--urgent --reason <text>] [--json]
5
5
  // `harness` of the app IO ({ version, role, openTicket }) is what the starci CLI hands in: the caller's role an urgent record names and the ticket
6
6
  // queue a red back-fill files into.
7
7
  // Every action is a dry run unless --execute is given. A refusal is a StackError (exit 2); a failed step returns ok false (exit 1).
@@ -58,7 +58,7 @@ function readPackage(root) {
58
58
  }
59
59
 
60
60
  /** The normalised `release:` block (tolerant of absence) with the package version: { root, version, gates, tagPrefix, defaultBranch, requireCi }. */
61
- function loadReleaseConfig(root) {
61
+ export function loadReleaseConfig(root) {
62
62
  const pkg = readPackage(root);
63
63
  if (typeof pkg.version !== 'string' || !VERSION.test(pkg.version)) throw refusal(RELEASE_CODE, 'package.json needs a version like 1.2.3 (the release tag derives from it)');
64
64
  const declaration = readDeclaration(root);
@@ -1,5 +1,5 @@
1
1
  // urgent.mjs - `starci app release push --urgent --reason "<text>"`, the sanctioned urgent path (owner ruling urgent-release, 2026-10-29: an urgent
2
- // deploy needs no CI). It runs only the fast local checks (app check, typecheck, lint of the files changed since the previous release tag, unit), or
2
+ // deploy needs no CI). It runs only the fast local checks (typecheck and the build: owner ruling urgent-typecheck-build, 2026-10-30), or
3
3
  // reuses a green row the gate already recorded for HEAD with the same command and an unchanged log; tags HEAD (annotated) and pushes the default
4
4
  // branch and the tag in ONE atomic push through the repository's hook (never --no-verify, `git push --dry-run --atomic` first); then writes the
5
5
  // URGENT record <git common dir>/starci-release/<HEAD>.urgent.json naming who (the caller's role), why (the reason), each check with its verdict and the
@@ -11,15 +11,14 @@ import { firstLine } from '../stack/context.mjs';
11
11
  import { failure, refusal } from '../stack/errors.mjs';
12
12
  import { assertUnmoved, git, inspect, releaseDir, runGate, summaryOf } from './gate.mjs';
13
13
  import { assertNames, branchRefs, probe, tagRefs } from './push.mjs';
14
- import { baselineLint } from './lint-baseline.mjs';
15
14
  import { URGENT_RULING, URGENT_SCHEMA, greenRow, recordRow, writeUrgent } from './records.mjs';
16
15
 
17
- /** The fast local checks of an urgent release, by gate name, in the order they run. */
18
- export const URGENT_CHECKS = Object.freeze(['app-check', 'typecheck', 'lint', 'test']);
16
+ /**
17
+ * The fast local checks of an urgent release, by gate name, in the order they run: what can break production, the types and the build
18
+ * (owner ruling urgent-typecheck-build, 2026-10-30). App check, lint and the tests wait for the back-fill (`release gate --backfill`).
19
+ */
20
+ export const URGENT_CHECKS = Object.freeze(['typecheck', 'build', 'build-be', 'build-fe']);
19
21
  const REASON_MAX = 500;
20
- const CHANGED_MAX = 200;
21
- const PATH_WORD = /^[A-Za-z0-9_@%+=:,./\\-]+$/u;
22
- const MANAGED_LINT = 'npm run lint';
23
22
 
24
23
  /** The reason, one line of plain text; an urgent release without one is refused. */
25
24
  function reasonOf(value) {
@@ -29,37 +28,11 @@ function reasonOf(value) {
29
28
  return reason;
30
29
  }
31
30
 
32
- /** The newest release tag reachable from HEAD's parent, or null on a first release. */
33
- function previousTag(ctx, prefix) {
34
- const found = git(ctx, ['describe', '--tags', '--abbrev=0', '--match', `${prefix}[0-9]*`, 'HEAD^'], { allowFail: true });
35
- return found.code === 0 && found.stdout !== '' ? found.stdout : null;
36
- }
37
-
38
- /** The lint row of an urgent release: the managed whole-app lint narrowed to the source files changed since the previous release tag. */
39
- function changedLint(ctx, gate, prefix) {
40
- if (gate.command.join(' ') !== MANAGED_LINT) return { gate, note: null };
41
- const since = previousTag(ctx, prefix);
42
- if (!since) return { gate, note: 'no previous release tag: the whole app is linted' };
43
- const files = git(ctx, ['diff', '--name-only', '--diff-filter=d', `${since}..HEAD`]).stdout.split('\n').map((file) => file.trim())
44
- .filter((file) => /\.(?:[cm]?[jt]sx?|css)$/u.test(file));
45
- if (files.length === 0) return { gate: null, note: `no source file changed since ${since}` };
46
- if (files.length > CHANGED_MAX || !files.every((file) => PATH_WORD.test(file))) return { gate, note: `${files.length} changed file(s) since ${since}: the whole app is linted` };
47
- return { gate: { ...gate, command: ['npx', 'starci', 'app', 'lint', '--changed', ...files] }, note: `${files.length} file(s) changed since ${since}` };
48
- }
49
-
50
- /**
51
- * The urgent checks this app declares, from its release gates; a lint row is narrowed to the changed files, or, with `lintBaseline` (a release
52
- * tag), judged whole against that tag's findings (lint-baseline.mjs), which only the managed lint can be.
53
- */
54
- function urgentGates(ctx, config, prefix, lintBaseline) {
31
+ /** The urgent checks this app declares, from its release gates, in URGENT_CHECKS order. */
32
+ function urgentGates(config) {
55
33
  const declared = URGENT_CHECKS.map((name) => config.gates.find((gate) => gate.name === name)).filter(Boolean);
56
34
  if (declared.length === 0) throw refusal('RELEASE_URGENT_NO_CHECKS', `the release gates declare none of ${URGENT_CHECKS.join(', ')}: an urgent release still runs its fast local checks`);
57
- return declared.map((gate) => {
58
- if (gate.name !== 'lint') return { name: gate.name, gate, note: null };
59
- if (lintBaseline === undefined) return { name: gate.name, ...changedLint(ctx, gate, prefix) };
60
- if (gate.command.join(' ') !== MANAGED_LINT) throw refusal('RELEASE_URGENT_LINT_BASELINE_UNMANAGED', `--lint-baseline judges the managed lint (${MANAGED_LINT}), and this app's lint gate runs ${gate.command.join(' ')}`);
61
- return { name: gate.name, gate, baseline: lintBaseline, note: `the whole app, judged against ${lintBaseline}: only a finding new since it is red (owner ruling urgent-lint-baseline)` };
62
- });
35
+ return declared.map((gate) => ({ name: gate.name, gate, note: null }));
63
36
  }
64
37
 
65
38
  /** Runs (or reuses) each check in order and stops at the first red one. Returns the rows of the record. */
@@ -71,12 +44,6 @@ function runChecks(ctx, checks, { common, head, dir, platform }) {
71
44
  rows.push({ name: check.name, command: null, pass: true, reused: false, detail: check.note, log: null, logSha256: null });
72
45
  continue;
73
46
  }
74
- if (check.baseline !== undefined) {
75
- const row = baselineLint(ctx, check.gate, { tag: check.baseline, dir, platform });
76
- rows.push({ ...row, reused: false, note: check.note });
77
- if (!row.pass) break;
78
- continue;
79
- }
80
47
  const command = check.gate.command.join(' ');
81
48
  const reused = greenRow(common, head, check.name, command);
82
49
  if (reused) {
@@ -104,6 +71,7 @@ function planOf(checks) {
104
71
  */
105
72
  export async function releaseUrgentPush(ctx, config, options = {}) {
106
73
  const reason = reasonOf(options.reason);
74
+ if (options.lintBaseline !== undefined) throw refusal('RELEASE_URGENT_LINT_BASELINE_RETIRED', 'an urgent release no longer lints (owner ruling urgent-typecheck-build): lint runs in the back-fill, so --lint-baseline has nothing to judge');
107
75
  const role = options.role ?? 'unset';
108
76
  const remote = options.remote ?? 'origin';
109
77
  const branch = config.defaultBranch;
@@ -112,7 +80,7 @@ export async function releaseUrgentPush(ctx, config, options = {}) {
112
80
  const { head, chosen } = facts;
113
81
  const common = releaseDir(ctx);
114
82
  const dir = path.join(common, head.slice(0, 12));
115
- const checks = urgentGates(ctx, config, config.tagPrefix, options.lintBaseline);
83
+ const checks = urgentGates(config);
116
84
  const out = [...facts.out, `urgent ${URGENT_RULING}`, `reason ${reason}`, `role ${role}`, ...planOf(checks)];
117
85
  const data = { head, tag: chosen.tag, remote, branch, urgent: true, reason, role, checks: [], pushed: false };
118
86
  if (facts.red.length > 0) return { ok: false, lines: [...out, ...facts.red.map((item) => `RED: ${item}`), 'nothing run, nothing pushed.'], data: { ...data, red: facts.red } };
@@ -31,35 +31,35 @@ pins:
31
31
  source: packages/event-stream/package.json
32
32
  why: 'the one server-sent-events client of every front end (fe-stack event-stream, owner:event-stream-package): the transport client layer (modules/api/sse/clients) creates one instance for the app with the bearer token source and the stream operations follow on it; it carries Last-Event-ID resume, the capped doubling backoff, the heartbeat timeout, the single 401 renewal and the useSWRSubscription adapter, so no app keeps a hand-written reader.'
33
33
  '@starci/grammar':
34
- version: 0.15.32
34
+ version: 0.15.34
35
35
  group: starci
36
36
  install: registry
37
37
  side: fe
38
38
  source: packages/grammar/package.json
39
39
  why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
40
40
  '@starci/eslint-canon-be':
41
- version: 3.8.19
41
+ version: 3.8.21
42
42
  group: starci
43
43
  install: registry
44
44
  side: be
45
45
  source: packages/eslint-canon-be/package.json
46
46
  why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
47
47
  '@starci/eslint-canon-fe':
48
- version: 9.5.21
48
+ version: 9.5.23
49
49
  group: starci
50
50
  install: registry
51
51
  side: fe
52
52
  source: packages/eslint-canon-fe/package.json
53
53
  why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
54
54
  '@starci/eslint-grammar-core':
55
- version: 0.15.32
55
+ version: 0.15.34
56
56
  group: starci
57
57
  install: registry
58
58
  side: fe
59
59
  source: packages/eslint-grammar-core/package.json
60
60
  why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
61
61
  '@starci/eslint-grammar-offset-pop':
62
- version: 0.15.32
62
+ version: 0.15.34
63
63
  group: starci
64
64
  install: registry
65
65
  side: fe
@@ -106,7 +106,7 @@ pins:
106
106
  source: packages/ai-router/package.json
107
107
  why: 'the AI pool router of a back end: a NestJS module that routes OpenAI-compatible chat, stream and embeddings calls across keys, models and providers, with @starci/ai-router/testing for its specs; @starci/jest-preset compiles it as an ESM-only dependency.'
108
108
  '@starci/hfs':
109
- version: 4.11.20
109
+ version: 4.11.22
110
110
  group: starci
111
111
  install: registry
112
112
  side: both
@@ -650,14 +650,8 @@ $defs:
650
650
  pattern: '^[A-Za-z0-9][A-Za-z0-9._-]*$'
651
651
  releasesBase: {$ref: '#/$defs/deployAbsolutePath'}
652
652
  sealed:
653
- description: 'Owner-machine session for prepare and doctor: members of .starcistacks/<environment>/secrets.'
654
- type: object
655
- additionalProperties: false
656
- required: [ops, sshKey, knownHosts]
657
- properties:
658
- ops: {$ref: '#/$defs/deployName'}
659
- sshKey: {$ref: '#/$defs/deployName'}
660
- knownHosts: {$ref: '#/$defs/deployName'}
653
+ description: 'Owner-machine session for prepare, doctor and deploy: the one member of .starcistacks/<environment>/secrets holding VPS_HOST, VPS_USER, privateKey and knownHosts.'
654
+ $ref: '#/$defs/deployName'
661
655
  serverRecipient:
662
656
  description: The deploy server's public age recipient, recorded by starci app secret server-key <env> --execute.
663
657
  type: string
@@ -865,5 +859,11 @@ $defs:
865
859
  where: {type: string, minLength: 1}
866
860
  member: {type: string, pattern: '^[a-z0-9][a-z0-9-]*$', description: "The provider member holding this key (`secrets/<member>`, the slug of where); with key, the entry declares one key of it."}
867
861
  key: {type: string, pattern: '^[A-Z][A-Z0-9_]*$', description: "The one key of the member this entry declares; materialized as its own file, read by the app as <KEY>_FILE."}
862
+ keys:
863
+ description: The keys a member groups on purpose (several providers in one member), declared in one entry instead of an entry per key; every one must be in the member's envelope.
864
+ type: array
865
+ minItems: 1
866
+ uniqueItems: true
867
+ items: {type: string, pattern: '^[A-Za-z][A-Za-z0-9_]*$'}
868
868
  recipientPolicy: {type: string, minLength: 1, description: "Which age recipients the envelope is encrypted to: its environment's rule of the app's managed .sops.yaml."}
869
869
  keyCustody: {type: string, minLength: 1, description: "Where the shared decrypting identity is held; docs/host-secrets.md owns host custody and its execution prerequisites."}
@@ -0,0 +1,36 @@
1
+ // gate-threshold.mjs - the verdict of `starci app check` and `starci app lint` (owner ruling gate-threshold-20, 2026-10-30): green
2
+ // while fewer than GATE_ERROR_LIMIT error findings remain and none of them is a hard blocker, so a release is not held back finding
3
+ // by finding (5, 4, 3, ...) by the last few structural nits. A plaintext secret, a failed boot proof and a broken migration block at
4
+ // any count. Every finding is still printed; only the exit code changes. Typecheck, build and the tests are not judged here.
5
+
6
+ export const GATE_ERROR_LIMIT = 20;
7
+
8
+ /** The limit in force: policy/quality.yaml `gate.errorLimit`, handed in by the harness CLI as STARCI_GATE_ERROR_LIMIT, else 20. */
9
+ export function gateErrorLimit(env = process.env) {
10
+ const value = Number(env.STARCI_GATE_ERROR_LIMIT);
11
+ return Number.isInteger(value) && value > 0 ? value : GATE_ERROR_LIMIT;
12
+ }
13
+ export const GATE_THRESHOLD_RULING = 'owner ruling gate-threshold-20 2026-10-30: app check and lint pass under 20 error findings with no plaintext secret, boot proof or migration finding';
14
+
15
+ /** The codes that block at any count: plaintext secrets, the boot proof, the migrations. */
16
+ export const HARD_BLOCKERS = Object.freeze(new Set([
17
+ 'HFS_PLAINTEXT_SECRET', 'HFS_SECRET_PLAINTEXT_FILE', 'HFS_SECRET_OUTSIDE_ENC', 'HFS_SCRIPT_PLAINTEXT_LOAD', 'RT_SECRET_TRACKED',
18
+ 'STACKS_SECRET_ENV_LITERAL', 'APP_SECRET_IN_CI', 'BE_LOG_SECRET',
19
+ 'BE_APP_BOOT_PROOF_MISSING',
20
+ 'DB_MIGRATION_SHAPE', 'DB_MIGRATION_DESTRUCTIVE', 'LITE_DB_MIGRATION', 'BE_MIGRATION_REVERSIBLE',
21
+ ]));
22
+
23
+ /**
24
+ * The verdict over the error findings (each with `code`): { pass, count, hard, line }. `pass` is true when no hard blocker is
25
+ * among them and there are fewer than GATE_ERROR_LIMIT; `line` says which, for the report.
26
+ */
27
+ export function gateVerdict(errors, limit = gateErrorLimit()) {
28
+ const hard = [...new Set(errors.map((finding) => finding.code).filter((code) => HARD_BLOCKERS.has(code)))].sort();
29
+ const count = errors.length;
30
+ const pass = hard.length === 0 && count < limit;
31
+ const line = count === 0 ? null
32
+ : hard.length > 0 ? `gate: red, ${hard.join(', ')} block${hard.length === 1 ? 's' : ''} at any count (${count} error finding(s))`
33
+ : pass ? `gate: green under the threshold, ${count} error finding(s) < ${limit} and no hard blocker (owner ruling gate-threshold-20); they stay listed above`
34
+ : `gate: red, ${count} error finding(s), the threshold is fewer than ${limit}`;
35
+ return { pass, count, hard, line };
36
+ }
@@ -20,21 +20,31 @@ export const providerOf = (key) => key.split("_")[0].toLowerCase();
20
20
  const sameSet = (left, right) => left.length === right.length && left.every((item) => right.includes(item));
21
21
  const keyList = (keys) => keys.join(", ");
22
22
 
23
+ /** The member a `secrets:` entry names: `member`, else the slug of `where`, else its `name`. */
24
+ const memberOfEntry = (entry) => entry?.member ?? /^secrets\/([a-z0-9-]+)/u.exec(entry?.where ?? "")?.[1] ?? entry?.name;
25
+
23
26
  /** The keys an environment's `secrets:` declares for `member`: an entry naming `key` with that `member`, or a whole-member entry. */
24
27
  function declaredKeys(spec, member, keys) {
25
28
  const entries = Array.isArray(spec?.secrets) ? spec.secrets : [];
26
- const memberOfEntry = (entry) => entry?.member ?? /^secrets\/([a-z0-9-]+)/u.exec(entry?.where ?? "")?.[1] ?? entry?.name;
27
29
  if (entries.some((entry) => entry?.key === undefined && memberOfEntry(entry) === member)) return keys;
28
30
  return entries.filter((entry) => entry?.key !== undefined && memberOfEntry(entry) === member).map((entry) => entry.key);
29
31
  }
30
32
 
33
+ /** The keys of the one sealed SSH member `deploy.remote.sealed` names (stack/remote.mjs): the deploy transport reads exactly these. */
34
+ const SSH_GROUP = Object.freeze(["VPS_HOST", "VPS_USER", "privateKey", "knownHosts"]);
35
+
31
36
  /**
32
- * True when the stack groups `member` on purpose: the environment's `secrets:` declares every key of it per key, naming this member.
33
- * A member the owner groups (an app's own keys, the keys one service reads) holds keys of several first words by design.
37
+ * True when the stack groups `member` on purpose: every key of it is declared in the environment's `secrets:`, per key (`key` with
38
+ * `member: <member>`) or in the `keys` list of an entry naming the member, or is a key of the sealed SSH member the deploy names.
39
+ * A member the owner groups (an app's own keys, the keys one service reads, the VPS session) holds keys of several first words by design.
34
40
  */
35
41
  function declaredGroup(spec, member, keys) {
36
42
  const entries = Array.isArray(spec?.secrets) ? spec.secrets : [];
37
- return keys.length > 0 && keys.every((key) => entries.some((entry) => entry?.key === key && entry?.member === member));
43
+ const sealed = spec?.deploy?.remote?.sealed;
44
+ const ssh = (typeof sealed === "string" ? [sealed] : Object.values(sealed ?? {})).includes(member) ? SSH_GROUP : [];
45
+ const declared = (key) => ssh.includes(key) || entries.some((entry) => memberOfEntry(entry) === member
46
+ && (entry?.key === key || (Array.isArray(entry?.keys) && entry.keys.includes(key))));
47
+ return keys.length > 0 && keys.every(declared);
38
48
  }
39
49
 
40
50
  /** The tracked member file names of one environment, or null outside a git work tree. */
@@ -75,7 +85,7 @@ export function auditSecrets(repoRoot, environment = null) {
75
85
  const providers = [...new Set(envelope.keys.map(providerOf))];
76
86
  if (isLegacyName(name)) add("LEGACY_MEMBER", `is a dotenv .enc member; move it: starci app secret migrate ${env} ${member} [--to <provider>] --execute`);
77
87
  if (providers.length > 1 && !declaredGroup(spec, member, envelope.keys))
78
- add("MIXED_PROVIDERS", `holds keys of ${providers.length} providers by their first word (${providers.join(", ")}) that the stack does not group in it; split it (starci app secret split ${env} ${member} [--group KEY=member] --execute) or declare each key with member: ${member} in environments.${env}.secrets`);
88
+ add("MIXED_PROVIDERS", `holds keys of ${providers.length} providers by their first word (${providers.join(", ")}) that the stack does not group in it; split it (starci app secret split ${env} ${member} [--group KEY=member] --execute) or declare its keys in environments.${env}.secrets (an entry naming ${member} with keys: [...])`);
79
89
  const wanted = recipientsFor(repoRoot, path.join(directory, `${member}${MEMBER_SUFFIX}`));
80
90
  if (!isLegacyName(name) && wanted.length && !sameSet(wanted, envelope.recipients))
81
91
  add("RECIPIENT_DRIFT", `is sealed to ${keyList(envelope.recipients)}, its environment's rule names ${keyList(wanted)}; seal it again: starci app secret migrate ${env} ${member} --execute`);
@@ -65,9 +65,12 @@ function remote(c, block) {
65
65
  if (block.releasesBase !== undefined && (!REMOTE_BASE.test(String(block.releasesBase)) || String(block.releasesBase).includes('..')))
66
66
  c.problem('deploy.remote.releasesBase', 'must be an absolute path without ..');
67
67
  let sealed = null;
68
- if (block.sealed !== undefined && closedFields(c, 'deploy.remote.sealed', block.sealed, FIELDS.sealed)) {
69
- for (const key of FIELDS.sealed) nameField(c, `deploy.remote.sealed.${key}`, block.sealed[key]);
70
- sealed = { ...block.sealed };
68
+ // One member holds VPS_HOST, VPS_USER, privateKey and knownHosts (`sealed: vps`); it plays all three SSH roles of the transport.
69
+ if (typeof block.sealed === 'string') {
70
+ nameField(c, 'deploy.remote.sealed', block.sealed);
71
+ sealed = Object.fromEntries(FIELDS.sealed.map((key) => [key, block.sealed]));
72
+ } else if (block.sealed !== undefined) {
73
+ c.problem('deploy.remote.sealed', 'names one member holding VPS_HOST, VPS_USER, privateKey and knownHosts (sealed: vps); fold a member per role into it with starci app secret migrate <env> <member> --to vps --into-existing');
71
74
  }
72
75
  return { host: block.host ?? 'vps', releasesBase: block.releasesBase ?? null, sealed, serverRecipient: block.serverRecipient ?? null };
73
76
  }
@@ -264,6 +264,12 @@ const checkSecret=(secret,at,{envDir,environment,root,tracked,secretNames,add})=
264
264
  add('encrypted-ref-invalid',`${at}.where`,'secret must resolve to <where>.enc.yaml (or a legacy <where>.enc) as a recognizable SOPS envelope, an existing regular file below the environment directory');
265
265
  else if(nonempty(secret.key)&&!envelopeOf(fs.readFileSync(enc,'utf8')).keys.includes(secret.key))
266
266
  add('encrypted-ref-invalid',`${at}.key`,`the member at ${secret.where} holds no ${secret.key}`);
267
+ else if(Array.isArray(secret.keys)){
268
+ // A grouped member declares its keys in one entry; each must be in the envelope, and one entry declares one key or a group, not both.
269
+ if(nonempty(secret.key))add('encrypted-ref-invalid',`${at}.keys`,'an entry declares one key (key) or a group (keys), not both');
270
+ const held=envelopeOf(fs.readFileSync(enc,'utf8')).keys;
271
+ for(const key of secret.keys.filter(key=>!held.includes(key)))add('encrypted-ref-invalid',`${at}.keys`,`the member at ${secret.where} holds no ${key}`);
272
+ }
267
273
  if(nonempty(secret.where)&&!plain)
268
274
  add('materialized-path-invalid',`${at}.where`,'secret plaintext path and its existing ancestors must remain below the environment directory without symlinks');
269
275
  if(!String(secret.recipientPolicy??'').trim()||!String(secret.keyCustody??'').trim())
package/src/main.mjs CHANGED
@@ -73,6 +73,7 @@ import { dbBaselineMain } from '../runtime/scripts/hfs/db-baseline-verb.mjs';
73
73
  import { dbRestampMain } from '../runtime/scripts/hfs/db-restamp-verb.mjs';
74
74
  import { dbPlanMain } from '../runtime/scripts/hfs/db-plan-verb.mjs';
75
75
  import { formatCoverageReport } from '../runtime/scripts/hfs/coverage-from.mjs';
76
+ import { gateVerdict } from '../runtime/scripts/hfs/gate-threshold.mjs';
76
77
  import { HFS_DECLARATION_FILE, HfsSlotsError, loadSlotManifest, readRepoDeclaration } from '../runtime/scripts/hfs/slots.mjs';
77
78
  import { formatFindings } from '../sync/format.mjs';
78
79
  import { main as syncMain } from '../sync/cli.mjs';
@@ -116,11 +117,11 @@ starci app db migrate [--execute] [--url-env <NAME>] [--json] [--cwd <dir>]
116
117
  starci app db post-cutover [--execute] [--green-at <ISO> | --owner-confirms-old-app-gone] [--url-env <NAME>] [--json] [--cwd <dir>]
117
118
  starci app db drift [--url-env <NAME>] [--json] [--cwd <dir>]
118
119
  starci app release gate [--execute] [--source <ref>] [--tag-prefix <prefix>] [--backfill <tag>] [--json] [--cwd <dir>]
119
- starci app release push [--execute] [--remote <name>] [--urgent --reason <text> [--lint-baseline <tag>]] [--json] [--cwd <dir>]
120
+ starci app release push [--execute] [--remote <name>] [--urgent --reason <text>] [--json] [--cwd <dir>]
120
121
  starci app upgrade [--plan] [--cwd <dir>]
121
122
  starci app stack <up|down|status> [--stack <dir>] [--services <list>] [--k3d] [--force] [--json] [--cwd <dir>]
122
123
  starci app stack <prepare|doctor|connect|disconnect|build-args|render|deploy|converge|verify|rollback|prune|backup|jobs> --env <env> [--execute] [--json] [--cwd <dir>]
123
- starci app stack deploy --env <env> --source-sha <sha> --urgent [--db-url-env <NAME>] [--backup-out <dir>] [--first-start --db-service <service>] [--execute] [--json] [--cwd <dir>]
124
+ starci app stack deploy --env <env> --urgent (--reason <text> [--remote <name>] | --source-sha <sha> --image <service>=<ref>) [--db-url-env <NAME>] [--backup-out <dir>] [--first-start --db-service <service>] [--execute] [--json] [--cwd <dir>]
124
125
  starci app explain <path> [--cwd <dir>] [--json]
125
126
  starci app emit [--cwd <dir>]
126
127
  starci app new service <dir> <name> [--inject <binding>...] [--cwd <dir>]
@@ -363,9 +364,11 @@ async function checkMain(opts, { cwd: repoRoot, harness, edition, stdout: out, p
363
364
  const existing = changed ? changed.filter(file => fs.existsSync(path.join(repoRoot, file))) : [];
364
365
  const eslint = await eslintRepository({ repoRoot, changed, existing, run: runLinter });
365
366
  const findings = [...proof.findings, ...eslint.findings.map(finding => ({ ...finding, code: finding.code ?? finding.rule, level: 'error' }))];
366
- const result = { ...proof, findings, counts: { ...proof.counts, error: proof.counts.error + eslint.findings.length }, eslint: { ...eslint.engine, errors: eslint.errors }, ok: proof.ok && eslint.findings.length === 0 && eslint.errors.length === 0 };
367
+ // Green under the threshold (gate-threshold.mjs): every finding is still listed, only the verdict changes.
368
+ const verdict = gateVerdict(findings.filter(finding => finding.level === 'error'));
369
+ const result = { ...proof, findings, counts: { ...proof.counts, error: proof.counts.error + eslint.findings.length }, eslint: { ...eslint.engine, errors: eslint.errors }, ok: verdict.pass && eslint.errors.length === 0, gate: verdict };
367
370
  if (opts.json) out(`${JSON.stringify(result, null, 2)}\n`);
368
- else { printCheck(result, out); printCheckProofs(result, out); }
371
+ else { printCheck(result, out); printCheckProofs(result, out); if (verdict.line) out(`${verdict.line}\n`); }
369
372
  return eslint.errors.length ? 2 : result.ok ? 0 : 1;
370
373
  }
371
374
 
@@ -435,8 +438,8 @@ function declaredEdition(cwd) {
435
438
  * `starci app stack`: the deploy actions (prepare, doctor, render, deploy, converge, verify, rollback, prune, backup, jobs, ...) are the Swarm
436
439
  * tooling of stack/cli.mjs; up, down and status are the full edition's test-world infrastructure.
437
440
  */
438
- async function stackAppMain(argv, { cwd, edition, stackMain, stdout: out, stderr: err, env, sops, hostIdentity, stackIo }) {
439
- if (STACK_ACTIONS.includes(argv[0])) return deployStackMain(argv, { ...stackIo, cwd, stdout: out, stderr: err, env, hostIdentity, ...(sops ? { sops } : {}) });
441
+ async function stackAppMain(argv, { cwd, edition, stackMain, stdout: out, stderr: err, env, sops, hostIdentity, stackIo, harness }) {
442
+ if (STACK_ACTIONS.includes(argv[0])) return deployStackMain(argv, { ...stackIo, cwd, stdout: out, stderr: err, env, hostIdentity, harness, ...(sops ? { sops } : {}) });
440
443
  if ((edition ?? declaredEdition(cwd)) === 'lite') throw new Error('starci app stack up|down|status manage the local test world of the full edition; a lite app starts its local database with npm run db:start');
441
444
  const run = stackMain ?? await installedStackMain(cwd);
442
445
  return run(argv, { cwd, out, err });
package/stack/cli.mjs CHANGED
@@ -8,6 +8,7 @@ import { loadDeployConfig } from './config.mjs';
8
8
  import { withDockerTransport } from './docker-transport.mjs';
9
9
  import { StackError, EXIT, refusal } from './errors.mjs';
10
10
  import { parseTargetBinding, bindStackTarget, nativeToolEnvironment } from './target-binding.mjs';
11
+ import { oneCommand, prepareUrgentRelease } from './urgent-release.mjs';
11
12
 
12
13
  /** The actions that drive the docker CLI of the operator machine (pointed at the manager by docker-transport.mjs when the key is sealed). */
13
14
  const DOCKER_ACTIONS = new Set(['deploy', 'accept', 'converge', 'verify', 'rollback', 'prune']);
@@ -15,7 +16,7 @@ const DOCKER_ACTIONS = new Set(['deploy', 'accept', 'converge', 'verify', 'rollb
15
16
  export const ACTIONS = Object.freeze(['prepare', 'doctor', 'connect', 'disconnect', 'build-args', 'render', 'deploy', 'converge', 'verify', 'rollback', 'prune', 'backup', 'jobs', 'task', 'ingress', 'retire', 'build', 'accept']);
16
17
 
17
18
  const BOOLEAN = new Set(['--execute', '--json', '--swarm-state', '--init-swarm', '--owner-approved', '--fix-live-restore', '--skip-public', '--skip-internal', '--allow-unpinned', '--push', '--urgent', '--first-start']);
18
- const VALUE = new Set(['--env', '--image', '--source-sha', '--previous', '--out', '--release', '--since', '--timeout', '--retry', '--keep', '--app', '--ssh-cmd', '--extra-compose', '--project', '--target-binding', '--db-url-env', '--backup-out', '--db-service']);
19
+ const VALUE = new Set(['--env', '--image', '--source-sha', '--previous', '--out', '--release', '--since', '--timeout', '--retry', '--keep', '--app', '--ssh-cmd', '--extra-compose', '--project', '--target-binding', '--db-url-env', '--backup-out', '--db-service', '--reason', '--remote']);
19
20
  const REPEAT = new Set(['--image', '--keep', '--extra-compose', '--project']);
20
21
 
21
22
  /** Splits argv into { flags, positional }; an unknown flag or a flag without its value is a refusal. */
@@ -72,7 +73,7 @@ const OPTIONS = {
72
73
  images: parseImages(flags.image), sourceSha: flags['source-sha'], execute: flags.execute === true,
73
74
  out: flags.out ? path.resolve(cwd, flags.out) : null, timeoutSeconds: number(flags, 'timeout'), retrySeconds: number(flags, 'retry'), skipPublic: flags['skip-public'] === true,
74
75
  urgent: flags.urgent === true, dbUrlEnv: flags['db-url-env'], backupOut: flags['backup-out'] ? path.resolve(cwd, flags['backup-out']) : undefined,
75
- firstStart: flags['first-start'] === true, dbService: flags['db-service'],
76
+ firstStart: flags['first-start'] === true, dbService: flags['db-service'], reason: flags.reason, remote: flags.remote,
76
77
  }),
77
78
  converge: ({ flags }) => ({ since: flags.since, timeoutSeconds: number(flags, 'timeout') }),
78
79
  verify: ({ flags }) => ({ retrySeconds: number(flags, 'retry'), skipPublic: flags['skip-public'] === true, skipInternal: flags['skip-internal'] === true }),
@@ -127,15 +128,27 @@ export async function stackMain(argv, io = {}) {
127
128
  if (binding && (!['deploy', 'verify'].includes(action) || flags['ssh-cmd'] || flags['skip-public'] || flags['skip-internal']))
128
129
  throw refusal('STACK_USAGE', 'the bound native consumer supports only complete deploy or verify');
129
130
  const config = bindStackTarget(ctx, loadDeployConfig({ repoRoot: ctx.cwd, env: flags.env ?? 'production' }), binding);
130
- if (action !== 'deploy' && (flags.urgent || flags['db-url-env'] || flags['backup-out'] || flags['first-start'] || flags['db-service'])) throw refusal('STACK_USAGE', '--urgent, --db-url-env, --backup-out, --first-start and --db-service belong to deploy');
131
+ if (action !== 'deploy' && (flags.urgent || flags['db-url-env'] || flags['backup-out'] || flags['first-start'] || flags['db-service'] || flags.reason || flags.remote)) throw refusal('STACK_USAGE', '--urgent, --db-url-env, --backup-out, --first-start, --db-service, --reason and --remote belong to deploy');
132
+ if (!flags.urgent && (flags.reason || flags.remote)) throw refusal('STACK_USAGE', '--reason and --remote release HEAD in the one-command urgent deploy: add --urgent');
131
133
  if (!flags.urgent && (flags['first-start'] || flags['db-service'])) throw refusal('STACK_USAGE', '--first-start and --db-service are the first start of an empty database under the urgent floor: add --urgent');
132
134
  if (action === 'deploy' && !flags.urgent && (flags['db-url-env'] || flags['backup-out'])) throw refusal('STACK_USAGE', '--db-url-env and --backup-out choose the urgent floor\'s database and backup folder: add --urgent');
133
- const options = OPTIONS[action]({ flags, positional, cwd: ctx.cwd });
135
+ let options = OPTIONS[action]({ flags, positional, cwd: ctx.cwd });
136
+ // The one-command urgent deploy releases HEAD and builds its images here, before the Docker transport reaches the server.
137
+ let prepared = null;
138
+ if (action === 'deploy' && oneCommand(options)) {
139
+ prepared = await prepareUrgentRelease(ctx, config, { ...options, role: io.harness?.role ?? ctx.env.STARCI_ROLE });
140
+ if (!prepared.images) {
141
+ print(ctx, action, flags, prepared);
142
+ return prepared.ok ? EXIT.ok : EXIT.failed;
143
+ }
144
+ options = { ...options, images: prepared.images, sourceSha: prepared.sourceSha };
145
+ }
134
146
  const handler = await handlerOf(action, io.importer ?? ((file) => import(file)));
135
147
  const sshCmd = flags['ssh-cmd'] ?? null;
136
148
  const call = (context) => handler(context, config, { ...options, sshCmd });
137
149
  const toolContext = nativeToolContext(ctx, binding);
138
- const result = DOCKER_ACTIONS.has(action) ? await withDockerTransport(toolContext, config, { sshCmd }, call) : await call(toolContext);
150
+ const ran = DOCKER_ACTIONS.has(action) ? await withDockerTransport(toolContext, config, { sshCmd }, call) : await call(toolContext);
151
+ const result = prepared ? { ...ran, lines: [...prepared.lines, ...(ran.lines ?? [])] } : ran;
139
152
  print(ctx, action, flags, result);
140
153
  // A floor step of an urgent deploy that failed is a refusal with its own code (urgent-floor.mjs), printed after the lines that led to it.
141
154
  if (result.refused) {
@@ -0,0 +1,45 @@
1
+ // urgent-release.mjs - the one-command urgent release (owner ruling urgent-typecheck-build, 2026-10-30):
2
+ // starci app stack deploy --env <env> --urgent --reason "<text>" [--execute]
3
+ // with no --image and no --source-sha takes HEAD from the laptop to the server in one command, CI not involved:
4
+ // 1. the urgent release of HEAD (release/urgent.mjs: typecheck and the build, tag, one atomic push, the urgent record), skipped when HEAD
5
+ // already has a pushed urgent record;
6
+ // 2. the images of that tag built and pushed on THIS machine's Docker (stack/build.mjs), which yields their digests;
7
+ // 3. the urgent deploy of those digests (stack/urgent-floor.mjs): backup, migrate preview then execute, deploy, verify, rollback on red.
8
+ // Steps 1 and 2 run before the deploy's Docker transport reaches the server, so nothing is ever built on the server. A dry run prints the
9
+ // urgent release plan and the build plan and stops: the deploy plan needs the digests the build makes.
10
+ import { buildImages } from './build.mjs';
11
+ import { refusal } from './errors.mjs';
12
+ import { git, releaseDir } from '../release/gate.mjs';
13
+ import { loadReleaseConfig } from '../release/index.mjs';
14
+ import { readUrgent } from '../release/records.mjs';
15
+ import { releaseUrgentPush } from '../release/urgent.mjs';
16
+
17
+ /** True when an urgent deploy names neither images nor a source commit: the one-command form. */
18
+ export const oneCommand = (options) => options.urgent === true && !options.sourceSha && Object.keys(options.images ?? {}).length === 0;
19
+
20
+ /**
21
+ * Steps 1 and 2 on the local machine. options: { execute, reason, role, remote }. Returns { ok, lines, data } to print when it stops (a dry run,
22
+ * a red step), or { ok: true, lines, images, sourceSha } for the deploy to continue with.
23
+ */
24
+ export async function prepareUrgentRelease(ctx, config, options, deps = {}) {
25
+ const d = { buildImages, loadReleaseConfig, releaseUrgentPush, ...deps };
26
+ const head = git(ctx, ['rev-parse', 'HEAD']).stdout;
27
+ const lines = [`one-command urgent release of ${head.slice(0, 12)} (owner ruling urgent-typecheck-build): urgent release, local build and push, urgent deploy`];
28
+ const record = readUrgent(releaseDir(ctx), head);
29
+ if (record?.pushed === true) lines.push(`urgent release ${record.tag} of ${head.slice(0, 10)} already pushed: reused`);
30
+ else {
31
+ if (options.reason === undefined) throw refusal('STACK_URGENT_REASON_MISSING', 'the one-command urgent deploy releases HEAD first and says why: --reason "<text>"');
32
+ const pushed = await d.releaseUrgentPush(ctx, d.loadReleaseConfig(ctx.cwd), { execute: options.execute, reason: options.reason, role: options.role, remote: options.remote });
33
+ lines.push(...pushed.lines);
34
+ if (!pushed.ok) return { ok: false, lines, data: { head, step: 'release', ...pushed.data } };
35
+ if (options.execute !== true) {
36
+ lines.push('then: the images of that tag are built and pushed on this machine (stack build --push), then the urgent deploy runs the floor on their digests.');
37
+ return { ok: true, lines: [...lines, 'dry run: nothing tagged, built or deployed.'], data: { head, step: 'release', executed: false } };
38
+ }
39
+ }
40
+ const built = await d.buildImages(ctx, config, { push: true, execute: options.execute === true });
41
+ lines.push(...built.lines);
42
+ if (!built.ok) return { ok: false, lines, data: { head, step: 'build', ...built.data } };
43
+ if (options.execute !== true) return { ok: true, lines: [...lines, 'then: the urgent deploy runs the floor on the pushed digests.', 'dry run: nothing built or deployed.'], data: { head, step: 'build', executed: false } };
44
+ return { ok: true, lines, images: built.data.images, sourceSha: built.data.sha };
45
+ }
@@ -1,123 +0,0 @@
1
- // lint-baseline.mjs - the lint row of an urgent release judged against a baseline release tag (`release push --urgent --lint-baseline <tag>`,
2
- // owner ruling urgent-lint-baseline 2026-10-29: an app whose lint backlog predates the release ships when the release adds no finding of its own).
3
- // The managed lint (`npm run lint`, which ends in `starci app lint`) runs twice, each writing its findings as a Sonar Generic Issue Import file
4
- // (`-- --sonar <file>`): at HEAD, and at the baseline tag in a throwaway `git worktree` that borrows HEAD's installs (each node_modules folder is
5
- // linked in as a directory junction, unlinked before the worktree is removed, never deleted through). A finding is the same finding when its
6
- // engine, rule, file and message match (lines move); a finding left over is then matched on engine, rule and message alone (a file that moved).
7
- // What HEAD holds beyond the baseline is new: zero new findings is green, any is red, and a lint that could not run on either side is red. The
8
- // row names both counts and both reports with their sha256, and the new findings go to lint-new.json beside the record, so the back-fill's full
9
- // gate (which this changes nothing in) still sees the whole backlog.
10
- import { createHash, randomBytes } from 'node:crypto';
11
- import fs from 'node:fs';
12
- import os from 'node:os';
13
- import path from 'node:path';
14
- import { refusal } from '../stack/errors.mjs';
15
- import { git, runGate } from './gate.mjs';
16
-
17
- /** The owner's ruling a baseline-judged lint row cites. */
18
- export const LINT_BASELINE_RULING = 'owner ruling urgent-lint-baseline 2026-10-29: an urgent release whose lint is red only with findings its baseline tag already had ships; a new finding is red';
19
- const LINK_DEPTH = 3;
20
- const NEW_SHOWN = 50;
21
-
22
- const sha256 = (file) => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
23
-
24
- /** The findings of a Sonar Generic Issue Import file as { engine, rule, file, line, message }, or null when it is missing or unreadable. */
25
- export function sonarFindings(file) {
26
- let doc;
27
- try { doc = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return null; }
28
- if (!doc || !Array.isArray(doc.issues)) return null;
29
- return doc.issues.map((issue) => ({
30
- engine: String(issue.engineId ?? ''), rule: String(issue.ruleId ?? ''), file: String(issue.primaryLocation?.filePath ?? ''),
31
- line: issue.primaryLocation?.textRange?.startLine ?? null, message: String(issue.primaryLocation?.message ?? ''),
32
- }));
33
- }
34
-
35
- /** The findings of `head` the `baseline` does not hold: matched on engine, rule, file and message, then the rest on engine, rule and message. */
36
- export function newFindings(head, baseline) {
37
- const take = (pool, key) => { const left = pool.get(key) ?? 0; if (left === 0) return false; pool.set(key, left - 1); return true; };
38
- const exact = (finding) => `${finding.engine}\u0000${finding.rule}\u0000${finding.file}\u0000${finding.message}`;
39
- const loose = (finding) => `${finding.engine}\u0000${finding.rule}\u0000${finding.message}`;
40
- const exactPool = new Map();
41
- for (const finding of baseline) exactPool.set(exact(finding), (exactPool.get(exact(finding)) ?? 0) + 1);
42
- const unmatched = head.filter((finding) => !take(exactPool, exact(finding)));
43
- const loosePool = new Map();
44
- for (const finding of baseline) {
45
- const left = exactPool.get(exact(finding)) ?? 0;
46
- if (left > 0) { exactPool.set(exact(finding), left - 1); loosePool.set(loose(finding), (loosePool.get(loose(finding)) ?? 0) + 1); }
47
- }
48
- return unmatched.filter((finding) => !take(loosePool, loose(finding)));
49
- }
50
-
51
- /** Every node_modules folder of `root` within LINK_DEPTH levels (never inside one), app-relative. */
52
- function installFolders(root) {
53
- const found = [];
54
- const walk = (rel, depth) => {
55
- let entries;
56
- try { entries = fs.readdirSync(path.join(root, rel), { withFileTypes: true }); } catch { return; }
57
- for (const entry of entries) {
58
- if (!entry.isDirectory() || entry.name === '.git') continue;
59
- const child = rel ? path.join(rel, entry.name) : entry.name;
60
- if (entry.name === 'node_modules') found.push(child);
61
- else if (depth < LINK_DEPTH) walk(child, depth + 1);
62
- }
63
- };
64
- walk('', 0);
65
- return found;
66
- }
67
-
68
- /** Removes a link made by this module: the link alone, never what it points at. */
69
- function unlink(link) {
70
- try { fs.unlinkSync(link); } catch { try { fs.rmdirSync(link); } catch { /* already gone */ } }
71
- }
72
-
73
- /** The lint of `gate` with its findings written to `report`: { row, findings } (findings null when the lint could not run). */
74
- function lintTo(ctx, gate, { name, report, dir, platform }) {
75
- fs.rmSync(report, { force: true });
76
- const row = runGate(ctx, { ...gate, name, command: [...gate.command, '--', '--sonar', report] }, { dir, platform, credentialNames: [] });
77
- const ran = row.pass || row.detail === 'exit 1';
78
- return { row, findings: ran ? sonarFindings(report) : null };
79
- }
80
-
81
- /**
82
- * The lint row of an urgent release against `tag`: { name, command, pass, detail, log, logSha256, baseline }. Refuses a tag that is not a
83
- * commit. `dir` is the record folder of HEAD, where both reports, both logs and lint-new.json are written.
84
- */
85
- export function baselineLint(ctx, gate, { tag, dir, platform }) {
86
- const commit = git(ctx, ['rev-parse', '--verify', '--quiet', `${tag}^{commit}`], { allowFail: true });
87
- if (commit.code !== 0 || commit.stdout === '') throw refusal('RELEASE_URGENT_LINT_BASELINE_TAG', `--lint-baseline ${tag} names no commit`);
88
- fs.mkdirSync(dir, { recursive: true });
89
- const headReport = path.join(dir, 'lint-head.sonar.json');
90
- const head = lintTo(ctx, gate, { name: 'lint', report: headReport, dir, platform });
91
- const row = (pass, detail, baseline = null) => ({ ...head.row, pass, detail, baseline: baseline && { tag, commit: commit.stdout, ruling: LINT_BASELINE_RULING, ...baseline } });
92
- if (head.findings === null) return row(false, `the lint at HEAD could not run (${head.row.detail})`);
93
- if (head.findings.length === 0) return row(true, 'no finding at HEAD', { findings: 0, headFindings: 0, newFindings: 0 });
94
- const tree = path.join(os.tmpdir(), `starci-lint-baseline-${randomBytes(4).toString('hex')}`);
95
- const links = [];
96
- const added = git(ctx, ['worktree', 'add', '--detach', tree, commit.stdout], { allowFail: true });
97
- if (added.code !== 0) return row(false, `the baseline worktree of ${tag} could not be made`);
98
- try {
99
- for (const rel of installFolders(ctx.cwd)) {
100
- const link = path.join(tree, rel);
101
- if (fs.existsSync(link) || !fs.existsSync(path.dirname(link))) continue;
102
- fs.symlinkSync(path.join(ctx.cwd, rel), link, 'junction');
103
- links.push(link);
104
- }
105
- const baseReport = path.join(dir, 'lint-baseline.sonar.json');
106
- const base = lintTo(Object.create(ctx, { cwd: { value: tree } }), gate, { name: 'lint-baseline', report: baseReport, dir, platform });
107
- if (base.findings === null) return row(false, `the lint at the baseline ${tag} could not run (${base.row.detail}; log ${base.row.log})`);
108
- const fresh = newFindings(head.findings, base.findings);
109
- fs.writeFileSync(path.join(dir, 'lint-new.json'), `${JSON.stringify(fresh, null, 2)}\n`);
110
- const counts = {
111
- findings: base.findings.length, headFindings: head.findings.length, newFindings: fresh.length,
112
- headReport, headReportSha256: sha256(headReport), baselineReport: baseReport, baselineReportSha256: sha256(baseReport), baselineLog: base.row.log,
113
- newShown: fresh.slice(0, NEW_SHOWN).map((finding) => `${finding.file}:${finding.line ?? '-'} ${finding.rule} ${finding.message}`),
114
- };
115
- const detail = `${head.findings.length} finding(s) at HEAD, ${base.findings.length} at ${tag}, ${fresh.length} new${fresh.length > 0 ? ` (${path.join(dir, 'lint-new.json')})` : ''}`;
116
- return row(fresh.length === 0, detail, counts);
117
- } finally {
118
- links.reverse().forEach(unlink);
119
- // A link still present would let the removal delete through it into HEAD's installs: the worktree then stays for a person to unlink.
120
- if (links.every((link) => !fs.existsSync(link))) git(ctx, ['worktree', 'remove', '--force', tree], { allowFail: true });
121
- else ctx.stderr?.(`lint baseline: ${tree} keeps a linked node_modules; unlink it (cmd /c rmdir <link>) before removing the worktree\n`);
122
- }
123
- }