clearotron 0.5.1 → 0.6.0-beta.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/.env.example +7 -7
- package/INSTALL.md +10 -10
- package/QUICKSTART.md +6 -6
- package/README.md +2 -2
- package/THIRD-PARTY-NOTICES.md +4 -4
- package/bin/README.md +2 -2
- package/bin/clearotron.mjs +1 -1
- package/bin/connect.mjs +1 -1
- package/bin/disconnect.mjs +1 -1
- package/bin/example.mjs +2 -2
- package/bin/grant.mjs +1 -1
- package/bin/onboard.mjs +78 -23
- package/bin/start.mjs +49 -18
- package/bin/update.mjs +13 -3
- package/build-info.json +2 -2
- package/docs/DELIVERY.md +1 -1
- package/docs/PORTAL.md +1 -1
- package/docs/RELEASES.md +1 -1
- package/docs/architecture/02-architecture.md +10 -2
- package/docs/architecture/03-run-lifecycle.md +6 -2
- package/docs/architecture/04-configuration-reference.md +3 -3
- package/docs/architecture/05-config-governance.md +5 -4
- package/docs/architecture/08-development-guide.md +4 -4
- package/docs/architecture/09-security-and-data.md +1 -1
- package/{driver/skills/clearance-search/SKILL.md → docs/architecture/retired-manuals/clearance-search-spine.md} +17 -30
- package/{driver/skills/clearance-search/templates/email/generic.md → docs/architecture/retired-manuals/email-generic.md} +1 -1
- package/{driver/skills/clearance-search → docs/architecture/retired-manuals}/template-formatting.md +3 -4
- package/docs/configuration.md +1 -1
- package/docs/decisions/0002-no-dark-functionality.md +5 -0
- package/driver/CHANGELOG.md +60 -0
- package/driver/README.md +11 -1
- package/driver/accepted-order.mjs +13 -5
- package/driver/attempt-rows.mjs +64 -0
- package/driver/attributed-span.mjs +1 -1
- package/driver/authority-trees.mjs +1 -1
- package/driver/best-draft.mjs +3 -3
- package/driver/blind-frame-record.mjs +2 -2
- package/driver/cancel.mjs +3 -2
- package/driver/carry-through.mjs +2 -2
- package/driver/citation-census.json +3 -3
- package/driver/clearance-variants-record.mjs +4 -10
- package/driver/common-law-coverage-status.mjs +3 -3
- package/driver/common-law-receipts.mjs +2 -2
- package/driver/compare.mjs +1 -1
- package/driver/config-inventory.mjs +6 -79
- package/driver/consumption-ledger.mjs +2 -1
- package/driver/contract-dictation-registry.mjs +5 -0
- package/driver/contract-e3-backlog.mjs +45 -66
- package/driver/contract-e3-baseline.json +16 -16
- package/driver/contract-vocabulary.mjs +8 -6
- package/driver/corrections-feedforward.mjs +3 -1
- package/driver/coverage-form-io.mjs +7 -8
- package/driver/coverage-tool.mjs +1 -1
- package/driver/declination-tool.mjs +2 -2
- package/driver/degraded-parts.mjs +9 -9
- package/driver/demo-container.mjs +5 -4
- package/driver/deploy-live-run-guard.mjs +19 -7
- package/driver/derived-state.mjs +2 -2
- package/driver/dev-portal.mjs +2 -1
- package/driver/dispatch-record.mjs +1 -1
- package/driver/disposition-tool.mjs +2 -1
- package/driver/doubt-closure-tool.mjs +2 -2
- package/driver/driver.config.mjs +35 -724
- package/driver/e2e-rounds.mjs +3 -4
- package/driver/engine/CONTRACT.md +3 -0
- package/driver/engine/README.md +2 -0
- package/driver/engine/anthropic-agent.mjs +8 -37
- package/driver/engine/auth.mjs +74 -0
- package/driver/engine/child-record.mjs +1 -1
- package/driver/engine/deny-authority-write.mjs +2 -2
- package/driver/engine/jx-turn.mjs +10 -2
- package/driver/engine/mcp/README.md +1 -1
- package/driver/engine/mcp/band-server.mjs +6 -6
- package/driver/engine/mcp/codex-config.mjs +1 -1
- package/driver/engine/mcp/declination-server.mjs +2 -3
- package/driver/engine/mcp/dispositions-server.mjs +3 -3
- package/driver/engine/mcp/gather-config.mjs +24 -19
- package/driver/engine/mcp/grid-provenance.mjs +1 -1
- package/driver/engine/mcp/held-answers.mjs +5 -5
- package/driver/engine/mcp/perplexity-server.mjs +16 -7
- package/driver/engine/mcp/recording-server.mjs +7 -6
- package/driver/engine/mcp/register-server.mjs +29 -0
- package/driver/engine/mcp/stdio-server.mjs +5 -5
- package/driver/engine/mcp/supplemental.mjs +9 -9
- package/driver/engine/openai-agent.mjs +5 -2
- package/driver/engine/registry.mjs +103 -0
- package/driver/engine/run-choices.mjs +162 -0
- package/driver/engine/stamps.mjs +35 -0
- package/driver/enqueue-schema.mjs +4 -4
- package/driver/envelope-settle.mjs +3 -2
- package/driver/feedback-issues.mjs +1 -1
- package/driver/feedback-mint.mjs +3 -2
- package/driver/feedback-store.mjs +3 -2
- package/driver/findings-model.mjs +1 -1
- package/driver/flag-snapshot.mjs +5 -4
- package/driver/floor-duty.mjs +3 -3
- package/driver/foreign-record-links.mjs +1 -1
- package/driver/frame-diff-record.mjs +2 -8
- package/driver/framework.mjs +1 -1
- package/driver/gate-metrics.mjs +10 -11
- package/driver/gateway.mjs +220 -839
- package/driver/goods-evidence.mjs +10 -6
- package/driver/jx-lanes.mjs +3 -3
- package/driver/jx-units.mjs +31 -37
- package/driver/jx.mjs +44 -59
- package/driver/knockout-assess-record.mjs +3 -3
- package/driver/knockout-caveats.mjs +21 -0
- package/driver/knockout-correction-record.mjs +58 -28
- package/driver/knockout-frame-record.mjs +2 -2
- package/driver/knockout-register-read.mjs +38 -21
- package/driver/knockout-register-record.mjs +5 -6
- package/driver/knockout-review-record.mjs +12 -11
- package/driver/ladder/model-gauge.mjs +88 -0
- package/driver/ladder/next-rung.mjs +296 -0
- package/driver/ladder/rescue.mjs +146 -0
- package/driver/ladder/stage-tools.mjs +57 -0
- package/driver/ladder/turn-failure.mjs +166 -0
- package/driver/log.mjs +2 -2
- package/driver/matter-frame-record.mjs +4 -4
- package/driver/methodology-witness.mjs +2 -2
- package/driver/narrative-refutation-record.mjs +145 -42
- package/driver/one-build-per-run.mjs +62 -0
- package/driver/outbox-backoff.mjs +4 -4
- package/driver/owner-screen.mjs +0 -10
- package/driver/owner-use-check.mjs +2 -28
- package/driver/package.json +1 -1
- package/driver/partial-payload-baseline.json +1 -1
- package/driver/parts-not-completed.mjs +1 -1
- package/driver/pipeline-knockout.mjs +1015 -1001
- package/driver/pipeline.mjs +511 -9265
- package/driver/placement-decisions.mjs +2 -2
- package/driver/placement-form-io.mjs +7 -9
- package/driver/placement-union.mjs +0 -6
- package/driver/plan-stability.mjs +7 -10
- package/driver/portal-acks.mjs +3 -2
- package/driver/portal-confirmation.mjs +48 -0
- package/driver/portal-families.mjs +3 -2
- package/driver/portal-local-auth.mjs +1 -2
- package/driver/portal-routes/README.md +24 -0
- package/driver/portal-routes/admin.mjs +425 -0
- package/driver/portal-routes/compose.mjs +66 -0
- package/driver/portal-routes/config.mjs +118 -0
- package/driver/portal-routes/connect.mjs +283 -0
- package/driver/portal-routes/feedback.mjs +178 -0
- package/driver/portal-routes/me.mjs +165 -0
- package/driver/portal-routes/queue.mjs +64 -0
- package/driver/portal-routes/report.mjs +106 -0
- package/driver/portal-routes/run.mjs +508 -0
- package/driver/portal-routes/runs.mjs +127 -0
- package/driver/portal-routes/usage.mjs +82 -0
- package/driver/portal-runs.mjs +588 -0
- package/driver/portal-service.mjs +78 -2592
- package/driver/portal-static.mjs +3 -1
- package/driver/predelivery-lint.mjs +92 -9
- package/driver/production-pool-guard.mjs +1 -1
- package/driver/profiles.mjs +5 -4
- package/driver/progress.mjs +29 -24
- package/driver/publish/README.md +10 -5
- package/driver/publish/archive-tags.mjs +3 -2
- package/driver/publish/demo-marking.mjs +2 -2
- package/driver/publish/index.mjs +215 -140
- package/driver/publish/knockout.mjs +153 -107
- package/driver/publish/office-record-links.mjs +22 -0
- package/driver/publish/parse.mjs +20 -5
- package/driver/publish/pool-admin.mjs +9 -3
- package/driver/publish/render.mjs +11 -3
- package/driver/publish/report-dates.mjs +3 -4
- package/driver/publish/report-registry.mjs +7 -10
- package/driver/publish/seed-pool.mjs +3 -2
- package/driver/publish/shell.mjs +106 -0
- package/driver/publish/templates/report.css +3 -1
- package/driver/queue-order.mjs +4 -3
- package/driver/record-carry.mjs +0 -9
- package/driver/record-discard.mjs +1 -4
- package/driver/record-fold.mjs +3 -3
- package/driver/record-goods.mjs +5 -5
- package/driver/reference-score.mjs +2 -3
- package/driver/register-capabilities.mjs +0 -6
- package/driver/register-count.mjs +3 -2
- package/driver/register-digest-record.mjs +7 -7
- package/driver/register-fixture-marker.mjs +3 -3
- package/driver/register-plan.mjs +2 -2
- package/driver/register-records.mjs +2 -2
- package/driver/register-taint.mjs +3 -3
- package/driver/register-unit-record.mjs +48 -9
- package/driver/register-unreachable.mjs +4 -3
- package/driver/registry-fidelity.mjs +79 -34
- package/driver/repair-composers.mjs +14 -9
- package/driver/repair-digest.mjs +4 -6
- package/driver/repair-scope.mjs +3 -3
- package/driver/repair-targets.mjs +24 -9
- package/driver/repairs.mjs +44 -58
- package/driver/replay-archive.mjs +7 -7
- package/driver/report-card-record.mjs +3 -3
- package/driver/report-overview-record.mjs +4 -4
- package/driver/research-answers.mjs +38 -6
- package/driver/research-checks.mjs +4 -4
- package/driver/result-noun-fields.mjs +28 -11
- package/driver/review-addresses.mjs +163 -0
- package/driver/rule-shape.mjs +1 -1
- package/driver/run-delivered.mjs +340 -0
- package/driver/run-economics.mjs +8 -26
- package/driver/run-failed.mjs +545 -0
- package/driver/run-integrity.mjs +1 -1
- package/driver/run-outcome.mjs +314 -0
- package/driver/run-park.mjs +23 -0
- package/driver/run-quote.mjs +32 -0
- package/driver/run-record.mjs +352 -0
- package/driver/run-requirements.mjs +22 -0
- package/driver/run-shell.mjs +55 -0
- package/driver/runner.mjs +71 -33
- package/driver/saved-register-pages.mjs +4 -4
- package/driver/score-redaction.mjs +2 -2
- package/driver/search-policy.mjs +12 -13
- package/driver/settle-stamp.mjs +4 -3
- package/driver/skeptic-record.mjs +2 -2
- package/driver/skeptic-search.mjs +1 -1
- package/driver/skills/README.md +7 -7
- package/driver/skills/blind-frame/SKILL.md +1 -2
- package/driver/skills/case-law-citation/SKILL.md +9 -37
- package/driver/skills/case-law-citation/sources/courtlistener.md +1 -3
- package/driver/skills/case-law-citation/sources/eurlex.md +8 -11
- package/driver/skills/case-law-citation/sources/legaldatahunter.md +1 -1
- package/driver/skills/clearance-common-law/SKILL.md +45 -111
- package/driver/skills/clearance-common-law/perplexity-prompts.md +7 -79
- package/driver/skills/clearance-register/SKILL.md +15 -33
- package/driver/skills/clearance-register/digest.md +31 -92
- package/driver/skills/clearance-register/providers/clarivate.md +2 -2
- package/driver/skills/clearance-register/providers/corsearch.md +5 -5
- package/driver/skills/clearance-register/providers/euipo.md +1 -2
- package/driver/skills/clearance-register/providers/free-tier.md +0 -19
- package/driver/skills/clearance-register/providers/signa.md +6 -25
- package/driver/skills/clearance-register/providers/uspto-local.md +0 -24
- package/driver/skills/clearance-register/register-recipes.md +8 -15
- package/driver/skills/clearance-register/status-rules.md +6 -24
- package/driver/skills/clearance-register/unit.md +11 -20
- package/driver/skills/clearance-search/delivery-contract.md +24 -120
- package/driver/skills/clearance-search/field-doctrine-pharma.md +1 -5
- package/driver/skills/clearance-search/firm-wide-reasoning.md +24 -43
- package/driver/skills/clearance-search/phase2-execution.md +29 -77
- package/driver/skills/clearance-search/report-prose.md +3 -4
- package/driver/skills/clearance-search/risk-framework-demo.md +1 -1
- package/driver/skills/clearance-search/risk-framework-triage.manifest.json +3 -3
- package/driver/skills/clearance-search/risk-framework-triage.md +7 -9
- package/driver/skills/clearance-search/risk-framework.manifest.json +1 -1
- package/driver/skills/clearance-search/risk-framework.md +1 -1
- package/driver/skills/clearance-search/synthesis-rules.md +30 -107
- package/driver/skills/clearance-search/worked-examples.md +5 -5
- package/driver/skills/clearance-variants/SKILL.md +46 -45
- package/driver/skills/clearance-variants/transliteration-scripts.md +4 -4
- package/driver/skills/frame-diff/SKILL.md +1 -1
- package/driver/skills/knockout-assess/SKILL.md +6 -14
- package/driver/skills/knockout-frame/SKILL.md +1 -1
- package/driver/skills/matter-frame/SKILL.md +7 -12
- package/driver/skills/matter-frame/watchlist-reference.md +1 -4
- package/driver/skills/narrative-refutation/SKILL.md +20 -30
- package/driver/skills/placement-inquiry/SKILL.md +8 -18
- package/driver/skills-store-provenance.mjs +1 -1
- package/driver/stage-context.mjs +32 -35
- package/driver/stage-freshness.mjs +127 -11
- package/driver/stages-knockout.mjs +49 -22
- package/driver/stages.mjs +88 -283
- package/driver/status-snapshot.mjs +2 -1
- package/driver/steps/correction-cycle.mjs +311 -0
- package/driver/steps/corrections.mjs +644 -0
- package/driver/steps/delivery.mjs +1287 -0
- package/driver/steps/frame-comparison.mjs +922 -0
- package/driver/steps/intake.mjs +84 -0
- package/driver/steps/open-run.mjs +419 -0
- package/driver/steps/overview-and-cards.mjs +899 -0
- package/driver/steps/placement-and-digest.mjs +23 -0
- package/driver/steps/register-sweep.mjs +1563 -0
- package/driver/steps/skeptic-and-follow-up.mjs +831 -0
- package/driver/steps/synthesis.mjs +261 -0
- package/driver/steps/verdict-gate.mjs +968 -0
- package/driver/suite-census.json +403 -91
- package/driver/surface-exit-verdict.mjs +0 -8
- package/driver/synthesis-record.mjs +72 -6
- package/driver/terminal-clamp.mjs +10 -0
- package/driver/tokens.mjs +8 -62
- package/driver/tool-calls.mjs +2 -2
- package/driver/unit-state-verdict.mjs +1 -1
- package/driver/usage-ledger.mjs +2 -1
- package/driver/verify-knockout.mjs +20 -35
- package/driver/verify.mjs +47 -36
- package/driver/web-grid.mjs +3 -4
- package/driver/whatif-memo-run.mjs +2 -2
- package/driver/whatif-queue.mjs +4 -3
- package/driver/withheld-families.mjs +14 -15
- package/driver/worker-heartbeat.mjs +3 -2
- package/driver/write-up-form.mjs +0 -3
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/http-server.mjs +1 -1
- package/mcp-server/lib/brief.mjs +22 -4
- package/mcp-server/lib/events.mjs +2 -2
- package/mcp-server/lib/evidence.mjs +3 -2
- package/mcp-server/lib/findings.mjs +2 -1
- package/mcp-server/lib/knockout.mjs +9 -10
- package/mcp-server/lib/ops.mjs +9 -9
- package/mcp-server/lib/runs.mjs +9 -10
- package/mcp-server/lib/trace.mjs +1 -1
- package/mcp-server/lib/whatif.mjs +2 -3
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +5 -5
- package/package.json +2 -1
- package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-D5rkCjDc.js} +26 -14
- package/portal-ui/dist/index.html +1 -1
- package/portal-ui/package.json +3 -3
- package/providers/README.md +1 -1
- package/providers/_shared/answer-memory.mjs +4 -5
- package/providers/_shared/execute-plan.mjs +48 -1
- package/providers/_shared/records-from-search.mjs +46 -0
- package/providers/clarivate/README.md +2 -2
- package/providers/clarivate/src/adapter.js +147 -0
- package/providers/clarivate/src/core.js +1 -14
- package/{driver/engine/mcp/clarivate-server.mjs → providers/clarivate/src/mount.js} +5 -10
- package/providers/corsearch/README.md +3 -3
- package/providers/corsearch/src/adapter.js +80 -0
- package/providers/corsearch/src/core.js +14 -11
- package/{driver/engine/mcp/corsearch-server.mjs → providers/corsearch/src/mount.js} +5 -10
- package/providers/euipo/README.md +2 -2
- package/providers/euipo/src/adapter.js +85 -0
- package/providers/euipo/src/core.js +1 -1
- package/providers/euipo/src/euipo-client.js +1 -2
- package/{driver/engine/mcp/euipo-server.mjs → providers/euipo/src/mount.js} +5 -10
- package/providers/free-tier/README.md +2 -2
- package/providers/free-tier/src/adapter.js +127 -0
- package/{driver/engine/mcp/free-tier-server.mjs → providers/free-tier/src/mount.js} +5 -10
- package/providers/jx-subclass/coverage.mjs +1 -6
- package/providers/jx-subclass/score-truth.mjs +2 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/perplexity/src/core.js +2 -2
- package/providers/signa/README.md +2 -2
- package/providers/signa/src/adapter.js +157 -0
- package/providers/signa/src/capabilities.js +0 -3
- package/providers/signa/src/core.js +2 -2
- package/{driver/engine/mcp/signa-server.mjs → providers/signa/src/mount.js} +7 -12
- package/providers/signa/src/offices.generated.js +17 -15
- package/providers/uspto-local/README.md +1 -1
- package/providers/uspto-local/bin/verify-index.mjs +1 -1
- package/providers/uspto-local/src/adapter.js +75 -0
- package/{driver/engine/mcp/uspto-local-server.mjs → providers/uspto-local/src/mount.js} +5 -10
- package/scripts/band-shape-probe.mjs +2 -2
- package/scripts/citation-line-check.mjs +7 -7
- package/scripts/compare.mjs +1 -1
- package/scripts/dead-names.mjs +2 -2
- package/scripts/e2e-first-time.mjs +19 -7
- package/scripts/e2e.mjs +13 -13
- package/scripts/engine-probe.mjs +1 -1
- package/scripts/env-audit.mjs +7 -4
- package/scripts/env-classify.mjs +5 -1
- package/scripts/feedback-mint.mjs +1 -1
- package/scripts/freeze-example-run.mjs +7 -7
- package/scripts/mint-suite-census.mjs +2 -2
- package/scripts/nightly-notice.mjs +1 -1
- package/scripts/release-cut-decision.mjs +7 -2
- package/scripts/release-note-required.mjs +26 -9
- package/scripts/release-notes-lint.mjs +3 -2
- package/scripts/release-version-pr-checks.mjs +1 -1
- package/scripts/settings-render-check.mjs +23 -3
- package/scripts/test-run.mjs +5 -5
- package/scripts/travelling-predicates.mjs +1 -1
- package/scripts/undeclared-field-census.mjs +1 -1
- package/scripts/unexecuted-asserts.mjs +1 -1
- package/scripts/verify-publishable.mjs +1 -1
- package/shared/client-door.mjs +1 -1
- package/shared/connect-clients.mjs +1 -1
- package/shared/connector-signin-probe.mjs +1 -1
- package/shared/env-aliases.mjs +1 -1
- package/shared/invocation.mjs +14 -2
- package/shared/names-in-force.mjs +2 -0
- package/shared/register-selection.mjs +2 -2
- package/shared/store-in-repo.mjs +3 -3
- package/shared/summary-blocks.mjs +0 -3
- package/shared/trigger-lane.mjs +1 -1
- package/shared/vacuous-pass.mjs +2 -2
- package/shared/verb-shim.mjs +4 -2
- package/node_modules/exceljs/README.md +0 -3023
package/driver/runner.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import "../shared/env-local.mjs"; // side effect: apply <repo>/.env when THIS
|
|
|
22
22
|
import "./engine/mcp/http-dispatcher.mjs"; // side effect: raise undici headersTimeout (code-side fetches)
|
|
23
23
|
import { readdirSync, renameSync, existsSync, mkdirSync, readFileSync, writeFileSync, appendFileSync, rmSync, statSync } from "node:fs";
|
|
24
24
|
import { join, dirname, basename } from "node:path"; import { studioDirFor } from "../shared/pre-rename-spellings.mjs";
|
|
25
|
-
import {
|
|
25
|
+
import { crossBuildResumeRefusal } from "./one-build-per-run.mjs"; // a run is finished on the build it started on (owner, 2026-11-09)
|
|
26
26
|
// The queue's filename vocabulary, in ONE place — the rule, extended by to the prose-sidecar and
|
|
27
27
|
// claim-sidecar names, because a harness check retyped four of them from memory and false-alarmed on the
|
|
28
28
|
// other nine. Behaviour here is unchanged: the same object and the same three suffixes, sourced.
|
|
@@ -65,7 +65,7 @@ import { drainWhatIfQueues, liveRunDirs } from "./whatif-worker.mjs";
|
|
|
65
65
|
// throw. A self-contained LEGACY job (prose inline in the JSON, no sidecars) assembles unchanged: the overlay
|
|
66
66
|
// loop is a no-op. A present, non-empty sidecar overrides the manifest's value for that field (sidecar wins).
|
|
67
67
|
function assembleJob(procPath, qdir, base) {
|
|
68
|
-
const job =
|
|
68
|
+
const job = readJson(procPath);
|
|
69
69
|
// Prose sidecars share the job's BARE base (<id>.markName.md, …). A manifest mis-named `<id>.manifest.json`
|
|
70
70
|
// — an observed forwarding-agent fumble (live, 2026-06-19) — leaves `base` as "<id>.manifest", so the
|
|
71
71
|
// bare-base sidecars stop matching and the mark name never overlays → the job parks "missing mark name(s)".
|
|
@@ -267,7 +267,7 @@ export function checkRunCaps({ account, caps, queueDirs, inHandTagged = true, no
|
|
|
267
267
|
let files = [];
|
|
268
268
|
try { files = readdirSync(qd).filter(isLiveQueueMarker); } catch { continue; }
|
|
269
269
|
for (const f of files) {
|
|
270
|
-
try { const j =
|
|
270
|
+
try { const j = readJson(join(qd, f)); if (inLane(j.profileKey, j.tenant)) queued++; }
|
|
271
271
|
catch { /* mid-rename / prose sidecar — skip */ }
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -552,6 +552,7 @@ import { procStarttime, parseClaimSidecar, claimAgeMs, claimerIsAlive } from "./
|
|
|
552
552
|
import { isEntrypoint } from "../shared/is-entrypoint.mjs"; // — one entry-point test, all spellings
|
|
553
553
|
import { beat } from "./worker-heartbeat.mjs"; // — is anything draining this install
|
|
554
554
|
import { BRAND } from "../shared/brand.mjs"; // — the operator name in the allowance note, from the tenant seam
|
|
555
|
+
import { ensureDriverDir, paths, readJson } from "./run-record.mjs"; // — one definition of where `_driver/` is
|
|
555
556
|
export { procStarttime, parseClaimSidecar, claimAgeMs, claimerIsAlive };
|
|
556
557
|
|
|
557
558
|
// — a queue running WITHOUT the birth stamp says so, once, out loud. Where no stamp can be read
|
|
@@ -567,7 +568,7 @@ export function claimToken(pid = process.pid) {
|
|
|
567
568
|
if (!st && !starttimeGapAnnounced) {
|
|
568
569
|
starttimeGapAnnounced = true;
|
|
569
570
|
note("[runner] no birth stamp for this pid on this host — neither /proc/<pid>/stat nor `ps` " +
|
|
570
|
-
"answered, so claims record a BARE PID and the
|
|
571
|
+
"answered, so claims record a BARE PID and the PID-reuse " +
|
|
571
572
|
"defence is inactive. Fail-safe direction (a claim whose liveness cannot be proved counts as " +
|
|
572
573
|
"ALIVE): no run is ever double-claimed and no lawyer double-delivered to. What is lost: a " +
|
|
573
574
|
"`.processing` held by a RECYCLED pid is not freed by liveness and waits for the max-claim-age " +
|
|
@@ -710,7 +711,7 @@ function preRunFailNotify(agentId, base, job, reason) {
|
|
|
710
711
|
return Boolean(p);
|
|
711
712
|
}
|
|
712
713
|
|
|
713
|
-
// B3 — guaranteed failure-notice backstop for PRE-TRY throws.
|
|
714
|
+
// B3 — guaranteed failure-notice backstop for PRE-TRY throws. The run-level catch in `runShell` owns every
|
|
714
715
|
// failure inside its try{} (it RETURNS {ok:false, failedStage, …} after notifying — the
|
|
715
716
|
// _driver/failure.json + outbox packet); a throw that reaches runPrepared's catch instead (res.failedStage
|
|
716
717
|
// unset) came from the SETUP code before that try — corrupt profile sidecar, missing framework manifest,
|
|
@@ -735,7 +736,7 @@ async function backstopFailureNotice({ res, job, agentId, base, codename, studio
|
|
|
735
736
|
const owned = codename ? findRunDirFor({ codename, slug, studioRoot, archiveRoot }) : null;
|
|
736
737
|
if (!owned) { preRunFailNotify(agentId, base, job, shortReason); return; }
|
|
737
738
|
if (owned.kind === "archived" || existsSync(join(owned.dir, ".delivered"))) return; // report already delivered
|
|
738
|
-
if (existsSync(
|
|
739
|
+
if (existsSync(paths(owned.dir).failure)) return; // already noticed
|
|
739
740
|
const packet = buildFailurePacket({
|
|
740
741
|
// canonical runId form (charter P1 §3): `<slug>-<date>-<codename>` — owned.dir's leaf IS
|
|
741
742
|
// "<date>-<codename>", so the dated id is derivable even here (matches status.runId + rescan).
|
|
@@ -745,13 +746,13 @@ async function backstopFailureNotice({ res, job, agentId, base, codename, studio
|
|
|
745
746
|
// same per-send invariant as the pipeline's failure path: a fresh notice supersedes an older .sent
|
|
746
747
|
// and its per-channel receipts (B4 — stale receipts would make clearotron-deliver skip this notice)
|
|
747
748
|
try { rmSync(join(owned.dir, ".sent"), { force: true }); } catch { /* none */ }
|
|
748
|
-
try { rmSync(
|
|
749
|
+
try { rmSync(paths(owned.dir).sendReceipts, { force: true }); } catch { /* none */ }
|
|
749
750
|
ensureDriverDir(owned.dir);
|
|
750
|
-
writeFileSync(
|
|
751
|
+
writeFileSync(paths(owned.dir).failure, JSON.stringify(packet, null, 2) + "\n");
|
|
751
752
|
// status flip mirrors the pipeline path (best-effort — packet + marker are the guaranteed lane)
|
|
752
753
|
try {
|
|
753
754
|
const sp = join(owned.dir, "status.json");
|
|
754
|
-
const s =
|
|
755
|
+
const s = readJson(sp);
|
|
755
756
|
writeFileSync(sp, JSON.stringify({ ...s, state: "failed", failedStage: "pre-run", reason: shortReason, reasonTruncated, reasonFull, sendPending: true }, null, 2) + "\n");
|
|
756
757
|
} catch { /* a pre-seed throw leaves no status.json — the packet still notifies */ }
|
|
757
758
|
mkdirSync(config.outboxDir, { recursive: true });
|
|
@@ -1079,6 +1080,18 @@ export function parkCause(res = {}) {
|
|
|
1079
1080
|
// CONCURRENTLY across a queue's prepared jobs — each owns its own .processing/.pid + run dir, and the
|
|
1080
1081
|
// matter-dedup was already settled serially in claimAndPrep. The run-slot cap (acquireRunSlot) bounds how
|
|
1081
1082
|
// many pipelines actually run at once.
|
|
1083
|
+
/** The refusal for resuming this claim's run on the running build, recorded in the run's log, or null. */
|
|
1084
|
+
function resumeRefusalFor({ job, identity, studioRoot, archiveRoot }) {
|
|
1085
|
+
const owned = findRunDirFor({ codename: identity.codename, slug: deriveSlug(job), dateISO: identity.dateISO ?? null, studioRoot, archiveRoot });
|
|
1086
|
+
if (!owned?.dir) return null; // no run folder: the pipeline's own resume refuses that, by name
|
|
1087
|
+
const refused = crossBuildResumeRefusal(owned.dir);
|
|
1088
|
+
if (refused) {
|
|
1089
|
+
note(`[runner] ${identity.codename}: ${refused}`);
|
|
1090
|
+
try { runLog(owned.dir, { event: "resume-refused", reason: refused }); } catch { /* the queue's failure record carries it too */ }
|
|
1091
|
+
}
|
|
1092
|
+
return refused;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1082
1095
|
async function runPrepared({ procPath, base, job }, qdir, agentId, resumeMeta = null) {
|
|
1083
1096
|
const studioRoot = config.studioRootForAgent(agentId);
|
|
1084
1097
|
const archiveRoot = config.archiveRootForAgent(agentId);
|
|
@@ -1107,13 +1120,16 @@ async function runPrepared({ procPath, base, job }, qdir, agentId, resumeMeta =
|
|
|
1107
1120
|
// whole recovery. Stated plainly because the previous wording said the dir "certainly exists", and an
|
|
1108
1121
|
// arm built on that claim reddened main for one commit.
|
|
1109
1122
|
inFlightRuns.set(procPath, { slug: deriveSlug(job), codename: identity.codename, dateISO: identity.dateISO ?? null, agentId, studioRoot, archiveRoot });
|
|
1123
|
+
// A POSTPONED CLAIM OR A CRASH RECLAIM OF A RUN STARTED ON ANOTHER BUILD IS REFUSED here, before the pipeline is
|
|
1124
|
+
// entered, and the refusal takes the failure path below like any other, the client's notice included.
|
|
1125
|
+
const refused = resumeMeta ? resumeRefusalFor({ job, identity, studioRoot, archiveRoot }) : null;
|
|
1110
1126
|
let res;
|
|
1111
1127
|
try {
|
|
1112
1128
|
// Run as the forwarding agent, with the run-dir + archive rooted in THAT agent's workspace (so the
|
|
1113
1129
|
// agent's sandboxed write tool can reach them). Delivery still publishes to the central pool. resumeMeta
|
|
1114
1130
|
// (set by resumePostponed / the crash-reclaim) reuses the prior codename's valid stages via the pipeline
|
|
1115
1131
|
// resume path; a fresh job dispatches its pre-minted identity as a cold start (minted:true).
|
|
1116
|
-
res = await pipeline(job, {
|
|
1132
|
+
res = refused ? { ok: false, reason: refused } : await pipeline(job, {
|
|
1117
1133
|
agent: agentId, studioRoot, archiveRoot,
|
|
1118
1134
|
// A2 — pass the dispatch-persisted dateISO so the RESUME targets the EXACT `${dateISO}-${codename}`
|
|
1119
1135
|
// run dir. Without it the pipeline re-resolves the date via a date-agnostic findRunDate() that could
|
|
@@ -1468,7 +1484,7 @@ export function claimDuePostponed(qdir) {
|
|
|
1468
1484
|
for (const f of readdirSync(qdir).filter((f) => f.endsWith(".postponed"))) {
|
|
1469
1485
|
const base = f.replace(/\.postponed$/, "");
|
|
1470
1486
|
let meta = {};
|
|
1471
|
-
try { meta =
|
|
1487
|
+
try { meta = readJson(join(qdir, `${base}.postponed.meta`)); } catch { /* missing meta -> resume now (fail-open) */ }
|
|
1472
1488
|
if (postponedDueAt(meta, config.rateLimitDefaultBackoffMs) > now) continue; // window not elapsed yet
|
|
1473
1489
|
// STOPPED WHILE PARKED. This is the resume path that most needs the check: a rate-limit park can
|
|
1474
1490
|
// sit for hours, which is exactly when someone gives up and presses Stop — and a park has no turn
|
|
@@ -1571,7 +1587,7 @@ function queueOwnedCodenames() {
|
|
|
1571
1587
|
try {
|
|
1572
1588
|
for (const f of readdirSync(q)) {
|
|
1573
1589
|
if (!f.endsWith(".postponed.meta") && !f.endsWith(".processing.meta")) continue;
|
|
1574
|
-
try { const m =
|
|
1590
|
+
try { const m = readJson(join(q, f)); if (m?.codename) owned.add(m.codename); } catch { /* skip */ }
|
|
1575
1591
|
}
|
|
1576
1592
|
} catch { /* queue dir absent */ }
|
|
1577
1593
|
}
|
|
@@ -1602,7 +1618,7 @@ function queueTerminalCodenames() {
|
|
|
1602
1618
|
try {
|
|
1603
1619
|
for (const f of readdirSync(q)) {
|
|
1604
1620
|
if (!suffixes.some((sfx) => f.endsWith(sfx))) continue;
|
|
1605
|
-
try { const m =
|
|
1621
|
+
try { const m = readJson(join(q, f)); if (m?.codename) settled.add(m.codename); } catch { /* skip */ }
|
|
1606
1622
|
}
|
|
1607
1623
|
} catch { /* queue dir absent */ }
|
|
1608
1624
|
}
|
|
@@ -1646,7 +1662,16 @@ export function resumeClaimIsAbandoned(resumingPath, now = Date.now(), {
|
|
|
1646
1662
|
// needs to see it once would be the person least able to find it.
|
|
1647
1663
|
const announcedTerminalSkips = new Set();
|
|
1648
1664
|
|
|
1649
|
-
|
|
1665
|
+
/** Is there a `.published` at `publishedPath` written no earlier than the park at `parkPath`? Unreadable reads as yes. */
|
|
1666
|
+
export function publishedSincePark(publishedPath, parkPath) {
|
|
1667
|
+
if (!existsSync(publishedPath)) return false;
|
|
1668
|
+
try { return statSync(publishedPath).mtimeMs >= statSync(parkPath).mtimeMs; } catch { return true; }
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
/** Every run folder this watcher will resume on its own, due now or later: what an update has to wait for. */
|
|
1672
|
+
export const parkedRunDirOrphans = (now = Date.now()) => scanDueRunDirOrphans(now, { dueOnly: false });
|
|
1673
|
+
|
|
1674
|
+
export function scanDueRunDirOrphans(now = Date.now(), { dueOnly = true } = {}) {
|
|
1650
1675
|
const owned = queueOwnedCodenames();
|
|
1651
1676
|
const settled = queueTerminalCodenames();
|
|
1652
1677
|
const out = [];
|
|
@@ -1688,11 +1713,18 @@ export function scanDueRunDirOrphans(now = Date.now()) {
|
|
|
1688
1713
|
// `.resuming` stays in this list for the ORDINARY path: a live self-resume must not be re-fired.
|
|
1689
1714
|
// It is excluded only when this run IS the abandoned claim recovered above, which is the whole
|
|
1690
1715
|
// of the change — the fail-safe polarity is unchanged and an unprovable claim still counts alive.
|
|
1691
|
-
|
|
1716
|
+
//
|
|
1717
|
+
// `.published` skips only when it is at least as new as the park. A run that published and then failed in a
|
|
1718
|
+
// later delivery step parks like any other, and its `.published` is older than the park: the resume finds the
|
|
1719
|
+
// record and delivers it without publishing again. A resume deletes the park it resumes (steps/open-run.mjs),
|
|
1720
|
+
// so a park older than the publish is one this watcher must leave alone, as it always has. An unreadable time
|
|
1721
|
+
// reads as moved on.
|
|
1722
|
+
const inFlight = [".delivered", ".failed", ".resuming", ".cancelled", ".cancel"]
|
|
1692
1723
|
.filter((m) => !(abandoned && m === ".resuming"));
|
|
1693
1724
|
if (inFlight.some((m) => existsSync(join(runDir, m)))) continue;
|
|
1725
|
+
if (publishedSincePark(join(runDir, ".published"), sentPath)) continue;
|
|
1694
1726
|
let sent;
|
|
1695
|
-
try { sent =
|
|
1727
|
+
try { sent = readJson(sentPath); } catch { continue; }
|
|
1696
1728
|
if (!sent.job || !sent.agent || !sent.codename) continue; // pre-fix sentinel without payload — leave for manual handling
|
|
1697
1729
|
if (owned.has(sent.codename)) continue; // the queue owns this resume — don't double-fire
|
|
1698
1730
|
// ── — THE OTHER TWO WAYS A STOP IS SPELLED ──────────────────────────
|
|
@@ -1721,7 +1753,7 @@ export function scanDueRunDirOrphans(now = Date.now()) {
|
|
|
1721
1753
|
}
|
|
1722
1754
|
continue;
|
|
1723
1755
|
}
|
|
1724
|
-
if (postponedDueAt(sent, config.rateLimitDefaultBackoffMs) > now) continue; // backoff window not elapsed
|
|
1756
|
+
if (dueOnly && postponedDueAt(sent, config.rateLimitDefaultBackoffMs) > now) continue; // backoff window not elapsed
|
|
1725
1757
|
out.push({ runDir, sentPath, job: sent.job, agent: sent.agent, codename: sent.codename, fromStage: sent.fromStage ?? null, reparks: Number(sent.reparks) || 0, payload: sent });
|
|
1726
1758
|
}
|
|
1727
1759
|
}
|
|
@@ -1783,13 +1815,19 @@ export async function resumeRunDirOrphans(orphans, { runPipeline = pipeline } =
|
|
|
1783
1815
|
// already on disk, and threading them would put the same fact in two places to disagree.
|
|
1784
1816
|
try {
|
|
1785
1817
|
let sent = {};
|
|
1786
|
-
try { sent =
|
|
1818
|
+
try { sent = readJson(claimPath); } catch { /* pre-fix sentinel — log what we have */ }
|
|
1787
1819
|
runLog(o.runDir, { event: "park-resumed", via: "run-dir-sentinel",
|
|
1788
1820
|
probeAttempt: Number(sent?.probeAttempt) || 0, parkedAt: sent?.postponedAt ?? null,
|
|
1789
1821
|
kind: sent?.kind ?? null, fromStage: o.fromStage ?? sent?.fromStage ?? null });
|
|
1790
1822
|
} catch { /* spine append is best-effort */ }
|
|
1791
1823
|
note(`[runner] self-resuming run-dir POSTPONED ${o.codename} (agent=${o.agent} from=${o.fromStage ?? "auto"}; window elapsed)`);
|
|
1792
1824
|
try {
|
|
1825
|
+
// A run started on another build is not resumed, and a re-park cannot change that, so the refusal is final at once.
|
|
1826
|
+
const refused = crossBuildResumeRefusal(o.runDir);
|
|
1827
|
+
if (refused) {
|
|
1828
|
+
try { runLog(o.runDir, { event: "resume-refused", reason: refused }); } catch { /* the .failed sentinel below carries it */ }
|
|
1829
|
+
throw Object.assign(new Error(refused), { final: true });
|
|
1830
|
+
}
|
|
1793
1831
|
await runPipeline(o.job, {
|
|
1794
1832
|
agent: o.agent, codename: o.codename, fromStage: o.fromStage ?? undefined,
|
|
1795
1833
|
studioRoot: config.studioRootForAgent(o.agent), archiveRoot: config.archiveRootForAgent(o.agent),
|
|
@@ -1802,8 +1840,8 @@ export async function resumeRunDirOrphans(orphans, { runPipeline = pipeline } =
|
|
|
1802
1840
|
// it goes terminal (.failed + status), the same honest circuit breaker the pipeline itself uses.
|
|
1803
1841
|
const reparks = (Number(o.reparks) || 0) + 1;
|
|
1804
1842
|
const REPARK_MAX = 3;
|
|
1805
|
-
if (reparks >= REPARK_MAX) {
|
|
1806
|
-
const reasonText = `self-resume errored ${reparks}× — last: ${String(err?.message ?? err).slice(0, 300)}`;
|
|
1843
|
+
if (err?.final || reparks >= REPARK_MAX) {
|
|
1844
|
+
const reasonText = err?.final ? String(err.message) : `self-resume errored ${reparks}× — last: ${String(err?.message ?? err).slice(0, 300)}`;
|
|
1807
1845
|
// — derived ONCE, outside both best-effort try blocks below, because both sinks need it:
|
|
1808
1846
|
// the status write and the failure notice. Computing it inside the status `try` scoped it away
|
|
1809
1847
|
// from the packet, which is the shape that had the packet re-cutting the string on its own.
|
|
@@ -1813,7 +1851,7 @@ export async function resumeRunDirOrphans(orphans, { runPipeline = pipeline } =
|
|
|
1813
1851
|
writeFileSync(join(o.runDir, ".failed"), JSON.stringify({ stage: "self-resume", reason: reasonText, reparks, ts: new Date().toISOString() }, null, 2) + "\n");
|
|
1814
1852
|
try {
|
|
1815
1853
|
const statusPath = join(o.runDir, "status.json");
|
|
1816
|
-
const status =
|
|
1854
|
+
const status = readJson(statusPath);
|
|
1817
1855
|
// — cut VISIBLY. This is a terminal status write and it carried a bare 200-char slice,
|
|
1818
1856
|
// so the cap that hides a cause hid it here too — and reasonText has already lost its own
|
|
1819
1857
|
// tail to a 300-char slice one level up, which is the second cut nobody was told about.
|
|
@@ -1829,12 +1867,12 @@ export async function resumeRunDirOrphans(orphans, { runPipeline = pipeline } =
|
|
|
1829
1867
|
// string with a bare slice, so the notice and status.json could disagree about whether the
|
|
1830
1868
|
// sentence was finished. One cap, one marker, both sinks.
|
|
1831
1869
|
failedStage: "self-resume", shortReason: rt.reason, reasonVerbatim: reasonText,
|
|
1832
|
-
terminalKind: "exhausted", priorAttempts: reparks,
|
|
1870
|
+
terminalKind: err?.final ? undefined : "exhausted", priorAttempts: reparks,
|
|
1833
1871
|
});
|
|
1834
1872
|
try { rmSync(join(o.runDir, ".sent"), { force: true }); } catch { /* none */ }
|
|
1835
|
-
try { rmSync(
|
|
1873
|
+
try { rmSync(paths(o.runDir).sendReceipts, { force: true }); } catch { /* none */ }
|
|
1836
1874
|
ensureDriverDir(o.runDir);
|
|
1837
|
-
writeFileSync(
|
|
1875
|
+
writeFileSync(paths(o.runDir).failure, JSON.stringify(packet, null, 2) + "\n");
|
|
1838
1876
|
mkdirSync(config.outboxDir, { recursive: true });
|
|
1839
1877
|
writeFileSync(join(config.outboxDir, `${packet.runId}.pending`), `${o.agent}\n`);
|
|
1840
1878
|
} catch { /* notice best-effort — .failed + status remain the record */ }
|
|
@@ -1880,10 +1918,10 @@ async function claimAndRun(jsonFile, qdir, agentId) {
|
|
|
1880
1918
|
* Exported for the test; returns what it did so callers can log it. */
|
|
1881
1919
|
export function armUnannouncedDelivery(runDir, label = "") {
|
|
1882
1920
|
try {
|
|
1883
|
-
if (!existsSync(
|
|
1921
|
+
if (!existsSync(paths(runDir).delivery)) return "no-packet";
|
|
1884
1922
|
if (existsSync(join(runDir, ".sent"))) return "already-sent";
|
|
1885
1923
|
let status = {};
|
|
1886
|
-
try { status =
|
|
1924
|
+
try { status = readJson(join(runDir, "status.json")); } catch { /* absent/corrupt ⇒ treat as unarmed */ }
|
|
1887
1925
|
if (status?.sendPending === true) return "already-pending";
|
|
1888
1926
|
const merged = { ...status, state: "delivered", sendPending: true, updatedAt: new Date().toISOString() };
|
|
1889
1927
|
const tmp = join(runDir, `status.json.${process.pid}.${Date.now().toString(36)}.tmp`);
|
|
@@ -1901,8 +1939,8 @@ export function armUnannouncedDelivery(runDir, label = "") {
|
|
|
1901
1939
|
|
|
1902
1940
|
export function runDirDelivered(dir) {
|
|
1903
1941
|
if (existsSync(join(dir, ".delivered"))) return true;
|
|
1904
|
-
if (existsSync(
|
|
1905
|
-
try { return
|
|
1942
|
+
if (existsSync(paths(dir).delivery)) return true;
|
|
1943
|
+
try { return readJson(join(dir, "status.json"))?.state === "delivered"; } catch { return false; }
|
|
1906
1944
|
}
|
|
1907
1945
|
|
|
1908
1946
|
// B1 — where (if anywhere) a codename's run already lives on disk. The live leaf is "<date>-<codename>";
|
|
@@ -2023,7 +2061,7 @@ function reclaimOrphanedClaims(qdir, agentId) {
|
|
|
2023
2061
|
continue;
|
|
2024
2062
|
}
|
|
2025
2063
|
let meta = null;
|
|
2026
|
-
try { meta =
|
|
2064
|
+
try { meta = readJson(`${procPath}.meta`); } catch { /* no/corrupt meta — legacy fresh re-claim */ }
|
|
2027
2065
|
if (meta?.codename) {
|
|
2028
2066
|
let job = null;
|
|
2029
2067
|
try { job = assembleJob(procPath, qdir, base); } catch { /* malformed manifest — the .json path fails it at intake properly */ }
|
|
@@ -2085,9 +2123,9 @@ function reclaimOrphanedClaims(qdir, agentId) {
|
|
|
2085
2123
|
priorAttempts: priorReclaims,
|
|
2086
2124
|
});
|
|
2087
2125
|
try { rmSync(join(owned.dir, ".sent"), { force: true }); } catch { /* none */ }
|
|
2088
|
-
try { rmSync(
|
|
2126
|
+
try { rmSync(paths(owned.dir).sendReceipts, { force: true }); } catch { /* none */ }
|
|
2089
2127
|
ensureDriverDir(owned.dir);
|
|
2090
|
-
writeFileSync(
|
|
2128
|
+
writeFileSync(paths(owned.dir).failure, JSON.stringify(packet, null, 2) + "\n");
|
|
2091
2129
|
mkdirSync(config.outboxDir, { recursive: true });
|
|
2092
2130
|
writeFileSync(join(config.outboxDir, `${packet.runId}.pending`), `${agentId}\n`);
|
|
2093
2131
|
} catch (e) { note(`[runner] ${base} reclaim-terminal bookkeeping failed (non-fatal — the queue marker still ends it): ${e?.message ?? e}`); }
|
|
@@ -2268,7 +2306,7 @@ function hasQueuedWork() {
|
|
|
2268
2306
|
// postponedDueAt is the single source of truth, so the idle gate and the resume gate never disagree
|
|
2269
2307
|
// (a null-resetsAt run is NOT yet work until its postponedAt backoff elapses).
|
|
2270
2308
|
if (f.endsWith(".postponed")) {
|
|
2271
|
-
try { const m =
|
|
2309
|
+
try { const m = readJson(join(q, `${f}.meta`)); return postponedDueAt(m, config.rateLimitDefaultBackoffMs) <= now; }
|
|
2272
2310
|
catch { return true; }
|
|
2273
2311
|
}
|
|
2274
2312
|
return false;
|
|
@@ -2385,7 +2423,7 @@ export async function watch({
|
|
|
2385
2423
|
beatEveryMs = WATCH_TICK_MS,
|
|
2386
2424
|
startBeating = (fn, everyMs) => { const t = setInterval(fn, everyMs); t.unref?.(); return () => clearInterval(t); },
|
|
2387
2425
|
} = {}) {
|
|
2388
|
-
note(`[runner] watch:
|
|
2426
|
+
note(`[runner] watch: checking every ${Math.round(tickMs / 1000)}s for a search to start or to resume. Ctrl-C to stop.`);
|
|
2389
2427
|
for (let n = 0; ; n++) {
|
|
2390
2428
|
if (stopped()) break;
|
|
2391
2429
|
// One bad tick must never end the loop — that would put us back where a laptop started, with nothing
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
//
|
|
24
24
|
// A pure leaf: node:fs, node:path and shared/driver-dir.mjs only, so the goods reader and the band tool server can
|
|
25
25
|
// both import it.
|
|
26
|
-
import {
|
|
26
|
+
import { readdirSync } from "node:fs";
|
|
27
27
|
import { join } from "node:path";
|
|
28
|
-
import {
|
|
28
|
+
import { paths, readJson } from "./run-record.mjs";
|
|
29
29
|
|
|
30
30
|
// The research server's own name for a call's file: the time it was kept, with ":" and "." made "-", the server's
|
|
31
31
|
// process id, and the number of the call.
|
|
@@ -101,7 +101,7 @@ export function statusPagesIn(result) { // @internal — driven by its test
|
|
|
101
101
|
*/
|
|
102
102
|
export function savedStatusPages(runDir) {
|
|
103
103
|
if (!runDir) return () => new Map();
|
|
104
|
-
const dir =
|
|
104
|
+
const dir = paths(runDir).webResults;
|
|
105
105
|
const read = new Map();
|
|
106
106
|
return () => {
|
|
107
107
|
let names = [];
|
|
@@ -109,7 +109,7 @@ export function savedStatusPages(runDir) {
|
|
|
109
109
|
const pages = new Map();
|
|
110
110
|
for (const name of names) {
|
|
111
111
|
if (!read.has(name)) {
|
|
112
|
-
let result; try { result =
|
|
112
|
+
let result; try { result = readJson(join(dir, name)); } catch { continue; }
|
|
113
113
|
read.set(name, statusPagesIn(result));
|
|
114
114
|
}
|
|
115
115
|
for (const { serial, goods } of read.get(name)) {
|
|
@@ -227,8 +227,8 @@ export function protectedStrings(root) {
|
|
|
227
227
|
if (bare.length >= 5 && !LEGAL_FORM.has(bare.toLowerCase())) { names.add(bare); if (!given.has(bare.toLowerCase())) derived.add(bare); }
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
// THE FLOOR STAYS AND THE CASE IT MISSES IS NAMED. A
|
|
231
|
-
//
|
|
230
|
+
// THE FLOOR STAYS AND THE CASE IT MISSES IS NAMED. A maintainers' decision rather than this file's
|
|
231
|
+
// preference: keep the floor, and name the case it does not cover.
|
|
232
232
|
//
|
|
233
233
|
// WHAT IT BUYS: a two-character token is cheap to collide with, and every standalone occurrence of one
|
|
234
234
|
// would go — including words of this harness's own vocabulary. Lowering the floor is a real option and
|
package/driver/search-policy.mjs
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
// BETA POSTURE: runs delivered under the old numbering KEEP it — an archived run re-renders through
|
|
35
35
|
// RETIRED_POLICIES below, which still carries "Depth 4" for the level it was sold as.
|
|
36
36
|
|
|
37
|
-
import {
|
|
37
|
+
import { readdirSync } from "node:fs";
|
|
38
38
|
import { join, dirname } from "node:path";
|
|
39
39
|
import { fileURLToPath } from "node:url";
|
|
40
40
|
import { createHash } from "node:crypto";
|
|
@@ -43,6 +43,7 @@ import { PRODUCT_IDS, productSpec, productFor, maxNamesFor, productName, checkPr
|
|
|
43
43
|
// own static graph to compose-read + territory-tiers for exactly this reason (see its header).
|
|
44
44
|
import { registerCoverageCause, offerableTerritories } from "./register-coverage.mjs";
|
|
45
45
|
import { PROMPT_TERRITORIES } from "./compose-read.mjs"; // — the names a reader can choose from, which is the universe the disclosure counts against
|
|
46
|
+
import { readJson } from "./run-record.mjs";
|
|
46
47
|
|
|
47
48
|
// ── The closed product registry ──────────────────────────────────────────────────────────────────────
|
|
48
49
|
//
|
|
@@ -228,8 +229,6 @@ export const PRODUCT_POLICIES = {
|
|
|
228
229
|
// Pinned with the same provenance in the-doubt-carries-its-placement-tier.test.mjs (RULED_CUTS).
|
|
229
230
|
doubtClosure: "headline-candidate",
|
|
230
231
|
recallFollowupMax: 1,
|
|
231
|
-
envelopeRounds: "one", // one closing round, not to exhaustion
|
|
232
|
-
coverageClosureRounds: "one",
|
|
233
232
|
},
|
|
234
233
|
components: { registerProbe: false, jxLanes: false, commonLawGrid: true },
|
|
235
234
|
web: { questionPreset: "medium", resultsPerCell: 15 },
|
|
@@ -280,8 +279,6 @@ export const PRODUCT_POLICIES = {
|
|
|
280
279
|
// ruling to the most expensive product is not mine to do. Raised as a question rather than
|
|
281
280
|
// assumed —.
|
|
282
281
|
recallFollowupMax: 2,
|
|
283
|
-
envelopeRounds: "as-today",
|
|
284
|
-
coverageClosureRounds: "as-today",
|
|
285
282
|
},
|
|
286
283
|
components: { registerProbe: false, jxLanes: false, commonLawGrid: true },
|
|
287
284
|
web: { questionPreset: "high", resultsPerCell: 20 },
|
|
@@ -302,8 +299,6 @@ export const PRODUCT_POLICIES = {
|
|
|
302
299
|
groundedProfiles: "every-finding",
|
|
303
300
|
doubtClosure: "every-doubt",
|
|
304
301
|
recallFollowupMax: 2, // RECALL_FOLLOWUP_MAX
|
|
305
|
-
envelopeRounds: "as-today",
|
|
306
|
-
coverageClosureRounds: "as-today",
|
|
307
302
|
},
|
|
308
303
|
components: { registerProbe: false, jxLanes: true, commonLawGrid: true },
|
|
309
304
|
web: { questionPreset: "xhigh", resultsPerCell: 25 },
|
|
@@ -459,7 +454,7 @@ export function depthFor(policy) {
|
|
|
459
454
|
// Reading only `product` meant ctx.searchPolicy resolved to `default-ungraded` on EVERY run: the whole
|
|
460
455
|
// ladder ran at one-country depth, every rung returned "", and nothing anywhere failed. Both names are
|
|
461
456
|
// accepted because both shapes reach this function — the frozen policy and a bare {product} selector.
|
|
462
|
-
const key =
|
|
457
|
+
const key = productKeyOf(policy);
|
|
463
458
|
const row = PRODUCT_POLICIES[key]?.depth;
|
|
464
459
|
if (row) return Object.freeze({ ...row, source: key });
|
|
465
460
|
// A product this build KNOWS but does not grade is not the same thing as one it does not recognise.
|
|
@@ -470,6 +465,11 @@ export function depthFor(policy) {
|
|
|
470
465
|
source: known ? `ungraded:${key}` : "default-ungraded" });
|
|
471
466
|
}
|
|
472
467
|
|
|
468
|
+
/** The product a policy names: `level` on a run's frozen policy, `product` on a bare selector. "" when neither. */
|
|
469
|
+
export function productKeyOf(policy) {
|
|
470
|
+
return String(policy?.level ?? policy?.product ?? "").trim();
|
|
471
|
+
}
|
|
472
|
+
|
|
473
473
|
export function isRegisterOnly(policy) {
|
|
474
474
|
return policy?.pipeline === "clearance" && policy?.components?.commonLawGrid === false;
|
|
475
475
|
}
|
|
@@ -529,10 +529,9 @@ export const BUILT = { knockout: true, jxLanes: true, registerProbe: true };
|
|
|
529
529
|
// dir answering with a demo roster. Deleting the switch is the fix that cannot recur; plumbing a
|
|
530
530
|
// snapshot into each new caller is the one that waits for the next caller.
|
|
531
531
|
//
|
|
532
|
-
//
|
|
533
|
-
// (
|
|
534
|
-
//
|
|
535
|
-
// one is ever genuinely needed. `BUILT` remains one edit away for machinery that truly is unfinished.
|
|
532
|
+
// The last of them, the per-language off switch `CLEAROTRON_NATIVE_LANGUAGE_<code>`, is retired too
|
|
533
|
+
// (2026-11-11): no deployment set it, and the owner ruled it removed. `BUILT` remains one edit away for
|
|
534
|
+
// machinery that truly is unfinished.
|
|
536
535
|
|
|
537
536
|
// Admission gate over a RESOLVED policy: null = runnable, else a clarify message. Split from resolution so
|
|
538
537
|
// the runner can distinguish "which product is this" (resolveSearchPolicy) from "may it run HERE, NOW".
|
|
@@ -1115,7 +1114,7 @@ export function loadRecipes({ dir = process.env.CLEAROTRON_RECIPES_DIR || null,
|
|
|
1115
1114
|
try { files = readdirSync(join(dir, customer)).filter((f) => f.endsWith(".json")); } catch (e) { if (!absent(e)) throw e; continue; }
|
|
1116
1115
|
for (const f of files) {
|
|
1117
1116
|
const slug = f.replace(/\.json$/, "");
|
|
1118
|
-
const r =
|
|
1117
|
+
const r = readJson(join(dir, customer, f)); // parse error = loud (config bug)
|
|
1119
1118
|
// A RETIRED extra is dropped here, not refused. Refusing to SAVE one is right — that is the door
|
|
1120
1119
|
// where somebody is asking for a behaviour that no longer exists. Refusing to LOAD one would be a
|
|
1121
1120
|
// different and much worse thing: a key that has never done anything would take out every run that
|
package/driver/settle-stamp.mjs
CHANGED
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
// `writeRO` does, and never touches the directory. Writing into a pool run dir after publish is already
|
|
29
29
|
// how the product works — pool-admin.mjs rewrites `meta.json` there long after the run settles.
|
|
30
30
|
|
|
31
|
-
import { writeFileSync,
|
|
31
|
+
import { writeFileSync, chmodSync } from "node:fs";
|
|
32
32
|
import { join } from "node:path";
|
|
33
|
+
import { readJson } from "./run-record.mjs";
|
|
33
34
|
|
|
34
35
|
/** The stamp's filename inside the pool run directory. One name, read and written from here only. */
|
|
35
36
|
export const SETTLE_FILE = "settle.json";
|
|
@@ -87,7 +88,7 @@ export function writeSettleStamp(poolRunDir, { state, signoff = null, tier = nul
|
|
|
87
88
|
export function readSettleStamp(dir) {
|
|
88
89
|
if (!dir) return null;
|
|
89
90
|
try {
|
|
90
|
-
const s =
|
|
91
|
+
const s = readJson(join(dir, SETTLE_FILE));
|
|
91
92
|
if (!s || typeof s !== "object" || Array.isArray(s)) return null;
|
|
92
93
|
if (s.schema_version !== SETTLE_SCHEMA_VERSION) return null;
|
|
93
94
|
if (typeof s.state !== "string" || !s.state) return null;
|
|
@@ -132,5 +133,5 @@ export function backfillSettleStamp(poolRunDir, runDir, { readStatus = defaultRe
|
|
|
132
133
|
|
|
133
134
|
function defaultReadStatus(runDir) {
|
|
134
135
|
if (!runDir) return null;
|
|
135
|
-
try { return
|
|
136
|
+
try { return readJson(join(runDir, "status.json")); } catch { return null; }
|
|
136
137
|
}
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
37
37
|
import { captureCall, stampVerdict } from "./call-capture.mjs";
|
|
38
38
|
import { join } from "node:path";
|
|
39
|
-
import { driverDir } from "../shared/driver-dir.mjs"; //
|
|
40
39
|
import { REGISTER_AXES } from "./coverage-ledger.mjs";
|
|
40
|
+
import { paths } from "./run-record.mjs";
|
|
41
41
|
|
|
42
42
|
export const FLAGS_FILE = "skeptic-flags.md";
|
|
43
43
|
|
|
@@ -56,7 +56,7 @@ export function escalatedAxes(flagsText, axes) {
|
|
|
56
56
|
|
|
57
57
|
/** Where the call's evidence lives — the driver's own record of what the seat handed it. */
|
|
58
58
|
export function skepticCallPaths(runDir) {
|
|
59
|
-
const dir =
|
|
59
|
+
const dir = paths(runDir).skepticCalls;
|
|
60
60
|
return { dir, payload: join(dir, "call-001.json") };
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
// 0, lines_scanned: N }` — a measured zero, from an instrument the answer itself shows can count.
|
|
36
36
|
import { readFileSync, realpathSync, statSync } from "node:fs";
|
|
37
37
|
import { resolve, sep, isAbsolute } from "node:path";
|
|
38
|
-
import { DRIVER_DIR } from "
|
|
38
|
+
import { DRIVER_DIR } from "./run-record.mjs"; //
|
|
39
39
|
import { answerBudget } from "../shared/answer-parts.mjs"; // the reply size this server was given
|
|
40
40
|
import { RESEARCH_ANSWERS_MD, RESEARCH_AFTER_REVIEW_MD } from "./research-answers.mjs"; // the two artifacts whose lines come back whole
|
|
41
41
|
|
package/driver/skills/README.md
CHANGED
|
@@ -40,8 +40,9 @@ instead; and `clearance-search/templates/search-request-form.html`, named only i
|
|
|
40
40
|
(`CLEAROTRON_INSTRUCTIONS_DIR`) wins per file, this tree is the fallback, and a configured-but-unreadable overlay throws
|
|
41
41
|
rather than silently falling back to the Generic defaults.
|
|
42
42
|
- `../methodology-witness.mjs` — records the sha of every file each stage read, per run.
|
|
43
|
-
- `../test/
|
|
44
|
-
copy:
|
|
43
|
+
- `../test/every-manual-is-read-and-names-what-exists.test.mjs` and `../test/prose-voice.test.mjs` read these files
|
|
44
|
+
rather than a copy: that every manual is read by a stage and names only tools and files that exist, and the house
|
|
45
|
+
prose contract.
|
|
45
46
|
|
|
46
47
|
## The provider boundary
|
|
47
48
|
|
|
@@ -60,10 +61,9 @@ are clean. The authoring rules and the empirical-verification checklist a new pr
|
|
|
60
61
|
|
|
61
62
|
## Where to start
|
|
62
63
|
|
|
63
|
-
`clearance-
|
|
64
|
-
Then `clearance-register/SKILL.md`, the more elaborated of the two execution skills: a spine plus per-mode files
|
|
64
|
+
`clearance-register/SKILL.md`, the more elaborated of the two execution skills: a spine plus per-mode files
|
|
65
65
|
(`unit.md`, `digest.md`) and per-provider files (`providers/`). The other, `clearance-common-law`, is one spine plus
|
|
66
|
-
`perplexity-prompts.md
|
|
67
|
-
program) being sections inside it — the per-mode split and `providers/` are register-only, not a shape every
|
|
66
|
+
`perplexity-prompts.md` — the per-mode split and `providers/` are register-only, not a shape every
|
|
68
67
|
execution skill shares. `clearance-search/phase2-execution.md` is methodology, not sequencing — the pipeline is
|
|
69
|
-
sequenced in code, in `../stages.mjs` and `../pipeline.mjs`.
|
|
68
|
+
sequenced in code, in `../stages.mjs` and `../pipeline.mjs`. The old orchestrator manual is kept as a record at
|
|
69
|
+
[clearance-search-spine.md](../../docs/architecture/retired-manuals/clearance-search-spine.md); no stage reads it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: blind-frame
|
|
3
|
-
description: The frame-STARVED independent re-derivation for the v3 preliminary trademark search workflow. **
|
|
3
|
+
description: The frame-STARVED independent re-derivation for the v3 preliminary trademark search workflow. **Run by the driver**, in parallel with the gather sweeps — do not call directly. Reads ONLY the raw instruction (mark, goods, classes, territories, manner of use) and NOT the matter frame, then re-derives the threat model cold across four layers — element + neighbours both directions, field by goods-overlap, sources by real channel, ranking by goods-overlap — and emits a structured model the frame-diff stage diffs against what the run actually scoped. Its job is to test the frame, not to reason inside it.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Purpose
|
|
@@ -63,7 +63,6 @@ The tool takes these values, and the shape below is what it validates them again
|
|
|
63
63
|
|
|
64
64
|
```json
|
|
65
65
|
{
|
|
66
|
-
"schema_version": 1,
|
|
67
66
|
"dominant_element": "the spine, verbatim",
|
|
68
67
|
"variants": [
|
|
69
68
|
{"value": "VELTRI", "direction": "drop", "rationale": "drop the trailing N — VELTRIN→VELTRI"}
|