clearotron 0.5.1 → 0.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +88 -33
- 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 +69 -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/band-shape.mjs +21 -3
- 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/commonlaw-carry-floor.json +3 -3
- package/driver/compare.mjs +1 -1
- package/driver/config-inventory.mjs +6 -79
- package/driver/consumption-ledger.mjs +2 -1
- package/driver/contract-arm2-baseline.json +2 -3
- 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/demo-posture.mjs +17 -0
- 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 +13 -42
- 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 +20 -13
- 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 +26 -14
- 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/named-band.mjs +60 -3
- 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 +714 -9351
- 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 +82 -2593
- package/driver/portal-static.mjs +3 -1
- package/driver/predelivery-lint.mjs +101 -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 +9 -7
- 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 +79 -23
- 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 +35 -96
- 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 +10 -20
- 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 +89 -288
- 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 +927 -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 +836 -0
- package/driver/steps/synthesis.mjs +261 -0
- package/driver/steps/verdict-gate.mjs +968 -0
- package/driver/suite-census.json +456 -96
- 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/unexecuted-asserts.json +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 +8 -0
- package/mcp-server/http-server.mjs +11 -12
- 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/node_modules/buffers/package.json +1 -1
- package/package.json +2 -1
- package/portal-ui/dist/assets/{index-fPqAU0sx.js → index-CYaO2ygd.js} +26 -14
- package/portal-ui/dist/assets/{index-AtB9ZpDH.css → index-izLa9apq.css} +2 -2
- package/portal-ui/dist/index.html +4 -4
- 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 +8 -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/render-check.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 +3 -3
- 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/customer-store.mjs +3 -2
- 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/vendor/buffers/package.json +1 -1
- package/node_modules/exceljs/README.md +0 -3023
|
@@ -12,16 +12,15 @@
|
|
|
12
12
|
// THE ISSUE DATE IS THE FIRST ONE: what the pool's meta.json kept, or the delivery the run recorded when the pool
|
|
13
13
|
// holds no copy (a demo, or a run republished into an empty pool), and the clock only when neither exists, which is
|
|
14
14
|
// a first publish. `renderedAt` is this publish, recorded apart from both.
|
|
15
|
-
import { readFileSync } from "node:fs";
|
|
16
15
|
import { join } from "node:path";
|
|
16
|
+
import { readJsonOrNull } from "../run-record.mjs";
|
|
17
17
|
|
|
18
|
-
const readJson = (file) => { try { return JSON.parse(readFileSync(file, "utf8")); } catch { return null; } };
|
|
19
18
|
const instant = (value) => (typeof value === "string" && !Number.isNaN(Date.parse(value)) ? value : null);
|
|
20
19
|
|
|
21
20
|
/** `{searchedAt, issuedAt, renderedAt}` as ISO strings. `searchedAt` is null when the run records no start. */
|
|
22
21
|
export function reportDates({ runDir, poolRunDir, now = new Date() }) {
|
|
23
|
-
const status =
|
|
24
|
-
const kept =
|
|
22
|
+
const status = readJsonOrNull(join(runDir, "status.json"));
|
|
23
|
+
const kept = readJsonOrNull(join(poolRunDir, "meta.json"));
|
|
25
24
|
return {
|
|
26
25
|
searchedAt: instant(status?.startedAt),
|
|
27
26
|
issuedAt: instant(kept?.issuedAt) ?? instant(status?.deliveredAt) ?? now.toISOString(),
|
|
@@ -12,16 +12,13 @@
|
|
|
12
12
|
// publishReport unconditionally, so `republish <a knockout run>` failed on a missing report.md and no
|
|
13
13
|
// knockout report could ever be re-rendered. A report shape you cannot re-render is a report shape you
|
|
14
14
|
// cannot fix after delivery.
|
|
15
|
-
import { existsSync
|
|
15
|
+
import { existsSync } from 'node:fs';
|
|
16
16
|
import { join } from 'node:path';
|
|
17
|
-
import {
|
|
17
|
+
import { paths, readJson, readJsonOrNull } from "../run-record.mjs";
|
|
18
18
|
import { publishReport } from './index.mjs';
|
|
19
19
|
import { publishKnockout } from './knockout.mjs';
|
|
20
20
|
import { worstBand } from '../verify-knockout.mjs';
|
|
21
21
|
|
|
22
|
-
const readJson = (p) => JSON.parse(readFileSync(p, 'utf8'));
|
|
23
|
-
const readJsonOr = (p, fallback = null) => { try { return readJson(p); } catch { return fallback; } };
|
|
24
|
-
|
|
25
22
|
/** The template a PUBLISHED run was rendered under, read from its meta.
|
|
26
23
|
*
|
|
27
24
|
* `meta.template` has been stamped by both publishers since long before it was read by anything; this is
|
|
@@ -43,7 +40,7 @@ export async function republishRun({ runId, meta, pool, poolUrl, runDir, skipReg
|
|
|
43
40
|
const template = templateOfMeta(meta);
|
|
44
41
|
if (template !== 'knockout') {
|
|
45
42
|
if (!existsSync(join(runDir, 'report.md'))) throw new Error(`${runDir} has no report.md — not a clearance run workspace.`);
|
|
46
|
-
const prof =
|
|
43
|
+
const prof = readJsonOrNull(paths(runDir).profile);
|
|
47
44
|
return publishReport({
|
|
48
45
|
runId,
|
|
49
46
|
codename: meta?.codename || '',
|
|
@@ -66,16 +63,16 @@ export async function republishRun({ runId, meta, pool, poolUrl, runDir, skipReg
|
|
|
66
63
|
const findingsPath = join(runDir, 'knockout-findings.json');
|
|
67
64
|
if (!existsSync(findingsPath)) throw new Error(`${runDir} has no knockout-findings.json — not a knockout run workspace.`);
|
|
68
65
|
const findings = readJson(findingsPath);
|
|
69
|
-
const framework =
|
|
66
|
+
const framework = readJsonOrNull(paths(runDir).framework);
|
|
70
67
|
if (!framework) throw new Error(`${runDir} has no _driver/framework.json — a knockout cannot be re-rendered without the bands it was rated under.`);
|
|
71
|
-
const searchPolicy =
|
|
72
|
-
const prof =
|
|
68
|
+
const searchPolicy = readJsonOrNull(paths(runDir).searchPolicy);
|
|
69
|
+
const prof = readJsonOrNull(paths(runDir).profile);
|
|
73
70
|
return publishKnockout({
|
|
74
71
|
runId,
|
|
75
72
|
codename: meta?.codename || '',
|
|
76
73
|
runDir,
|
|
77
74
|
findings,
|
|
78
|
-
plan:
|
|
75
|
+
plan: readJsonOrNull(join(runDir, 'knockout-plan.json')),
|
|
79
76
|
framework,
|
|
80
77
|
// Recomputed from the frozen framework + the frozen findings, exactly as the lane computed it. The
|
|
81
78
|
// stored meta.overall is not trusted as an input: it is an OUTPUT of this same join, and feeding an
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
// shape that reads like "seeded nothing, all good", because "the archive is empty" and "the archive is
|
|
35
35
|
// empty and nobody noticed why" look identical from the browser.
|
|
36
36
|
|
|
37
|
-
import { existsSync, readdirSync
|
|
37
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
38
38
|
import { join } from "node:path";
|
|
39
|
+
import { readJson } from "../run-record.mjs";
|
|
39
40
|
|
|
40
41
|
/** A pool "run" is a directory holding meta.json. Mirrors pool-admin.mjs's listRuns and regenIndex's
|
|
41
42
|
* scan filter — `customer` is the per-customer page tree, not a run. */
|
|
@@ -79,7 +80,7 @@ export function frozenSamples(examplesDir) {
|
|
|
79
80
|
continue;
|
|
80
81
|
}
|
|
81
82
|
let meta;
|
|
82
|
-
try { meta =
|
|
83
|
+
try { meta = readJson(manifest); }
|
|
83
84
|
catch (e) { problems.push(`${manifest} is not readable JSON (${String(e?.message ?? e)})`); continue; }
|
|
84
85
|
if (!meta?.runId) { problems.push(`${manifest} names no runId — it is not a frozen example manifest`); continue; }
|
|
85
86
|
if (!hasRun) { problems.push(`${dir} names runId ${meta.runId} but has no run/ directory to publish`); continue; }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
3
|
+
// publish/shell.mjs — what publishing a report does whichever report it is. Both publishers call it; what a report says stays
|
|
4
|
+
// with its own renderer.
|
|
5
|
+
//
|
|
6
|
+
// A PART THAT FAILS DOES NOT STOP THE REPORT, and both publishers answer alike (design ruling, 2026-11-10). A workbook that
|
|
7
|
+
// cannot be built or a data file that cannot be written leaves the report in place, and nothing the run publishes names the
|
|
8
|
+
// missing file. A staff-page refresh that fails is recorded after the report is in place. The report page and `meta.json`
|
|
9
|
+
// are not parts: a failure to write either still throws, because then there is no report to deliver.
|
|
10
|
+
import { chmodSync, copyFileSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
import { runLog } from '../log.mjs';
|
|
14
|
+
import { RUN_DIR_MODE } from '../run-record.mjs';
|
|
15
|
+
|
|
16
|
+
export const grpRead = (p, mode) => { try { chmodSync(p, mode); } catch { /* best-effort */ } };
|
|
17
|
+
|
|
18
|
+
const reasonOf = (e) => String(e?.message ?? e);
|
|
19
|
+
const record = (runDir, row) => { if (runDir) { try { runLog(runDir, row); } catch { /* meta.json and the return carry it too */ } } };
|
|
20
|
+
const removePart = (p) => { try { rmSync(p, { force: true }); } catch { /* nothing names it, so a leftover is never offered */ } };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a run's folder in the report pool and return the ways a publisher puts a file there.
|
|
24
|
+
*
|
|
25
|
+
* The run dir inherits the web-server group + the set-GID bit AUTOMATICALLY from the set-GID pool root
|
|
26
|
+
* (mode 2750, web-server group) — so files written inside take that group and the web server (Caddy in
|
|
27
|
+
* the reference deployment, mode 0640) can read them. Do NOT chmod this dir: the service account is not
|
|
28
|
+
* a member of the web-server group, and POSIX silently strips S_ISGID when a non-member sets it, leaving
|
|
29
|
+
* the dir 0750 → new files fall back to the service account's primary group → every report 403s. (An explicit
|
|
30
|
+
* `grpRead(poolRunDir, 0o2750)` here, added 2026-06-02, WAS that 403 bug; removed 2026-06-08.)
|
|
31
|
+
*
|
|
32
|
+
* The two parts a report can ship without go through the folder too. `buildWorkbook(name, build)` awaits `build(path)` and
|
|
33
|
+
* returns `{ auditFile, auditError, built }`: the file's name and what `build` returned, or a null name and the reason when
|
|
34
|
+
* it threw, with any part of the file it left removed. `writeDataFile(name, produce)` writes `produce()` as JSON and
|
|
35
|
+
* returns the name, or null when either threw, so a caller claims a data file only when it exists. `copyPart(src, name)`
|
|
36
|
+
* copies a run file into the folder the same way, and returns the name or null. All three record a failure in `runDir`'s
|
|
37
|
+
* log when they are given one.
|
|
38
|
+
*/
|
|
39
|
+
export function openPoolRun(poolRoot, runId, { runDir = null } = {}) {
|
|
40
|
+
const poolRunDir = join(poolRoot, runId);
|
|
41
|
+
mkdirSync(poolRunDir, { recursive: true, mode: RUN_DIR_MODE }); // owner and group only; mkdir keeps the pool root's set-GID
|
|
42
|
+
const writeRO = (name, data) => { const p = join(poolRunDir, name); writeFileSync(p, data); grpRead(p, 0o640); };
|
|
43
|
+
const copyRO = (src, name) => { const p = join(poolRunDir, name); copyFileSync(src, p); grpRead(p, 0o640); };
|
|
44
|
+
const buildWorkbook = async (name, build) => {
|
|
45
|
+
const p = join(poolRunDir, name);
|
|
46
|
+
try {
|
|
47
|
+
const built = await build(p);
|
|
48
|
+
grpRead(p, 0o640);
|
|
49
|
+
return { auditFile: name, auditError: null, built };
|
|
50
|
+
} catch (e) {
|
|
51
|
+
removePart(p);
|
|
52
|
+
const auditError = reasonOf(e);
|
|
53
|
+
console.warn(`[audit-workbook] not built, the report ships without it: ${auditError.slice(0, 140)}`);
|
|
54
|
+
record(runDir, { event: 'workbook-not-built', file: name, error: auditError.slice(0, 300) });
|
|
55
|
+
return { auditFile: null, auditError, built: null };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const writeDataFile = (name, produce) => {
|
|
59
|
+
try { writeRO(name, JSON.stringify(produce(), null, 2)); return name; }
|
|
60
|
+
catch (e) {
|
|
61
|
+
removePart(join(poolRunDir, name));
|
|
62
|
+
const error = reasonOf(e);
|
|
63
|
+
console.warn(`[report-data] ${name} not written, the report ships without it: ${error.slice(0, 140)}`);
|
|
64
|
+
record(runDir, { event: 'data-file-not-written', file: name, error: error.slice(0, 300) });
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const copyPart = (src, name) => {
|
|
69
|
+
try { copyRO(src, name); return name; }
|
|
70
|
+
catch (e) {
|
|
71
|
+
removePart(join(poolRunDir, name));
|
|
72
|
+
const error = reasonOf(e);
|
|
73
|
+
console.warn(`[publish] ${name} not copied, the report ships without it: ${error.slice(0, 140)}`);
|
|
74
|
+
record(runDir, { event: 'data-file-not-written', file: name, error: error.slice(0, 300) });
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return { poolRunDir, writeRO, copyRO, copyPart, buildWorkbook, writeDataFile };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Write the run's `meta.json` and refresh the pool's index, and return the index's count (null when the caller asked for
|
|
83
|
+
* no refresh). `meta.json` is the last file a publisher writes, because the index lists only folders that hold one: every
|
|
84
|
+
* document is in place before the run becomes visible. `regenIndex` is passed in because it lives with the clearance
|
|
85
|
+
* publisher, which imports this module.
|
|
86
|
+
*/
|
|
87
|
+
export function finishPoolRun({ writeRO, meta, poolRoot, skipRegen, regenIndex }) {
|
|
88
|
+
writeRO('meta.json', JSON.stringify(meta, null, 2));
|
|
89
|
+
return skipRegen ? null : regenIndex(poolRoot);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Refresh the staff pages once the report and its `meta.json` are in place. A failure is recorded and returned, never
|
|
94
|
+
* thrown: the report is already delivered, and the next publish refreshes the pages again. `regenSurfaces` is passed in for
|
|
95
|
+
* the reason `regenIndex` is. Returns null when the refresh ran or was not asked for.
|
|
96
|
+
*/
|
|
97
|
+
export async function refreshStaffPages({ regenSurfaces, poolRoot, skipRegen, runDir = null }) {
|
|
98
|
+
if (skipRegen) return null;
|
|
99
|
+
try { await regenSurfaces(poolRoot); return null; }
|
|
100
|
+
catch (e) {
|
|
101
|
+
const error = reasonOf(e);
|
|
102
|
+
console.warn(`[publish] staff pages not refreshed, the report is in place: ${error.slice(0, 140)}`);
|
|
103
|
+
record(runDir, { event: 'staff-pages-not-refreshed', error: error.slice(0, 300) });
|
|
104
|
+
return error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
The visible sentence loses its bottom margin (the fold row carries the spacing instead) so a folded
|
|
42
42
|
caption occupies the same vertical run as an unfolded one. `details.sub-more` is styled here and NOT
|
|
43
43
|
in the frozen renderer, and the existing @media print rule that forces every <details> open already
|
|
44
|
-
covers it — the exported PDF carries the whole caption, which is
|
|
44
|
+
covers it — the exported PDF carries the whole caption, which is the rule for print. */
|
|
45
45
|
details.sub-more{margin:0 0 30px;max-width:700px}
|
|
46
46
|
details.sub-more>summary{cursor:pointer;list-style:none;font-size:12.5px;font-weight:700;
|
|
47
47
|
letter-spacing:.06em;text-transform:uppercase;color:var(--faint)}
|
|
@@ -59,7 +59,9 @@
|
|
|
59
59
|
/* the framework that owns the ticks, named where they are read. Normal case and un-tracked on
|
|
60
60
|
purpose: `.label` is an uppercase eyebrow, and a proper name in the eyebrow's own letterforms reads
|
|
61
61
|
as a second heading rather than as the thing being cited. */
|
|
62
|
-
.gauge .
|
|
62
|
+
.gauge .gauge-head{margin-bottom:18px}
|
|
63
|
+
.gauge .gauge-head .label{margin-bottom:0}
|
|
64
|
+
.gauge .gauge-fw{margin-top:5px;font-size:11px;font-weight:600;letter-spacing:0;
|
|
63
65
|
text-transform:none;color:var(--slate)}
|
|
64
66
|
.scale{position:relative;height:11px;border-radius:8px;margin:34px 0 10px;
|
|
65
67
|
background:linear-gradient(90deg,var(--clear) 0%,var(--low) 26%,var(--med) 52%,var(--high) 79%,var(--severe) 100%)}
|
|
@@ -395,19 +397,19 @@
|
|
|
395
397
|
hash pins the renderer's bytes and the render arms grep its HTML, and on screen a mis-ruled
|
|
396
398
|
disclosure is correct. It is the private print control that walks a rendered page on both lanes
|
|
397
399
|
and refuses a disclosure ruled by neither mechanism, and it runs by hand. Two folds have now
|
|
398
|
-
shipped mis-ruled and been caught there rather than in CI. `details.sub-more`
|
|
400
|
+
shipped mis-ruled and been caught there rather than in CI. `details.sub-more` was in NEITHER, so the exported PDF — the
|
|
399
401
|
client-facing legal document — printed an inert "MORE" label and a right-pointing COLLAPSED marker
|
|
400
402
|
in the hero, directly above text that was already fully expanded. Measured in Chrome: the caption's
|
|
401
403
|
own content was carried correctly and only the control leaked, which is why the commit that added
|
|
402
404
|
the fold could check the half it thought about and ship the half it did not. */
|
|
403
405
|
details.drill>summary,details.method>summary,details.sub-more>summary,
|
|
404
406
|
/* An answer's "More" is a pure toggle: it carries no content of its own, so on paper it would be an
|
|
405
|
-
inert label over text the rule below has already expanded —
|
|
407
|
+
inert label over text the rule below has already expanded — a defect that once shipped. */
|
|
406
408
|
details.ans-more>summary{display:none!important}
|
|
407
409
|
/* The caption fold made this line load-bearing for the document's CONTENT, not just its completeness. The
|
|
408
410
|
legal/practical reads now live inside .drillbody, so without this rule the exported PDF would
|
|
409
411
|
carry the one-line verdicts and none of the reasoning behind them. The export prints everything a
|
|
410
|
-
reader could open —
|
|
412
|
+
reader could open — a deliberate rule, unchanged. Ticked-card selection (.print-hidden)
|
|
411
413
|
and internal notes (.int-note, hidden above) are the only two things print ever drops. */
|
|
412
414
|
details>*:not(summary){display:block!important}
|
|
413
415
|
details>summary{list-style:none;cursor:default}
|
|
@@ -463,7 +465,7 @@
|
|
|
463
465
|
/* ── P5 (charter 2026-07-30) — content model: legal/practical split · manageable category · the
|
|
464
466
|
four answers. This file is NOT hash-frozen; the render emits the markup, the rules live here. */
|
|
465
467
|
/* the legal vs practical pair — two labelled reads, never blurred.
|
|
466
|
-
|
|
468
|
+
These moved out of the card body and into the "Full detail & provenance" drawer, where they
|
|
467
469
|
LEAD, so they are sized for the drawer's own reading text (.drillbody is 13.5px/1.62) instead of the
|
|
468
470
|
tighter card body they used to sit in. The first block has no top margin — .drillbody's padding is
|
|
469
471
|
the gap — and the last one is spaced off the structured <ul> that follows it. */
|
|
@@ -490,7 +492,7 @@
|
|
|
490
492
|
browser's default weight, under the browser's default triangle, at the foot of a document whose
|
|
491
493
|
every other section carries a numbered spine header. The section that states what the search did
|
|
492
494
|
NOT cover was the one region on the page a reader's eye had no reason to stop at.
|
|
493
|
-
This is the styling half of
|
|
495
|
+
This is the styling half of that change and it costs no hash bump — the markup is unchanged. */
|
|
494
496
|
details.scope>summary{cursor:pointer;list-style:none;margin:22px 0 0;padding:12px 0 10px;
|
|
495
497
|
border-top:1px solid var(--line);font-size:15px;font-weight:700;letter-spacing:-.01em;color:var(--ink)}
|
|
496
498
|
details.scope>summary::-webkit-details-marker{display:none}
|
package/driver/queue-order.mjs
CHANGED
|
@@ -20,14 +20,15 @@
|
|
|
20
20
|
// out there it can never match the `*.json` claim glob, checkRunCaps's `*.{json,processing,postponed}`
|
|
21
21
|
// parse set, or prelim-driver.path's watch — and reordering must NOT wake the runner.
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { writeFileSync, renameSync, mkdirSync, readdirSync } from "node:fs";
|
|
24
24
|
import { join, dirname } from "node:path"; import { studioDirFor } from "../shared/pre-rename-spellings.mjs";
|
|
25
|
+
import { readJson } from "./run-record.mjs";
|
|
25
26
|
|
|
26
27
|
export function queueOrderPath(qdir) { return join(dirname(qdir), ".queue-order.json"); }
|
|
27
28
|
|
|
28
29
|
export function readQueueOrder(qdir) {
|
|
29
30
|
try {
|
|
30
|
-
const j =
|
|
31
|
+
const j = readJson(queueOrderPath(qdir));
|
|
31
32
|
return Array.isArray(j?.order) ? j.order.filter((s) => typeof s === "string" && s) : [];
|
|
32
33
|
} catch { return []; } // absent, unreadable or corrupt ⇒ assert nothing, fall through to enqueuedAt
|
|
33
34
|
}
|
|
@@ -55,7 +56,7 @@ export function orderedQueueFiles(qdir, files) {
|
|
|
55
56
|
const listed = rank.get(f.replace(/\.json$/, ""));
|
|
56
57
|
if (listed !== undefined) return { f, tier: 0, pos: listed, at: "" };
|
|
57
58
|
let at = "";
|
|
58
|
-
try { at = String(
|
|
59
|
+
try { at = String(readJson(join(qdir, f)).enqueuedAt ?? ""); } catch { /* sorts by name */ }
|
|
59
60
|
return { f, tier: 1, pos: 0, at };
|
|
60
61
|
});
|
|
61
62
|
keyed.sort((a, b) => a.tier - b.tier || a.pos - b.pos || a.at.localeCompare(b.at) || a.f.localeCompare(b.f));
|
package/driver/record-carry.mjs
CHANGED
|
@@ -66,10 +66,6 @@ export const RECORD_CARRY_SCHEMA_VERSION = 4;
|
|
|
66
66
|
* clean run came to read as a total loss. Legitimate for a run archived before and
|
|
67
67
|
* for the probe; a fresh run reporting it is a defect, flagged by the predelivery lint.
|
|
68
68
|
*/
|
|
69
|
-
export const TRACE_BASES = ["recorded", "reconstructed"];
|
|
70
|
-
|
|
71
|
-
/** How far a record got. Ordered; index = distance travelled. */
|
|
72
|
-
export const REACH_STAGES = ["retrieved", "screened", "placed", "findings-surface", "finding"];
|
|
73
69
|
|
|
74
70
|
/**
|
|
75
71
|
* WHERE THE REASON WAS AUTHORED — the ruling's "weigh where the reason is authored", made a field so a
|
|
@@ -85,9 +81,6 @@ export const REACH_STAGES = ["retrieved", "screened", "placed", "findings-surfac
|
|
|
85
81
|
*/
|
|
86
82
|
export const REASON_SOURCES = ["step-structural", "step-stated", "step-silent", "absent"];
|
|
87
83
|
|
|
88
|
-
/** The seam a record failed to cross. `null` when it became a finding. */
|
|
89
|
-
export const SEAMS = ["screen", "placement", "digest", "synthesis"];
|
|
90
|
-
|
|
91
84
|
/**
|
|
92
85
|
* WHAT THIS TRACE COVERS AND WHAT IT DOES NOT — carried IN THE ARTIFACT, not just in a PR body.
|
|
93
86
|
*
|
|
@@ -431,8 +424,6 @@ const bump = (o, k) => { o[k] = (o[k] ?? 0) + 1; };
|
|
|
431
424
|
* checked first because execute-plan.mjs writes it ALONGSIDE `error`, never instead of it, and the
|
|
432
425
|
* capability gap is the more specific fact. PURE.
|
|
433
426
|
*/
|
|
434
|
-
export const SLICE_CLASSES = ["counted-not-fetched", "capability-gap", "provider-error", "count-unavailable"];
|
|
435
|
-
|
|
436
427
|
// — the fourth class. `counted-not-fetched` claimed the run HAS a count, which for a slice the
|
|
437
428
|
// register refused to size is the same false claim removed, wearing the new machine field. This
|
|
438
429
|
// one is distinct from the two refusals above: the slice DID run and may have returned records — it is
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
|
|
54
54
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
55
55
|
import { join } from "node:path";
|
|
56
|
-
import { driverDir } from "
|
|
56
|
+
import { driverDir } from "./run-record.mjs"; //
|
|
57
57
|
|
|
58
58
|
import { normalizeRecordUri } from "./registry-fidelity.mjs";
|
|
59
59
|
|
|
@@ -72,9 +72,6 @@ export const DISCARD_LEDGER_NAME = "record-discard.jsonl";
|
|
|
72
72
|
*/
|
|
73
73
|
export const DISCARD_SEAMS = ["placement", "digest", "synthesis"];
|
|
74
74
|
|
|
75
|
-
/** What a pass did with a record. `carried` cancels an earlier `discarded` at the same seam. */
|
|
76
|
-
export const DISCARD_VERDICTS = ["carried", "discarded"];
|
|
77
|
-
|
|
78
75
|
const clip = (s, n = 300) => {
|
|
79
76
|
const t = String(s ?? "").replace(/\s+/g, " ").trim();
|
|
80
77
|
return t.length > n ? `${t.slice(0, n - 1)}…` : t;
|
package/driver/record-fold.mjs
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
// in force.
|
|
30
30
|
import { readFileSync, writeFileSync, existsSync, renameSync, rmSync, mkdirSync } from "node:fs";
|
|
31
31
|
import { dirname } from "node:path";
|
|
32
|
-
import { driverDir } from "../shared/driver-dir.mjs";
|
|
33
32
|
import { consolidateFindings, remapActionOrdinals, remapFourAnswersOrdinals, parseFindingsJson } from "./findings-model.mjs";
|
|
34
33
|
import { parseFrameworkManifest } from "./framework.mjs";
|
|
34
|
+
import { driverDir, paths, readJson } from "./run-record.mjs";
|
|
35
35
|
|
|
36
36
|
export const FOLD_FILE = "fold.json";
|
|
37
37
|
export const UNFOLDED_FILE = "findings-unfolded.json";
|
|
@@ -63,7 +63,7 @@ export function foldRecord(doc, manifest = null) {
|
|
|
63
63
|
|
|
64
64
|
/** The fold state of a run, or null before any seam. Never throws. */
|
|
65
65
|
export function readFold(runDir) {
|
|
66
|
-
try { return
|
|
66
|
+
try { return readJson(driverDir(String(runDir ?? ""), FOLD_FILE)); } catch { return null; }
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function writeFold(runDir, { seamPassed, map = null, merges = [], error = null }) {
|
|
@@ -138,7 +138,7 @@ export function foldFindingsFile(runDir, findingsPath, manifest, { seam = false
|
|
|
138
138
|
/** The fold an accepted save makes, with the run's frozen framework manifest. Never throws. */
|
|
139
139
|
export function foldAfterSave(runDir, findingsPath) {
|
|
140
140
|
let manifest = null;
|
|
141
|
-
try { manifest = parseFrameworkManifest(readFileSync(
|
|
141
|
+
try { manifest = parseFrameworkManifest(readFileSync(paths(String(runDir ?? "")).framework, "utf8")); }
|
|
142
142
|
catch { manifest = null; } // a run with no frozen manifest folds as the seam does for it
|
|
143
143
|
return foldFindingsFile(runDir, findingsPath, manifest);
|
|
144
144
|
}
|
package/driver/record-goods.mjs
CHANGED
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
// UNKNOWN IS NOT A MISMATCH. A record with no goods on file passes a goods filter, the way a record that
|
|
16
16
|
// names no class passes the class scope (band-shape.mjs `inScope`): a filter must never hide a record for
|
|
17
17
|
// what the run simply does not hold.
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
18
19
|
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
19
20
|
import { join } from "node:path";
|
|
20
|
-
import { driverDir } from "../shared/driver-dir.mjs";
|
|
21
21
|
import { normalizeRecordUri } from "./registry-fidelity.mjs";
|
|
22
22
|
import { foldDiacritics } from "./form-neighbourhood.mjs";
|
|
23
23
|
import { parseVariantManifestModel } from "./variant-manifest-model.mjs";
|
|
24
24
|
import { canonicalJurisdictionCode } from "./jurisdiction-codes.mjs";
|
|
25
25
|
import { savedStatusPages, savedPageStatement, usSerialOf } from "./saved-register-pages.mjs";
|
|
26
|
+
import { paths, readJson } from "./run-record.mjs";
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* The registers whose language is English (ruled 2026-10-12): there, a goods statement with no language tag
|
|
@@ -218,7 +219,7 @@ export function bandGoodsIndex(runDir) {
|
|
|
218
219
|
const goods = recordGoods(body, { english: untaggedIsEnglish(key) });
|
|
219
220
|
if (goods.length) index.set(key, goods);
|
|
220
221
|
};
|
|
221
|
-
const ledger =
|
|
222
|
+
const ledger = paths(runDir).registerRecordBodies;
|
|
222
223
|
if (existsSync(ledger)) {
|
|
223
224
|
let text = "";
|
|
224
225
|
try { text = readFileSync(ledger, "utf8"); } catch { text = ""; }
|
|
@@ -233,7 +234,7 @@ export function bandGoodsIndex(runDir) {
|
|
|
233
234
|
let names = [];
|
|
234
235
|
try { names = readdirSync(dir).filter((n) => n.endsWith(".json")); } catch { names = []; }
|
|
235
236
|
for (const n of names) {
|
|
236
|
-
try { const body =
|
|
237
|
+
try { const body = readJson(join(dir, n)); take(body?._uri ?? body?.uri, body); } catch { /* unreadable: skip */ }
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
return index;
|
|
@@ -280,6 +281,14 @@ export function rowGoods(row, pages = null) {
|
|
|
280
281
|
const page = mark && serial ? savedPageStatement(pages, serial, whole.classes[0], whole.text) : null;
|
|
281
282
|
out.push(page ? { ...whole, text: page.text, page: { question: page.question } } : { ...whole, ...mark });
|
|
282
283
|
}
|
|
284
|
+
// A CLASS WHOSE TEXT THE MERGED BAND SET ASIDE (named-band.mjs `rowAsHanded`, outside the order's classes) is an entry
|
|
285
|
+
// marked `setAside` with no text: the class is on the record, and its wording is not here, which establishes nothing
|
|
286
|
+
// about it. It is never the register listing no goods, and never a search not made.
|
|
287
|
+
// Where the merge saved the shape's own goods test's answer on the record's whole wording (`setAsideTestAnswer`), the
|
|
288
|
+
// entry carries it, and only a test on the same word list reads it (`goodsWordCounter`'s `setAsideTest`).
|
|
289
|
+
const aside = Array.isArray(row?.goods_set_aside?.classes) ? row.goods_set_aside.classes : [];
|
|
290
|
+
const test = row?.goods_set_aside?.test && typeof row.goods_set_aside.test === "object" ? row.goods_set_aside.test : null;
|
|
291
|
+
for (const n of aside) out.push({ classes: [String(n)], text: "", setAside: true, ...(test ? { test } : {}) });
|
|
283
292
|
return out.length ? out : null;
|
|
284
293
|
}
|
|
285
294
|
|
|
@@ -292,16 +301,19 @@ export const statementCut = (goods) => (goods ?? []).some((g) => g?.cut === true
|
|
|
292
301
|
|
|
293
302
|
/** Is a statement of these goods one whose completeness is not established (`rowGoods`, `recordGoods`)? PURE. */
|
|
294
303
|
export const completenessUnknown = (goods) => (goods ?? []).some((g) => g?.unknown === true);
|
|
295
|
-
/**
|
|
296
|
-
const
|
|
304
|
+
/** Was a class's wording set aside from the merged band (`rowGoods`)? Its words may be the client's. PURE. */
|
|
305
|
+
export const statementSetAside = (goods) => (goods ?? []).some((g) => g?.setAside === true);
|
|
306
|
+
/** Could words cut off, not shown, or set aside from these goods be the client's? Then a statement matching none is unknown. PURE. */
|
|
307
|
+
const notWhole = (goods) => statementCut(goods) || completenessUnknown(goods) || statementSetAside(goods);
|
|
297
308
|
|
|
298
|
-
/** How many records rest on each kind of goods evidence: a held body, a row's whole statements, a row's statements cut short or not established whole, or none. PURE. */
|
|
309
|
+
/** How many records rest on each kind of goods evidence: a held body, a row's whole statements, a row's statements cut short or not established whole, a row whose other classes' wording was set aside, or none. PURE. */
|
|
299
310
|
export function goodsEvidence(records, goods) {
|
|
300
|
-
const out = { held: 0, complete: 0, cut: 0, unknown: 0, none: 0 };
|
|
311
|
+
const out = { held: 0, complete: 0, cut: 0, unknown: 0, setAside: 0, none: 0 };
|
|
301
312
|
for (const r of Array.isArray(records) ? records : []) {
|
|
302
313
|
if (goods?.held?.(r)) { out.held++; continue; }
|
|
303
314
|
const g = goods ? goods.of(r) : null;
|
|
304
|
-
if (!g) out.none++; else if (statementCut(g)) out.cut++; else if (completenessUnknown(g)) out.unknown++;
|
|
315
|
+
if (!g) out.none++; else if (statementCut(g)) out.cut++; else if (completenessUnknown(g)) out.unknown++;
|
|
316
|
+
else if (statementSetAside(g)) out.setAside++; else out.complete++;
|
|
305
317
|
}
|
|
306
318
|
return out;
|
|
307
319
|
}
|
|
@@ -338,13 +350,16 @@ export function goodsWordForms(word) {
|
|
|
338
350
|
* word or phrase matches its singular and plural forms (`goodsWordForms`), at word boundaries, never as the
|
|
339
351
|
* start of a longer word. PURE.
|
|
340
352
|
*/
|
|
341
|
-
export function goodsWordCounter(words, { stems = false } = {}) {
|
|
353
|
+
export function goodsWordCounter(words, { stems = false, setAsideTest = false, testKey = null } = {}) {
|
|
342
354
|
// A phrase's words are separated by spaces or hyphens alike: "mobile phone" is "mobile-phone".
|
|
343
355
|
const phrase = (w) => w.split(/[\s-]+/).filter(Boolean).map((x) => (stems ? `(?:${goodsWordForms(x).map(escape).join("|")})` : escape(x))).join("[\\s-]+");
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
356
|
+
const list = (Array.isArray(words) ? words : [words]).map((w) => fold(w).trim()).filter(Boolean);
|
|
357
|
+
const res = list.map((w) => new RegExp(`(^|[^\\p{L}\\p{N}])${phrase(w)}($|[^\\p{L}\\p{N}])`, "u"));
|
|
358
|
+
const key = setAsideTest ? (testKey ?? goodsTestKey(words, { stems })) : null;
|
|
347
359
|
return (goods) => {
|
|
360
|
+
// A record whose wording the merge set aside is read on the answer the merge saved for this same list.
|
|
361
|
+
const saved = key ? savedAnswer(goods, key) : undefined;
|
|
362
|
+
if (saved !== undefined) return !res.length || saved == null ? null : list.filter((w) => saved.has(w)).length;
|
|
348
363
|
const readable = (goods ?? []).filter((g) => g.en !== false);
|
|
349
364
|
if (!res.length || !readable.length) return null;
|
|
350
365
|
const text = fold(readable.map((g) => (g.alt ? `${g.text}\n${g.alt}` : g.text)).join("\n"));
|
|
@@ -353,6 +368,34 @@ export function goodsWordCounter(words, { stems = false } = {}) {
|
|
|
353
368
|
};
|
|
354
369
|
}
|
|
355
370
|
|
|
371
|
+
/**
|
|
372
|
+
* THE SHAPE'S OWN TEST, ANSWERED ON THE WORDING THE MERGE HELD. Before a class's wording is set aside (named-band.mjs
|
|
373
|
+
* `rowAsHanded`), the merge runs the band shape's goods test (`shapeGoodsTest`) on the record's whole wording, every
|
|
374
|
+
* statement joined as the test joins them, and saves the answer on the record with a key for the word list: the words
|
|
375
|
+
* matched, an empty list for a known zero, or null where the test could not tell (wording cut, completeness not
|
|
376
|
+
* established, or a class in no language the engine reads). A test on that same list returns the saved answer for the
|
|
377
|
+
* record as a whole, so a phrase across the boundary of a removed statement is neither lost nor made. Any other list,
|
|
378
|
+
* such as a lookup's own goods words, is not answered, and a set-aside class stays "cannot tell" to it. The answer
|
|
379
|
+
* describes the wording at the merge: a register page the run saves later is read by `band_record`, not by it. PURE.
|
|
380
|
+
*/
|
|
381
|
+
export function goodsTestKey(words, { stems = false } = {}) {
|
|
382
|
+
const list = [...new Set((Array.isArray(words) ? words : [words]).map((w) => fold(w).trim()).filter(Boolean))].sort();
|
|
383
|
+
return createHash("sha256").update(JSON.stringify({ stems: Boolean(stems), words: list })).digest("hex").slice(0, 16);
|
|
384
|
+
}
|
|
385
|
+
export function setAsideTestAnswer(statements, { words = [], stems = false } = {}) {
|
|
386
|
+
const list = (Array.isArray(words) ? words : [words]).map((w) => String(w ?? "").trim()).filter(Boolean);
|
|
387
|
+
if (!list.length || !Array.isArray(statements) || !statements.length) return null;
|
|
388
|
+
return { key: goodsTestKey(list, { stems }), matched: goodsWordsMatched(list, { stems })(statements) };
|
|
389
|
+
}
|
|
390
|
+
// The answer the merge saved for a record, where it saved one for this word list: the folded words matched, or null
|
|
391
|
+
// where the test could not tell. undefined where nothing was saved for this list, and the record is read as it stands.
|
|
392
|
+
const savedAnswer = (goods, key) => {
|
|
393
|
+
const aside = (goods ?? []).filter((g) => g?.setAside === true);
|
|
394
|
+
if (!aside.length || !aside.every((g) => g?.test?.key === key)) return undefined;
|
|
395
|
+
const matched = aside[0].test.matched;
|
|
396
|
+
return Array.isArray(matched) ? new Set(matched.map((w) => fold(w).trim())) : null;
|
|
397
|
+
};
|
|
398
|
+
|
|
356
399
|
/**
|
|
357
400
|
* Does a class of these goods have no statement the engine can read? A record whose readable statements match
|
|
358
401
|
* no word, while one of its classes is written only in a language the engine cannot use, is unknown to the
|
|
@@ -375,10 +418,13 @@ export function classUnread(goods) {
|
|
|
375
418
|
* null when the record has no goods on file or there are no words. A shape line shows them as "k of N:
|
|
376
419
|
* the words", which is the goods ground made visible on the line. PURE.
|
|
377
420
|
*/
|
|
378
|
-
export function goodsWordsMatched(words, { stems = false } = {}) {
|
|
421
|
+
export function goodsWordsMatched(words, { stems = false, setAsideTest = false } = {}) {
|
|
379
422
|
const list = (Array.isArray(words) ? words : [words]).map((w) => String(w ?? "").trim()).filter(Boolean);
|
|
423
|
+
const key = setAsideTest ? goodsTestKey(list, { stems }) : null;
|
|
380
424
|
const tests = list.map((w) => [w, goodsWordCounter([w], { stems })]);
|
|
381
425
|
return (goods) => {
|
|
426
|
+
const saved = key ? savedAnswer(goods, key) : undefined;
|
|
427
|
+
if (saved !== undefined) return !list.length || saved == null ? null : list.filter((w) => saved.has(fold(w).trim()));
|
|
382
428
|
if (!list.length || !(goods ?? []).some((g) => g.en !== false)) return null;
|
|
383
429
|
const hit = tests.filter(([, t]) => t(goods) === 1).map(([w]) => w);
|
|
384
430
|
return hit.length === 0 && (classUnread(goods) || notWhole(goods)) ? null : hit;
|
|
@@ -399,7 +445,7 @@ export function goodsWordMatcher(words) {
|
|
|
399
445
|
*/
|
|
400
446
|
export function instructedOrder(P, job = null) {
|
|
401
447
|
let scope = null;
|
|
402
|
-
try { scope =
|
|
448
|
+
try { scope = readJson(P.instructedScope); } catch { scope = null; }
|
|
403
449
|
const order = { ...(job ?? {}) };
|
|
404
450
|
for (const k of ["goods", "jurisdictions", "geography"]) if (scope?.[k] != null) order[k] = scope[k];
|
|
405
451
|
return order;
|
|
@@ -419,26 +465,36 @@ export function instructedOrder(P, job = null) {
|
|
|
419
465
|
* band's, so the shape tests goods whenever either is held. The saved pages are read once, for the first record with
|
|
420
466
|
* no body held.
|
|
421
467
|
*/
|
|
422
|
-
|
|
468
|
+
/**
|
|
469
|
+
* The words the band shape's goods test reads: the particular goods when the variants stage names them, as stems, else
|
|
470
|
+
* the goods words (ruled 2026-10-12), with the manifest they came from. The merge reads the same list, to record the
|
|
471
|
+
* test's answer for wording it sets aside (named-band.mjs `rowAsHanded`). IMPURE: reads the run's variant manifest.
|
|
472
|
+
*/
|
|
473
|
+
export function shapeGoodsTest(P) {
|
|
423
474
|
let model = null;
|
|
424
475
|
try { if (existsSync(P.variantManifestModel)) model = parseVariantManifestModel(readFileSync(P.variantManifestModel, "utf8")); } catch { model = null; }
|
|
476
|
+
const product = Array.isArray(model?.product_words) && model.product_words.length;
|
|
477
|
+
const words = product ? model.product_words : Array.isArray(model?.goods_words) ? model.goods_words : [];
|
|
478
|
+
// the word list the shape groups on is matched as stems, whichever source it came from
|
|
479
|
+
return { model, words, stems: true, source: product ? "product_words" : words.length ? "goods_words" : "none" };
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export function bandShapeGoods(P, records = []) {
|
|
483
|
+
const { model, words, source, stems } = shapeGoodsTest(P);
|
|
425
484
|
let searched = "";
|
|
426
485
|
try {
|
|
427
|
-
const plan =
|
|
486
|
+
const plan = readJson(P.registerPlan);
|
|
428
487
|
searched = String((plan?.entries ?? []).find((e) => /\+goods($|-)/.test(String(e?.qid ?? "")))?.term ?? "");
|
|
429
488
|
} catch { searched = ""; }
|
|
430
489
|
const manifestDominant = String(model?.dominant_element ?? "");
|
|
431
490
|
const index = bandGoodsIndex(P.runDir);
|
|
432
|
-
//
|
|
433
|
-
const
|
|
434
|
-
const words = product ? model.product_words : Array.isArray(model?.goods_words) ? model.goods_words : [];
|
|
435
|
-
const stems = true; // the word list the shape groups on is matched as stems, whichever source it came from
|
|
436
|
-
const hits = goodsWordCounter(words, { stems });
|
|
491
|
+
// A set-aside class is read through the answer the merge recorded for this same list (`setAsideTestAnswer`).
|
|
492
|
+
const hits = goodsWordCounter(words, { stems, setAsideTest: true });
|
|
437
493
|
const held = (r) => goodsFor(index, r);
|
|
438
494
|
let pages = null;
|
|
439
495
|
const saved = () => (pages ??= savedStatusPages(P.runDir)());
|
|
440
496
|
const rowsHold = Array.isArray(records) && records.some((r) => r && typeof r === "object" && rowGoods(r));
|
|
441
|
-
const goods = index.size || rowsHold ? { of: (r) => held(r) ?? rowGoods(r, saved()), held: (r) => held(r) != null, hits, matched: goodsWordsMatched(words, { stems }) } : null;
|
|
442
|
-
const goodsTest = { source
|
|
497
|
+
const goods = index.size || rowsHold ? { of: (r) => held(r) ?? rowGoods(r, saved()), held: (r) => held(r) != null, hits, matched: goodsWordsMatched(words, { stems, setAsideTest: true }) } : null;
|
|
498
|
+
const goodsTest = { source, words };
|
|
443
499
|
return { goods, goodsTest, goodsWordCount: words.length, dominantTerm: searched || manifestDominant, manifestDominant };
|
|
444
500
|
}
|
|
@@ -336,7 +336,6 @@ function containsWordRun(a, b) {
|
|
|
336
336
|
//
|
|
337
337
|
// An entry in a gold set's `register` array is a REGISTERED RIGHT by construction of the array it sits
|
|
338
338
|
// in — no per-entry flag is needed and no gold set is edited. What was missing is entirely candidate-side.
|
|
339
|
-
export const EVIDENCE_CLASSES = ["register", "common-law", "case-law", "unknown"];
|
|
340
339
|
|
|
341
340
|
/**
|
|
342
341
|
* Fold a run finding's own typed source into the class the scorer reasons about.
|
|
@@ -1862,7 +1861,7 @@ export function readJxLanes(doc) {
|
|
|
1862
1861
|
const v = doc.fold?.depth?.[name];
|
|
1863
1862
|
if (!v || typeof v !== "object") {
|
|
1864
1863
|
return { recorded: false, asked: d.depth ?? null, ran: null, shortfall: null,
|
|
1865
|
-
why: "the run did not state what depth this lane actually got (no fold.depth) —
|
|
1864
|
+
why: "the run did not state what depth this lane actually got (no fold.depth) — an earlier artifact, "
|
|
1866
1865
|
+ "or a run that never reached the delivery statement. Whether the ask was met CANNOT be established" };
|
|
1867
1866
|
}
|
|
1868
1867
|
return { recorded: true, asked: v.asked ?? null, ran: v.ran ?? null,
|
|
@@ -1890,7 +1889,7 @@ export function readJxLanes(doc) {
|
|
|
1890
1889
|
statement: typeof doc.fold?.executes === "string" ? doc.fold.executes : null,
|
|
1891
1890
|
slices: doc.fold?.slices ?? null,
|
|
1892
1891
|
statementWhy: typeof doc.fold?.executes === "string" ? null
|
|
1893
|
-
: "the run did not state which jx slices it executed (no fold.executes) —
|
|
1892
|
+
: "the run did not state which jx slices it executed (no fold.executes) — an earlier artifact, or a fold that never ran",
|
|
1894
1893
|
};
|
|
1895
1894
|
}
|
|
1896
1895
|
|
|
@@ -45,9 +45,3 @@ export function capabilitiesFor(providerId) {
|
|
|
45
45
|
}
|
|
46
46
|
return caps;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
/** The ACTIVE provider's capabilities (driver.config.mjs owns the toggle; this never re-reads the env). */
|
|
50
|
-
export async function activeCapabilities() {
|
|
51
|
-
const { REGISTER_PROVIDER } = await import("./driver.config.mjs");
|
|
52
|
-
return capabilitiesFor(REGISTER_PROVIDER);
|
|
53
|
-
}
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
// mark generates 3–8. `CLEAROTRON_KNOCKOUT_VARIANT_CAP` lowers it per deployment; nothing raises it above
|
|
88
88
|
// the code cap, because the ceiling is a spend guarantee and a knob that can lift it is not one.
|
|
89
89
|
|
|
90
|
-
import {
|
|
90
|
+
import { appendFileSync } from "node:fs";
|
|
91
91
|
import { join } from "node:path";
|
|
92
92
|
|
|
93
93
|
import { kebab } from "./search-policy.mjs"; import { moreThan } from "../shared/register-floor.mjs";
|
|
@@ -96,6 +96,7 @@ import { reachableRegions } from "./register-availability.mjs"; // — pure; t
|
|
|
96
96
|
import { variantForms, VARIANT_RULES, VARIANT_CAP } from "./register-variants.mjs";
|
|
97
97
|
import { isCapabilityGap } from "../providers/_shared/execute-plan.mjs";
|
|
98
98
|
import { plainDeferralReason, plainCause } from "./deferral-row.mjs"; // — the reader's line for a count left open
|
|
99
|
+
import { readJson } from "./run-record.mjs";
|
|
99
100
|
|
|
100
101
|
/** The three questions, in report order. `matchMode` is the provider-neutral predicate name.
|
|
101
102
|
*
|
|
@@ -245,7 +246,7 @@ async function runBatched(items, limit, fn) {
|
|
|
245
246
|
function fixtureCounter(dir) {
|
|
246
247
|
return async (mark, predicate) => {
|
|
247
248
|
let doc;
|
|
248
|
-
try { doc =
|
|
249
|
+
try { doc = readJson(join(dir, `${kebab(mark)}.json`)); }
|
|
249
250
|
catch (e) { return { ok: false, total: null, reason: `count fixture missing for ${kebab(mark)}: ${e.message}` }; }
|
|
250
251
|
// THE KEY IS THE QUESTION ASKED, NOT THE COLUMN IT FEEDS. A variant probe asks the provider's
|
|
251
252
|
// EXACT predicate about a generated form, so its fixture is that form's own file under `identical`
|