@ultimat3/cli 31.48.0 → 31.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +30 -23
- package/README.md +96 -4
- package/package.json +30 -30
- package/src/api-registration.ts +45 -14
- package/src/api-routes.ts +1 -0
- package/src/app-load.ts +7 -3
- package/src/app-openapi.ts +7 -1
- package/src/app-root.ts +7 -1
- package/src/budgets.ts +2 -1
- package/src/clean-services.ts +142 -0
- package/src/cmd-auth.ts +3 -0
- package/src/cmd-clean-spec.ts +10 -3
- package/src/cmd-clean.ts +23 -9
- package/src/cmd-db-backfill.ts +6 -0
- package/src/cmd-db-branch.ts +10 -4
- package/src/cmd-db-recount.ts +5 -12
- package/src/cmd-db-rollback.ts +77 -0
- package/src/cmd-db-spec.ts +18 -2
- package/src/cmd-db-status.ts +5 -10
- package/src/cmd-db.ts +105 -33
- package/src/cmd-deploy-verify.ts +14 -6
- package/src/cmd-docs-topic.ts +94 -0
- package/src/cmd-docs.ts +15 -1
- package/src/cmd-doctor.ts +109 -41
- package/src/cmd-drill.ts +80 -18
- package/src/cmd-env.ts +30 -8
- package/src/cmd-errors-app.ts +63 -0
- package/src/cmd-errors.ts +50 -14
- package/src/cmd-generate.ts +17 -4
- package/src/cmd-heavy-spec.ts +9 -1
- package/src/cmd-heavy.ts +111 -27
- package/src/cmd-i18n.ts +33 -1
- package/src/cmd-jobs.ts +27 -1
- package/src/cmd-merge-driver-spec.ts +12 -0
- package/src/cmd-merge-driver.ts +95 -0
- package/src/cmd-new.ts +23 -3
- package/src/cmd-policy-spec.ts +9 -1
- package/src/cmd-policy.ts +72 -17
- package/src/cmd-stop.ts +18 -4
- package/src/cmd-tasks-run.ts +87 -0
- package/src/cmd-tasks-spec.ts +10 -3
- package/src/cmd-tasks.ts +8 -5
- package/src/cmd-test.ts +2 -1
- package/src/cmd-upgrade-spec.ts +8 -1
- package/src/cmd-upgrade.ts +15 -1
- package/src/cmd-verify.ts +9 -41
- package/src/codemods/agents-doc-row.ts +73 -0
- package/src/codemods/define-error-leaf.ts +37 -12
- package/src/codemods/docs-many-agents.ts +11 -15
- package/src/codemods/docs-worker-commands.ts +26 -0
- package/src/codemods/engine-fs.ts +9 -2
- package/src/codemods/index.ts +4 -0
- package/src/codemods/merge-drivers.ts +147 -0
- package/src/command.ts +3 -0
- package/src/db-applied-edits.ts +117 -0
- package/src/db-dev-wire.ts +18 -0
- package/src/db-diagnostics.ts +5 -10
- package/src/db-generate.ts +82 -7
- package/src/db-migrate-pass.ts +51 -0
- package/src/db-migrate-through-dev.ts +209 -0
- package/src/db-rollback-consent.ts +128 -0
- package/src/db-rollback-pass.ts +76 -0
- package/src/db-seed-generate.ts +5 -1
- package/src/db-seed.ts +7 -1
- package/src/deploy-verify-findings.ts +3 -0
- package/src/deploy-verify-grade.ts +3 -0
- package/src/deploy-verify-processes.ts +32 -0
- package/src/dev-boot.ts +3 -0
- package/src/dev-db-migrate.ts +155 -0
- package/src/dev-db-rollback.ts +33 -0
- package/src/dev-db-settled.ts +22 -0
- package/src/dev-lock-errors.ts +78 -0
- package/src/dev-lock-holder-dir.ts +64 -0
- package/src/dev-lock-live.ts +44 -0
- package/src/dev-lock.ts +59 -84
- package/src/dev-policy.ts +11 -8
- package/src/dev-rebuild-schema.ts +116 -13
- package/src/dev-rebuild.ts +13 -4
- package/src/dev-route-table.ts +7 -0
- package/src/dispatch.ts +21 -1
- package/src/doctor-api-listing.ts +114 -0
- package/src/doctor-guarded.ts +41 -0
- package/src/doctor-port.ts +90 -17
- package/src/doctor-probe.ts +36 -5
- package/src/doctor-processes-probe.ts +127 -0
- package/src/doctor-processes.ts +136 -0
- package/src/doctor-warnings.ts +17 -0
- package/src/error-codes-agents.ts +35 -0
- package/src/error-codes-processes.ts +30 -0
- package/src/error-codes-tooling.ts +2 -0
- package/src/error-codes.ts +12 -13
- package/src/errors-suite.ts +27 -0
- package/src/errors.ts +18 -22
- package/src/exercise-registration.ts +4 -3
- package/src/exercise-services.ts +13 -3
- package/src/framework-env.ts +7 -3
- package/src/framework-schema.ts +15 -5
- package/src/generate-files.ts +1 -0
- package/src/generate-grant-findings.ts +7 -5
- package/src/generate-grants.ts +9 -8
- package/src/generate-kinds.ts +30 -6
- package/src/generate-roles-file.ts +30 -0
- package/src/generate-slice-policy.ts +3 -3
- package/src/guard-sources.ts +1 -2
- package/src/guards.ts +2 -2
- package/src/heavy-env.ts +2 -0
- package/src/heavy-errors.ts +18 -0
- package/src/heavy-holders.ts +78 -0
- package/src/heavy-ledger.ts +56 -14
- package/src/heavy-pressure.ts +104 -0
- package/src/heavy.ts +31 -13
- package/src/i18n-registration.ts +22 -2
- package/src/island-harness.ts +2 -2
- package/src/job-budget.ts +4 -2
- package/src/job-registration.ts +64 -8
- package/src/jobs-queue-known.ts +43 -0
- package/src/mcp-errors-agents.ts +20 -0
- package/src/mcp-errors-doctor.ts +27 -0
- package/src/mcp-errors-processes.ts +23 -0
- package/src/mcp-errors.ts +15 -29
- package/src/mcp-host.ts +2 -2
- package/src/merge-driver-catalog.ts +58 -0
- package/src/merge-driver-config.ts +43 -0
- package/src/merge-driver-lines.ts +140 -0
- package/src/merge-state.ts +105 -0
- package/src/messages-db.ts +22 -1
- package/src/messages-processes.ts +13 -0
- package/src/messages-upgrade.ts +10 -0
- package/src/messages.ts +54 -4
- package/src/output-findings.ts +48 -21
- package/src/page-navigation.ts +5 -2
- package/src/parse.ts +37 -6
- package/src/policy-facts.ts +38 -21
- package/src/policy-row.ts +99 -0
- package/src/port-pair-free.ts +28 -0
- package/src/pwa-artifacts.ts +1 -1
- package/src/registry-lines.ts +110 -0
- package/src/registry.ts +2 -0
- package/src/retain-sweep.ts +1 -1
- package/src/retained-assets-boot.ts +1 -1
- package/src/role-replicator.ts +4 -1
- package/src/role-select.ts +86 -0
- package/src/role-start.ts +13 -55
- package/src/role-sync.ts +10 -5
- package/src/runtime-assets-site.ts +2 -2
- package/src/runtime-assets.ts +1 -1
- package/src/runtime-cache-frame.ts +46 -0
- package/src/runtime-cache-ttl.ts +23 -0
- package/src/runtime-cache.ts +33 -16
- package/src/runtime-database-ssl.ts +84 -0
- package/src/runtime-idempotency-scope.ts +16 -2
- package/src/runtime-jobs-share.ts +52 -0
- package/src/runtime-jobs.ts +43 -12
- package/src/runtime-queue.ts +18 -3
- package/src/runtime-render-document.ts +1 -2
- package/src/runtime-services.ts +8 -1
- package/src/schema-drift.ts +19 -2
- package/src/schema-dump-drift.ts +4 -1
- package/src/serve-boot-probe.ts +30 -2
- package/src/serve-boot.ts +11 -1
- package/src/serve-env.ts +39 -3
- package/src/serve.ts +61 -10
- package/src/site-asset-routes.ts +2 -2
- package/src/site-assets.ts +5 -158
- package/src/stop-run-start.ts +12 -0
- package/src/supervise-boot.ts +61 -0
- package/src/supervise-cgroup.ts +84 -0
- package/src/supervise-child.ts +206 -0
- package/src/supervise-count.ts +244 -0
- package/src/supervise-errors.ts +83 -0
- package/src/supervise-facts.ts +40 -0
- package/src/supervise-messages.ts +84 -0
- package/src/supervise-policy.ts +46 -0
- package/src/supervise-pool.ts +10 -0
- package/src/supervise-probe.ts +158 -0
- package/src/supervise-run.ts +54 -0
- package/src/supervise.ts +383 -0
- package/src/sw-precache-plan.ts +1 -1
- package/src/templates/generate-purge.ts +6 -6
- package/src/templates/guard-animated-layout-property.ts +2 -2
- package/src/templates/guard-bare-error.ts +1 -1
- package/src/templates/guard-error-declared.ts +2 -2
- package/src/templates/guard-focus-visible.ts +1 -1
- package/src/templates/guard-image-dimensions.ts +2 -2
- package/src/templates/guard-island-mount-clears.ts +1 -1
- package/src/templates/guard-native-confirm.ts +1 -1
- package/src/templates/guard-raw-breakpoint.ts +2 -2
- package/src/templates/guard-raw-colour.ts +2 -2
- package/src/templates/guard-raw-fetch.ts +1 -1
- package/src/templates/guard-raw-interval.ts +1 -1
- package/src/templates/guard-raw-length.ts +3 -3
- package/src/templates/guard-raw-motion.ts +97 -1
- package/src/templates/guard-raw-shadow.ts +1 -1
- package/src/templates/guard-raw-z-index.ts +1 -1
- package/src/templates/guard-released-forms.ts +58 -9
- package/src/templates/guard-repo-await-in-loop.ts +1 -1
- package/src/templates/guard-repo-raw-sql.ts +4 -4
- package/src/templates/guard-repo-unbounded.ts +1 -1
- package/src/templates/guard-runtime-pin.ts +1 -1
- package/src/templates/guard-semantic-interactive.ts +2 -2
- package/src/templates/guard-unbounded-fanout.ts +1 -1
- package/src/templates/guard-undeclared-custom-property.ts +3 -3
- package/src/templates/guard-undefined-style-class.ts +3 -3
- package/src/templates/guard-unzoned-date.ts +3 -3
- package/src/templates/query-slice.ts +82 -0
- package/src/templates/query.ts +76 -30
- package/src/templates/resource-page.ts +3 -2
- package/src/templates/scaffold-bin.ts +2 -0
- package/src/templates/scaffold-claude-commands.ts +6 -0
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +47 -7
- package/src/templates/scaffold-docs.ts +7 -3
- package/src/templates/scaffold-gitattributes.ts +18 -1
- package/src/templates/scaffold-helm-templates.ts +9 -0
- package/src/templates/scaffold-repo.ts +5 -2
- package/src/templates/scaffold-test-services.ts +33 -11
- package/src/templates/shapes/offline.ts +0 -7
- package/src/templates/shapes/realtime.ts +2 -6
- package/src/templates/sign-in-action-tests.ts +6 -4
- package/src/templates/sign-in-challenge.ts +62 -0
- package/src/templates/sign-in-oidc-mfa.ts +31 -0
- package/src/templates/sign-in-oidc.ts +11 -3
- package/src/templates/sign-in-password.ts +18 -56
- package/src/test-only-shipped.ts +29 -2
- package/src/test-shards.ts +134 -42
- package/src/test-verdict.ts +79 -0
- package/src/test-workers.ts +15 -0
- package/src/upgrade-coverage-ratchet.ts +95 -0
- package/src/upgrade-gate-codemods.ts +5 -3
- package/src/upgrade-gate.ts +42 -4
- package/src/upgrade-merge-drivers.ts +25 -0
- package/src/upgrade-report.ts +32 -4
- package/src/upgrade-scope.ts +62 -0
- package/src/verify-checks.ts +2 -8
- package/src/verify-coverage-run.ts +4 -1
- package/src/verify-e2e.ts +21 -3
- package/src/verify-live.ts +38 -14
- package/src/verify-only.ts +67 -0
- package/src/verify-progress.ts +7 -3
- package/src/verify-run.ts +20 -2
- package/src/verify-services-stack.ts +165 -0
- package/src/verify-services.ts +84 -2
- package/src/verify-test-run.ts +6 -7
- package/src/verify-tests.ts +8 -2
- package/src/verify-typecheck.ts +25 -2
- package/src/workspace-checks.ts +4 -1
- package/wiki/Actions.md +66 -3
- package/wiki/Admin-Dashboard.md +2 -2
- package/wiki/Agents.md +5 -5
- package/wiki/Auth.md +20 -6
- package/wiki/Bare-VM.md +1 -1
- package/wiki/CI-Parallel-Gate.md +2 -1
- package/wiki/CLI-Reference.md +115 -42
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Client-Navigation.md +35 -5
- package/wiki/Configuration.md +12 -10
- package/wiki/Deployment.md +44 -4
- package/wiki/Entities-And-Migrations.md +17 -3
- package/wiki/FAQ.md +1 -1
- package/wiki/Getting-Started.md +2 -2
- package/wiki/Home.md +3 -3
- package/wiki/I18n.md +6 -4
- package/wiki/Installation.md +12 -11
- package/wiki/Interface-Rules.md +3 -1
- package/wiki/Jobs-And-Workflows.md +24 -4
- package/wiki/Known-Gaps.md +2 -2
- package/wiki/MCP-And-AI.md +48 -13
- package/wiki/Many-Agents.md +69 -2
- package/wiki/Migrations-And-Backfills.md +18 -0
- package/wiki/Notify.md +5 -3
- package/wiki/Observability.md +13 -0
- package/wiki/Outbound-HTTP.md +53 -2
- package/wiki/Policies-And-Authz.md +1 -1
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +24 -7
- package/wiki/Routes-And-Render-Modes.md +2 -2
- package/wiki/Scheduled-Tasks.md +4 -1
- package/wiki/Static-Assets.md +5 -3
- package/wiki/Testing.md +64 -7
- package/wiki/Theming.md +6 -3
- package/wiki/Timezones-And-Dates.md +5 -1
- package/wiki/Troubleshooting.md +1 -0
- package/wiki/Tutorial-01-First-App.md +3 -3
- package/wiki/Tutorial-02-First-Feature.md +1 -1
- package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
- package/wiki/UI-Components.md +1 -0
- package/wiki/Upgrading.md +38 -0
package/src/messages.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { DB_MESSAGES } from './messages-db';
|
|
|
8
8
|
import { FLOOR_MESSAGES } from './messages-floor';
|
|
9
9
|
import { GATE_MESSAGES } from './messages-gate';
|
|
10
10
|
import { OPS_MESSAGES } from './messages-ops';
|
|
11
|
+
import { PROCESSES_MESSAGES } from './messages-processes';
|
|
11
12
|
import { REPRO_MESSAGES } from './messages-repro';
|
|
12
13
|
import { SHOT_MESSAGES } from './messages-shot';
|
|
13
14
|
import { STATUS_MESSAGES } from './messages-status';
|
|
@@ -127,6 +128,7 @@ const CATALOG = {
|
|
|
127
128
|
'cli.docs.installed': 'installed: {list}',
|
|
128
129
|
'cli.docs.tryErrors': 'every X_* code, with its fix',
|
|
129
130
|
'cli.docs.tryActions': "this app's own primitives, not the framework's",
|
|
131
|
+
'cli.docs.tryTopic': 'any topic id above prints that section whole',
|
|
130
132
|
'cli.docs.found': '{count} doc(s) for "{query}"',
|
|
131
133
|
'cli.docs.none': 'no framework doc matches "{query}"',
|
|
132
134
|
'cli.docs.unresolved': 'the installed framework packages could not be located',
|
|
@@ -241,12 +243,18 @@ const CATALOG = {
|
|
|
241
243
|
'cli.policy.explained': '{subject} — allowed for {allowed} of {evaluations} actor evaluation(s)',
|
|
242
244
|
'cli.policy.allow': 'allow',
|
|
243
245
|
'cli.policy.deny': 'deny',
|
|
246
|
+
'cli.policy.needsInput': 'needs input',
|
|
247
|
+
'cli.policy.explainedPending':
|
|
248
|
+
'{subject} — allowed for {allowed} of {evaluations} actor evaluation(s); {pending} not denied, decided by a predicate that reads the request input — {command}',
|
|
249
|
+
'cli.policy.withInput':
|
|
250
|
+
'evaluated on --input, with no row — a row-level rule decides again on the real request',
|
|
251
|
+
'cli.policy.undecidableInput':
|
|
252
|
+
'not decidable on this --input — the policy threw reading it: a field the JSON does not carry, or a row rule',
|
|
244
253
|
'cli.policy.declaration': '{kind} {name} — policy {label}',
|
|
245
254
|
/** The empty cell in a `x policy list` column — a value, not a column key. */
|
|
246
255
|
'cli.policy.none': '-',
|
|
247
256
|
'cli.policy.noInput':
|
|
248
257
|
'evaluated with no request input and no row — a rule reading either decides again on the real request',
|
|
249
|
-
'cli.policy.undecidable': 'not decidable outside a request — this policy reads request input',
|
|
250
258
|
'cli.policy.unenforced': '{count} permission(s) no action or query enforces:',
|
|
251
259
|
'cli.registry.count': '{count} {kind}',
|
|
252
260
|
'cli.registry.described': '{kind} {name}',
|
|
@@ -256,6 +264,7 @@ const CATALOG = {
|
|
|
256
264
|
'sealed {sealed} second-factor secret(s); {already} already sealed, {skipped} changed mid-run and left alone',
|
|
257
265
|
'cli.tasks.count': '{count} task(s)',
|
|
258
266
|
'cli.tasks.shown': '{name} — {cron} ({tz}), next {next}',
|
|
267
|
+
'cli.tasks.ran': '{name} fired now — {count} job(s) enqueued; a worker (x dev) runs them',
|
|
259
268
|
'cli.test.fail': '{failed} of {workers} shard(s) failed',
|
|
260
269
|
'cli.test.affected.none': 'nothing is affected by {base}...HEAD — 0 test file(s) ran',
|
|
261
270
|
'cli.test.empty': 'no test file matches {selection} — 0 test file(s) ran (--allow-empty)',
|
|
@@ -265,6 +274,8 @@ const CATALOG = {
|
|
|
265
274
|
'cli.test.sampled': 'sampled {kept} of {total} {type} file(s)',
|
|
266
275
|
'cli.test.type.fail': '{type} — {failed} of {workers} shard(s) failed',
|
|
267
276
|
'cli.test.type.pass': '{type} — {files} test file(s) on {workers} worker(s) passed in {ms}ms',
|
|
277
|
+
'cli.test.allSkipped':
|
|
278
|
+
'{label} — 0 test(s) ran: all {skipped} skipped themselves, so nothing was checked',
|
|
268
279
|
'cli.clean.nothing': 'nothing to clean: no test leftovers under this app',
|
|
269
280
|
'cli.clean.removed': 'removed {paths} path(s) and {databases} probe database(s)',
|
|
270
281
|
'cli.clean.would':
|
|
@@ -272,6 +283,8 @@ const CATALOG = {
|
|
|
272
283
|
'cli.env.checked': '{count} declared variable(s), all present and valid',
|
|
273
284
|
'cli.env.invalid': '{count} of {total} declared variable(s) missing or malformed',
|
|
274
285
|
'cli.env.checkedAsProduction': 'checked as production: no ULTIMATE_ENV named',
|
|
286
|
+
'cli.env.checkedAsDevelopment':
|
|
287
|
+
'checked as development, as x dev runs here: no ULTIMATE_ENV named — a deploy: ULTIMATE_ENV=production x env check',
|
|
275
288
|
'cli.env.wrote': 'wrote {path} — {count} declared variable(s)',
|
|
276
289
|
'cli.env.fresh': '{path} already matches the declaration',
|
|
277
290
|
'cli.env.initialised': 'wrote {path} — {count} value(s), secrets generated and never printed',
|
|
@@ -315,19 +328,56 @@ const CATALOG = {
|
|
|
315
328
|
...UPGRADE_MESSAGES,
|
|
316
329
|
...GATE_MESSAGES,
|
|
317
330
|
...OPS_MESSAGES,
|
|
331
|
+
...PROCESSES_MESSAGES,
|
|
318
332
|
...FLOOR_MESSAGES,
|
|
319
333
|
...STATUS_MESSAGES,
|
|
320
334
|
'cli.heavy.waiting':
|
|
321
|
-
'heavy: {label} waits for {need} MB, position {position} of {queued}; {used} of {capacity} MB held by {holders}',
|
|
322
|
-
'cli.heavy.
|
|
335
|
+
'heavy: {label} waits for {need} MB, position {position} of {queued}; {used} of {capacity} MB held by {holders} — leave it running; it starts by itself (bunx x heavy status)',
|
|
336
|
+
'cli.heavy.waitingAdmission':
|
|
337
|
+
'heavy: {label} waits for {need} MB, position {position} of {queued}; admission in progress — leave it running; it starts by itself (bunx x heavy status)',
|
|
338
|
+
'cli.heavy.waitingCpu':
|
|
339
|
+
'heavy: {label} waits for CPU, position {position} of {queued}: {cpu}; running: {holders} — leave it running; it starts by itself (bunx x heavy status)',
|
|
340
|
+
'cli.heavy.cpu.psi': 'CPU pressure {value}% (new runs wait at {limit}%)',
|
|
341
|
+
'cli.heavy.cpu.runnable': '{value} runnable tasks per core (new runs wait at {limit})',
|
|
342
|
+
'cli.heavy.status.cpu': 'cpu: {cpu} — a new heavy run waits while another is running',
|
|
343
|
+
'cli.heavy.status.cpuOff': 'cpu: {cpu} — not gating here ({reason})',
|
|
344
|
+
'cli.heavy.lockWait':
|
|
345
|
+
'heavy: waiting for this checkout’s {name} lock, held by {holder} — leave it running; it starts by itself',
|
|
323
346
|
'cli.heavy.status.summary':
|
|
324
347
|
'{used} of {capacity} MB reserved, {holds} running, {queued} queued; {cores} core(s) per run',
|
|
325
348
|
'cli.heavy.status.off': 'admission is off here ({reason}); {cores} core(s) per run',
|
|
326
349
|
'cli.heavy.status.machine':
|
|
327
350
|
'machine: load {load} on {cpus} cores, {runnable} runnable, {free} GB of {total} GB available',
|
|
328
|
-
'cli.heavy.status.hold': 'running: {entry}',
|
|
351
|
+
'cli.heavy.status.hold': 'running: {entry}; {pids}',
|
|
352
|
+
'cli.heavy.status.wrapper': 'wrapper pid {pid}',
|
|
353
|
+
'cli.heavy.status.wrapperGone': 'wrapper pid {pid} exited',
|
|
354
|
+
'cli.heavy.status.command': 'command pid {pids}',
|
|
329
355
|
'cli.heavy.status.queued': 'queued {position}: {entry}',
|
|
330
356
|
'cli.heavy.run.done': '{command} exited {code} after {ran}, {waited} in the queue',
|
|
357
|
+
// `test-workers.ts`: a step line for a run the machine held below its plan.
|
|
358
|
+
'cli.test.narrowed': 'ran {peak} at once (peak), planned {planned}',
|
|
359
|
+
'cli.test.narrowedWhy':
|
|
360
|
+
'ran {peak} at once (peak), planned {planned} — the machine allowed no more (bunx x heavy status); plan: {reason}',
|
|
361
|
+
// `verify-live.ts`: which test stack the suites got, one line on stderr.
|
|
362
|
+
'cli.verify.services.line.started':
|
|
363
|
+
'services: started {project} ({services}) — bunx x clean --services stops it',
|
|
364
|
+
'cli.verify.services.line.reused':
|
|
365
|
+
'services: reused {project} — bunx x clean --services stops it',
|
|
366
|
+
'cli.verify.services.line.shared':
|
|
367
|
+
'services: shared {project} with {other} ({why}) — it stays up for that checkout too',
|
|
368
|
+
'cli.verify.services.why.same-app': 'another checkout of this app',
|
|
369
|
+
'cli.verify.services.why.declared': 'ULTIMATE_TEST_SERVICES_SHARED=1',
|
|
370
|
+
// `clean-services.ts`: what `x clean --services` did to the stack, and the ones it left alone.
|
|
371
|
+
'cli.clean.services.stopped': 'stopped test stack {project} ({services})',
|
|
372
|
+
'cli.clean.services.would-stop':
|
|
373
|
+
'would stop test stack {project} ({services}) — --dry-run stopped nothing',
|
|
374
|
+
'cli.clean.services.kept':
|
|
375
|
+
'kept test stack {project}: {owner} started it and may be using it — stop it from there, or: docker compose -p {project} down --volumes',
|
|
376
|
+
'cli.clean.services.none': 'no test stack is running for this app',
|
|
377
|
+
'cli.clean.services.other':
|
|
378
|
+
'other test stack {project} ({status}) from {root} — left alone; stop it with: docker compose -p {project} down --volumes',
|
|
379
|
+
'cli.clean.services.otherGone':
|
|
380
|
+
'other test stack {project} ({status}) from {root}, a checkout that no longer exists — left alone; stop it with: docker compose -p {project} down --volumes',
|
|
331
381
|
} as const;
|
|
332
382
|
|
|
333
383
|
export type MessageKey = keyof typeof CATALOG;
|
package/src/output-findings.ts
CHANGED
|
@@ -21,14 +21,32 @@ const commandWordAt = (fix: string, from: number): number => {
|
|
|
21
21
|
const isBareX = (fix: string, at: number): boolean =>
|
|
22
22
|
fix[at] === 'x' && (at + 1 === fix.length || fix[at + 1] === ' ');
|
|
23
23
|
|
|
24
|
+
/** What may stand before a quote that opens one: after a letter or a `"` it is an apostrophe. */
|
|
25
|
+
const BEFORE_QUOTE = /[\s([{=,:]/;
|
|
26
|
+
/** What may stand before a cited `x`: `apps/web/x.ts` and `max y` cite nothing. */
|
|
27
|
+
const BEFORE_CITATION = /[\s(`]/;
|
|
28
|
+
/** A runner already in front of this `x`. `then run x verify` has none: `run` alone is prose. */
|
|
29
|
+
const RUNNER_BEFORE = /(?:^|\s)(?:bunx|npx|bun|bun run|--bun)\s+$/;
|
|
30
|
+
|
|
31
|
+
const opensQuote = (fix: string, at: number): boolean =>
|
|
32
|
+
(fix[at] === "'" || fix[at] === '"') && (at === 0 || BEFORE_QUOTE.test(fix[at - 1] ?? ''));
|
|
33
|
+
|
|
34
|
+
/** `x <command>` anywhere in the line: a `then: x verify` tail is followed as literally as a head. */
|
|
35
|
+
const citesX = (fix: string, at: number): boolean =>
|
|
36
|
+
fix[at] === 'x' &&
|
|
37
|
+
fix[at + 1] === ' ' &&
|
|
38
|
+
/[a-z<]/.test(fix[at + 2] ?? '') &&
|
|
39
|
+
(at === 0 || BEFORE_CITATION.test(fix[at - 1] ?? '')) &&
|
|
40
|
+
!RUNNER_BEFORE.test(fix.slice(0, at));
|
|
41
|
+
|
|
24
42
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
43
|
+
* Every `x` the line tells its reader to run becomes `bunx x`: the head of each `&&`, `||` and `;`
|
|
44
|
+
* segment, and a citation anywhere after it, a `#` or `//` tail included, because a reader follows
|
|
45
|
+
* `# then: x verify` too. A quoted span is an argument and is copied. `bunx x` itself does not
|
|
46
|
+
* match, so a report read back by `x verify merge` and rendered again does not grow.
|
|
28
47
|
*/
|
|
29
48
|
export function runnableFix(fix: string): string {
|
|
30
49
|
let out = '';
|
|
31
|
-
let quote: string | undefined;
|
|
32
50
|
let at = 0;
|
|
33
51
|
let segmentStart = true;
|
|
34
52
|
while (at < fix.length) {
|
|
@@ -36,27 +54,32 @@ export function runnableFix(fix: string): string {
|
|
|
36
54
|
const word = commandWordAt(fix, at);
|
|
37
55
|
out += fix.slice(at, word);
|
|
38
56
|
at = word;
|
|
39
|
-
if (isBareX(fix, at)) out += 'bunx ';
|
|
40
57
|
segmentStart = false;
|
|
58
|
+
if (isBareX(fix, at)) {
|
|
59
|
+
out += 'bunx x';
|
|
60
|
+
at += 1;
|
|
61
|
+
}
|
|
41
62
|
continue;
|
|
42
63
|
}
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} else if (char === '#' && (at === 0 || fix[at - 1] === ' ')) {
|
|
49
|
-
return out + fix.slice(at);
|
|
50
|
-
} else {
|
|
51
|
-
const end = SEGMENT_END.exec(fix.slice(at));
|
|
52
|
-
if (end !== null) {
|
|
53
|
-
out += end[0];
|
|
54
|
-
at += end[0].length;
|
|
55
|
-
segmentStart = true;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
64
|
+
const close = opensQuote(fix, at) ? fix.indexOf(fix[at] ?? '', at + 1) : -1;
|
|
65
|
+
if (close !== -1) {
|
|
66
|
+
out += fix.slice(at, close + 1);
|
|
67
|
+
at = close + 1;
|
|
68
|
+
continue;
|
|
58
69
|
}
|
|
59
|
-
|
|
70
|
+
const end = SEGMENT_END.exec(fix.slice(at));
|
|
71
|
+
if (end !== null) {
|
|
72
|
+
out += end[0];
|
|
73
|
+
at += end[0].length;
|
|
74
|
+
segmentStart = true;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (citesX(fix, at)) {
|
|
78
|
+
out += 'bunx x';
|
|
79
|
+
at += 1;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
out += fix[at] ?? '';
|
|
60
83
|
at += 1;
|
|
61
84
|
}
|
|
62
85
|
return out;
|
|
@@ -106,6 +129,10 @@ export interface ReaderOptions {
|
|
|
106
129
|
readonly bunxRunner?: boolean;
|
|
107
130
|
}
|
|
108
131
|
|
|
132
|
+
/** One fix line outside a finding: a pointer on stderr, or `x errors explain`'s answer. */
|
|
133
|
+
export const fixForReader = (fix: string, reader: ReaderOptions = {}): string =>
|
|
134
|
+
reader.bunxRunner === true ? runnableFix(fix) : fix;
|
|
135
|
+
|
|
109
136
|
/** A finding read out of a CI log is fenced text and is never turned into an instruction. */
|
|
110
137
|
const withRunnableFix = (finding: Finding): Finding => {
|
|
111
138
|
if (finding.source === 'ci-log') return finding;
|
package/src/page-navigation.ts
CHANGED
|
@@ -75,7 +75,9 @@ export async function loadNavigation(root: string): Promise<NavigationDeclaratio
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* A page declaring `navigation` on a surface with no client navigation says something no process
|
|
78
|
-
* can honour — refused at boot, before a single request, for every route in the table.
|
|
78
|
+
* can honour — refused at boot, before a single request, for every route in the table. Except
|
|
79
|
+
* `'document'`: it asks for a real document load, which is what every page of such a surface
|
|
80
|
+
* already gets, so it is honoured there as declared.
|
|
79
81
|
*/
|
|
80
82
|
export function assertRouteNavigation(
|
|
81
83
|
surfaces: readonly NavigationSurface[],
|
|
@@ -83,7 +85,8 @@ export function assertRouteNavigation(
|
|
|
83
85
|
): void {
|
|
84
86
|
for (const entry of entries) {
|
|
85
87
|
const mode = navigationModeOf(entry.config.navigation);
|
|
86
|
-
if (mode === undefined ||
|
|
88
|
+
if (mode === undefined || mode === 'document') continue;
|
|
89
|
+
if (surfaces.some((surface) => surface === entry.surface)) continue;
|
|
87
90
|
throw new RouteNavigationInvalidError(
|
|
88
91
|
`${entry.file} declares navigation: '${mode}', and its surface (${entry.surface}) is not in app.config.ts navigation.client`,
|
|
89
92
|
);
|
package/src/parse.ts
CHANGED
|
@@ -122,11 +122,40 @@ export const wantsJson = (argv: readonly string[]): boolean =>
|
|
|
122
122
|
const HELP_ALIASES = new Set(['--help', '-h', 'help']);
|
|
123
123
|
const VERSION_ALIASES = new Set(['--version', '-v', '-V']);
|
|
124
124
|
|
|
125
|
+
// What an unknown top-level word most likely MEANT, ahead of what it merely resembles. Edit
|
|
126
|
+
// distance answered `x migrate` with `x upgrade` and `x start` with `x stop`: a `fix:` is pasted
|
|
127
|
+
// and run, so a guess that changes state is worse than no guess.
|
|
128
|
+
/**
|
|
129
|
+
* A word other toolchains use, as the `x` argv that does it. Each is held to the shipped parser by
|
|
130
|
+
* `parse.test.ts`, so an entry cannot outlive the command it names.
|
|
131
|
+
*/
|
|
132
|
+
export const COMMAND_INTENTS: Readonly<Record<string, readonly string[]>> = Object.freeze({
|
|
133
|
+
migrate: ['db', 'migrate'],
|
|
134
|
+
seed: ['db', 'seed'],
|
|
135
|
+
start: ['dev'],
|
|
136
|
+
serve: ['dev'],
|
|
137
|
+
server: ['dev'],
|
|
138
|
+
lint: ['verify', '--only', 'lint'],
|
|
139
|
+
typecheck: ['verify', '--only', 'typecheck'],
|
|
140
|
+
tsc: ['verify', '--only', 'typecheck'],
|
|
141
|
+
check: ['verify'],
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
/** The suggestion for `word` (`'db migrate'`), when `commands` has the command it starts with. */
|
|
145
|
+
export function intentFor(word: string, commands: readonly string[]): string | undefined {
|
|
146
|
+
const argv = Object.hasOwn(COMMAND_INTENTS, word) ? COMMAND_INTENTS[word] : undefined;
|
|
147
|
+
const [command] = argv ?? [];
|
|
148
|
+
return argv !== undefined && command !== undefined && commands.includes(command)
|
|
149
|
+
? argv.join(' ')
|
|
150
|
+
: undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
125
153
|
function resolveCommand(token: string, specs: readonly CommandSpec[]): CommandSpec {
|
|
126
154
|
const found = specs.find((spec) => spec.name === token || (spec.aliases ?? []).includes(token));
|
|
127
155
|
if (found !== undefined) return found;
|
|
128
156
|
const names = specs.map((spec) => spec.name);
|
|
129
|
-
|
|
157
|
+
// What the word means before what it resembles: `migrate` is two edits from `upgrade`.
|
|
158
|
+
const suggestion = intentFor(token, names) ?? nearestName(token, names);
|
|
130
159
|
throw new UnknownCommandError(
|
|
131
160
|
suggestion === undefined
|
|
132
161
|
? { path: token, known: names }
|
|
@@ -351,11 +380,13 @@ function readSubcommand(spec: CommandSpec, positionals: readonly string[]): Reso
|
|
|
351
380
|
if (spec.defaultSubcommandTakesPositional === true && suggestion === undefined) {
|
|
352
381
|
return { name: spec.defaultSubcommand, consumed: false };
|
|
353
382
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
383
|
+
// Near nothing: the command's own page, which lists the subcommands it REGISTERS — the command
|
|
384
|
+
// was right, so the top-level `x help` sent the reader back through every other one.
|
|
385
|
+
throw new UnknownCommandError({
|
|
386
|
+
path: `${spec.name} ${token}`,
|
|
387
|
+
known: allowed,
|
|
388
|
+
suggestion: suggestion === undefined ? `help ${spec.name}` : `${spec.name} ${suggestion}`,
|
|
389
|
+
});
|
|
359
390
|
}
|
|
360
391
|
|
|
361
392
|
function blank(command: string, specs: readonly CommandSpec[], json: boolean): ParsedArgs {
|
package/src/policy-facts.ts
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import type { AnyAction } from '@ultimat3/action';
|
|
6
6
|
import { describeActions, getAction } from '@ultimat3/action';
|
|
7
|
-
import type {
|
|
7
|
+
import type { Policy } from '@ultimat3/policy';
|
|
8
8
|
import { knownPermissions, policyMatrix, roleDefinitions, rolesGranting } from '@ultimat3/policy';
|
|
9
9
|
import type { AnyQuery } from '@ultimat3/query';
|
|
10
10
|
import { describeQueries, getQuery } from '@ultimat3/query';
|
|
11
11
|
import { devActors } from './dev-policy';
|
|
12
|
+
import { decided, type ExplainRow, rowWithoutInput } from './policy-row';
|
|
12
13
|
|
|
13
14
|
const isDefined = <T>(value: T | undefined): value is T => value !== undefined;
|
|
14
15
|
|
|
@@ -81,6 +82,12 @@ export function listPolicy(): PolicyListFacts {
|
|
|
81
82
|
export type DeclarationKind = 'action' | 'query';
|
|
82
83
|
export type SubjectKind = 'permission' | DeclarationKind;
|
|
83
84
|
|
|
85
|
+
/** What `x policy explain --input '<json>'` supplies: the request's input, parsed. */
|
|
86
|
+
export interface ExplainOptions {
|
|
87
|
+
/** Absent: no input was given, and a rule that reads one is `needs-input`. */
|
|
88
|
+
readonly input?: { readonly value: unknown } | undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
export interface DeclarationExplanation {
|
|
85
92
|
readonly name: string;
|
|
86
93
|
readonly kind: DeclarationKind;
|
|
@@ -94,12 +101,13 @@ export interface DeclarationExplanation {
|
|
|
94
101
|
readonly permissions: readonly string[];
|
|
95
102
|
readonly label: string;
|
|
96
103
|
/**
|
|
97
|
-
* Whether this policy
|
|
98
|
-
*
|
|
99
|
-
*
|
|
104
|
+
* Whether this policy could be evaluated at all. `false` only when it threw on the input
|
|
105
|
+
* `--input` supplied — a row rule dereferencing a row there is none of, a field the JSON did not
|
|
106
|
+
* carry — and `rows` is then empty, because a partial matrix reads as a verdict. With no input
|
|
107
|
+
* given a throwing predicate is a `needs-input` row instead: the missing input is why it threw.
|
|
100
108
|
*/
|
|
101
109
|
readonly decidable: boolean;
|
|
102
|
-
readonly rows: readonly
|
|
110
|
+
readonly rows: readonly ExplainRow[];
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
export interface SubjectExplanation {
|
|
@@ -118,17 +126,21 @@ type DeclarationMatrix = Pick<DeclarationExplanation, 'decidable' | 'rows'>;
|
|
|
118
126
|
* "every role plus anonymous" builder here is the duplicate axiom 1 bans, and it would drift
|
|
119
127
|
* from the panel's own set the first time a role is renamed.
|
|
120
128
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* straight out of `x policy explain`. One throw makes the whole declaration
|
|
124
|
-
* than half-reported
|
|
125
|
-
* `policyMatrix` stays the only decider; nothing here re-derives one.
|
|
129
|
+
* With `--input` the policy is evaluated on it, actor by actor inside a `try`: `policyMatrix` does
|
|
130
|
+
* not catch, and a row rule dereferencing the row this command has none of threw a bare
|
|
131
|
+
* `TypeError` straight out of `x policy explain`. One throw makes the whole declaration
|
|
132
|
+
* undecidable rather than half-reported.
|
|
126
133
|
*/
|
|
127
|
-
const matrixFor = (policy: Policy): DeclarationMatrix => {
|
|
128
|
-
const
|
|
134
|
+
const matrixFor = (policy: Policy, options: ExplainOptions): DeclarationMatrix => {
|
|
135
|
+
const { input } = options;
|
|
136
|
+
if (input === undefined) {
|
|
137
|
+
return { decidable: true, rows: devActors().map((actor) => rowWithoutInput(policy, actor)) };
|
|
138
|
+
}
|
|
139
|
+
const rows: ExplainRow[] = [];
|
|
129
140
|
for (const actor of devActors()) {
|
|
130
141
|
try {
|
|
131
|
-
|
|
142
|
+
const matrix = policyMatrix(policy, { actors: [actor], input: input.value });
|
|
143
|
+
rows.push(...matrix.rows.map(decided));
|
|
132
144
|
} catch {
|
|
133
145
|
return { decidable: false, rows: [] };
|
|
134
146
|
}
|
|
@@ -136,7 +148,7 @@ const matrixFor = (policy: Policy): DeclarationMatrix => {
|
|
|
136
148
|
return { decidable: true, rows };
|
|
137
149
|
};
|
|
138
150
|
|
|
139
|
-
const explainAction = (action: AnyAction): DeclarationExplanation => {
|
|
151
|
+
const explainAction = (action: AnyAction, options: ExplainOptions): DeclarationExplanation => {
|
|
140
152
|
const descriptor = action.describe();
|
|
141
153
|
return {
|
|
142
154
|
name: descriptor.name,
|
|
@@ -144,11 +156,11 @@ const explainAction = (action: AnyAction): DeclarationExplanation => {
|
|
|
144
156
|
capability: descriptor.capability,
|
|
145
157
|
permissions: descriptor.permissions,
|
|
146
158
|
label: action.policy.label,
|
|
147
|
-
...matrixFor(action.policy),
|
|
159
|
+
...matrixFor(action.policy, options),
|
|
148
160
|
};
|
|
149
161
|
};
|
|
150
162
|
|
|
151
|
-
const explainQuery = (query: AnyQuery): DeclarationExplanation => {
|
|
163
|
+
const explainQuery = (query: AnyQuery, options: ExplainOptions): DeclarationExplanation => {
|
|
152
164
|
const descriptor = query.describe();
|
|
153
165
|
return {
|
|
154
166
|
name: descriptor.name,
|
|
@@ -156,7 +168,7 @@ const explainQuery = (query: AnyQuery): DeclarationExplanation => {
|
|
|
156
168
|
capability: descriptor.capability,
|
|
157
169
|
permissions: descriptor.permissions,
|
|
158
170
|
label: query.policy.label,
|
|
159
|
-
...matrixFor(query.policy),
|
|
171
|
+
...matrixFor(query.policy, options),
|
|
160
172
|
};
|
|
161
173
|
};
|
|
162
174
|
|
|
@@ -188,7 +200,10 @@ export function knownPolicySubjects(): readonly string[] {
|
|
|
188
200
|
];
|
|
189
201
|
}
|
|
190
202
|
|
|
191
|
-
export function explainPolicy(
|
|
203
|
+
export function explainPolicy(
|
|
204
|
+
name: string,
|
|
205
|
+
options: ExplainOptions = {},
|
|
206
|
+
): SubjectExplanation | undefined {
|
|
192
207
|
const resolved = resolveSubject(name);
|
|
193
208
|
if (resolved === undefined) return undefined;
|
|
194
209
|
if (resolved.kind === 'permission') {
|
|
@@ -198,12 +213,12 @@ export function explainPolicy(name: string): SubjectExplanation | undefined {
|
|
|
198
213
|
.filter((descriptor) => enforces(descriptor, permission))
|
|
199
214
|
.map((descriptor) => getAction(descriptor.name))
|
|
200
215
|
.filter(isDefined)
|
|
201
|
-
.map(explainAction),
|
|
216
|
+
.map((action) => explainAction(action, options)),
|
|
202
217
|
...describeQueries()
|
|
203
218
|
.filter((descriptor) => enforces(descriptor, permission))
|
|
204
219
|
.map((descriptor) => getQuery(descriptor.name))
|
|
205
220
|
.filter(isDefined)
|
|
206
|
-
.map(explainQuery),
|
|
221
|
+
.map((query) => explainQuery(query, options)),
|
|
207
222
|
];
|
|
208
223
|
return {
|
|
209
224
|
subject: name,
|
|
@@ -213,7 +228,9 @@ export function explainPolicy(name: string): SubjectExplanation | undefined {
|
|
|
213
228
|
};
|
|
214
229
|
}
|
|
215
230
|
const declaration =
|
|
216
|
-
resolved.kind === 'action'
|
|
231
|
+
resolved.kind === 'action'
|
|
232
|
+
? explainAction(resolved.action, options)
|
|
233
|
+
: explainQuery(resolved.query, options);
|
|
217
234
|
return {
|
|
218
235
|
subject: name,
|
|
219
236
|
kind: resolved.kind,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// One actor's verdict on a policy, with or without the request's input: the row both `x policy
|
|
2
|
+
// explain` and the `/_x` policy panel draw. Without input, a predicate that READS input is
|
|
3
|
+
// `needs-input` — never the deny a stand-in `{}` produced. `policyMatrix` stays the only decider.
|
|
4
|
+
|
|
5
|
+
import type { MatrixRow, NamedActor, Policy } from '@ultimat3/policy';
|
|
6
|
+
import { decideBeforeInput, policyMatrix, reasonOf } from '@ultimat3/policy';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `needs-input` is NOT a denial: the actor passes every clause that reads only the actor, and a
|
|
10
|
+
* predicate then read the request's input — which this command was not given. Reported as a deny
|
|
11
|
+
* it sent the reader to edit a correct policy: every input-scoped rule (all that `x g resource`
|
|
12
|
+
* writes) read "predicate returned false" about the admin who had just succeeded over HTTP.
|
|
13
|
+
*/
|
|
14
|
+
export type ExplainVerdict = 'allow' | 'deny' | 'needs-input';
|
|
15
|
+
|
|
16
|
+
/** A `MatrixRow` that can also say "not decided". `allowed` is `null` exactly when it was not. */
|
|
17
|
+
export interface ExplainRow extends Omit<MatrixRow, 'allowed'> {
|
|
18
|
+
readonly verdict: ExplainVerdict;
|
|
19
|
+
readonly allowed: boolean | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const decided = (row: MatrixRow): ExplainRow => ({
|
|
23
|
+
...row,
|
|
24
|
+
verdict: row.allowed ? 'allow' : 'deny',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A stand-in for the input nobody supplied, which records being READ. Every trap a predicate can
|
|
29
|
+
* reach it through answers "nothing there" — what `{}` answered — and sets the flag, so a verdict
|
|
30
|
+
* that came out of reading it is known to be a verdict about no request at all. `[]` as the
|
|
31
|
+
* target is the array-shaped one: `Array.isArray` sees through a proxy to its target.
|
|
32
|
+
*/
|
|
33
|
+
function absentInput(target: object = {}): { readonly value: object; read(): boolean } {
|
|
34
|
+
let touched = false;
|
|
35
|
+
const touch = <T>(answer: T): T => {
|
|
36
|
+
touched = true;
|
|
37
|
+
return answer;
|
|
38
|
+
};
|
|
39
|
+
const value = new Proxy(target, {
|
|
40
|
+
get: () => touch(undefined),
|
|
41
|
+
has: () => touch(false),
|
|
42
|
+
ownKeys: () => touch([]),
|
|
43
|
+
getOwnPropertyDescriptor: () => touch(undefined),
|
|
44
|
+
});
|
|
45
|
+
return { value, read: () => touched };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The row over one stand-in, or `undefined` when a predicate threw on it. */
|
|
49
|
+
function rowOver(policy: Policy, entry: NamedActor, input: unknown): MatrixRow | undefined {
|
|
50
|
+
try {
|
|
51
|
+
return policyMatrix(policy, { actors: [entry], input }).rows[0];
|
|
52
|
+
} catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Did the verdict depend on the input? Read through a trap, or — for a whole-value check
|
|
59
|
+
* (`Array.isArray(input)`, `input === null`, `typeof input`) that reaches no trap — moved when the
|
|
60
|
+
* stand-in's shape did. A predicate over the actor alone answers the same for every one of them.
|
|
61
|
+
*/
|
|
62
|
+
function inputDecided(policy: Policy, entry: NamedActor, row: MatrixRow | undefined): boolean {
|
|
63
|
+
const array = absentInput([]);
|
|
64
|
+
const others = [array.value, null, ''].map((input) => rowOver(policy, entry, input));
|
|
65
|
+
return (
|
|
66
|
+
array.read() ||
|
|
67
|
+
// A throw is `undefined`, so throwing on one stand-in and not another is a move too.
|
|
68
|
+
others.some((other) => other?.allowed !== row?.allowed)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* One actor with no input to hand the policy. The before-input gate (`decideBeforeInput`, the one
|
|
74
|
+
* the HTTP surface runs before it parses a body) says whether a predicate has to run for this
|
|
75
|
+
* actor at all; when one does, the full evaluation runs over `absentInput()`, and a predicate
|
|
76
|
+
* that read it, threw reading it, or answered otherwise for another stand-in is `needs-input`,
|
|
77
|
+
* never a deny. A predicate that reads only the actor decides as it would on a request.
|
|
78
|
+
* `policyMatrix` stays the only decider.
|
|
79
|
+
*/
|
|
80
|
+
export function rowWithoutInput(policy: Policy, entry: NamedActor): ExplainRow {
|
|
81
|
+
const input = absentInput();
|
|
82
|
+
const row = rowOver(policy, entry, input.value);
|
|
83
|
+
const before = decideBeforeInput(policy, { actor: entry.actor });
|
|
84
|
+
const dependent = before === undefined && (input.read() || inputDecided(policy, entry, row));
|
|
85
|
+
if (row !== undefined && !dependent) return decided(row);
|
|
86
|
+
// Decided whatever the input is, and a predicate past the deciding clause threw on the stand-in.
|
|
87
|
+
if (before !== undefined) {
|
|
88
|
+
const { allowed } = before;
|
|
89
|
+
return decided({ actor: entry.name, allowed, reason: reasonOf(before), deciding: null });
|
|
90
|
+
}
|
|
91
|
+
const clause = row?.deciding ?? policy.label;
|
|
92
|
+
return {
|
|
93
|
+
actor: entry.name,
|
|
94
|
+
verdict: 'needs-input',
|
|
95
|
+
allowed: null,
|
|
96
|
+
deciding: row?.deciding ?? null,
|
|
97
|
+
reason: `not denied — every actor-only clause passes, and ${clause} has a predicate that reads the request input`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The port a "port in use" fix names. On a machine running several dev servers the next pair is
|
|
2
|
+
// often taken as well, and a fix that fails the same way is not a fix. Not `@ultimat3/testing`'s
|
|
3
|
+
// `freePortPair`, which binds; this one only asks.
|
|
4
|
+
|
|
5
|
+
import { PORT_RANGE, portPairAfter } from './flag-number';
|
|
6
|
+
|
|
7
|
+
/** How far to look: past this the machine is unusual and the plain suggestion is as good. */
|
|
8
|
+
const PAIRS_TRIED = 64;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The first pair after `port` with both ports free, walking the way `portPairAfter` points (down at
|
|
12
|
+
* the top of the range). `x dev --port N` binds N and N + 1, so both are asked. The answer is true
|
|
13
|
+
* when asked: another process can still take it.
|
|
14
|
+
*/
|
|
15
|
+
export async function freeDevPortPair(
|
|
16
|
+
port: number,
|
|
17
|
+
isFree: (port: number) => boolean | Promise<boolean>,
|
|
18
|
+
): Promise<number> {
|
|
19
|
+
const first = portPairAfter(port);
|
|
20
|
+
const step = first > port ? 2 : -2;
|
|
21
|
+
let candidate = first;
|
|
22
|
+
for (let tried = 0; tried < PAIRS_TRIED; tried += 1) {
|
|
23
|
+
if (candidate < 1 || candidate + 1 >= PORT_RANGE.max) break;
|
|
24
|
+
if ((await isFree(candidate)) && (await isFree(candidate + 1))) return candidate;
|
|
25
|
+
candidate += step;
|
|
26
|
+
}
|
|
27
|
+
return first;
|
|
28
|
+
}
|
package/src/pwa-artifacts.ts
CHANGED
|
@@ -30,12 +30,12 @@ import {
|
|
|
30
30
|
} from '@ultimat3/pwa';
|
|
31
31
|
import type { AssetPath } from '@ultimat3/render';
|
|
32
32
|
import { assetPathProblem } from '@ultimat3/render';
|
|
33
|
+
import { parseHashedAssetUrl, siteAssetTable } from '@ultimat3/render/server';
|
|
33
34
|
import { loadAppConfig } from './app-config-load';
|
|
34
35
|
import { assetRouteMeta } from './asset-route-meta';
|
|
35
36
|
import { hasSourceIcon, iconPlan, iconRenderer } from './icon-assets';
|
|
36
37
|
import type { AppLocales } from './pwa-manifest-locales';
|
|
37
38
|
import { appLocales, localeMembers, spellIn } from './pwa-manifest-locales';
|
|
38
|
-
import { parseHashedAssetUrl, siteAssetTable } from './site-assets';
|
|
39
39
|
|
|
40
40
|
/** What a browser fetches from `<link rel="manifest">`. The spec's own extension, not `.json`. */
|
|
41
41
|
export const WEB_MANIFEST_PATH = '/manifest.webmanifest';
|