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
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
//
|
|
4
|
+
// portal-routes/queue.mjs — the queue an account sees: cancelling a queued search and reordering its own queued searches.
|
|
5
|
+
//
|
|
6
|
+
// One of the portal service's route groups, moved out of its dispatcher unchanged; makePortalService says how it asks them.
|
|
7
|
+
import { assertPrincipal, seesEverything } from "../portal-access.mjs";
|
|
8
|
+
import { scanAccountRuns } from "../portal-runs.mjs";
|
|
9
|
+
import { reorderQueue } from "../queue-order.mjs";
|
|
10
|
+
|
|
11
|
+
export async function queueRoutes({ poolRoot, workspaceRoot, queueDirs, stopRun, audit }, { method, parts, principal, body, query }) {
|
|
12
|
+
// /portal/api/queue/<id>/cancel — drop a job that has not started. No spend has happened, so
|
|
13
|
+
// there is nothing to account for and no row is left behind.
|
|
14
|
+
if (parts[1] === "api" && parts[2] === "queue" && parts[3] && parts[4] === "cancel" && method === "POST") {
|
|
15
|
+
const account = assertPrincipal(principal, { account: query.account ?? null, tenant: query.tenant ?? null, run: true });
|
|
16
|
+
if (!account) return { status: 400, json: { error: "name an account (?account=)" } };
|
|
17
|
+
const id = decodeURIComponent(parts[3]);
|
|
18
|
+
const mine = scanAccountRuns({ poolRoot, workspaceRoot, account, queueDirs: queueDirs() }).find((r) => r.runId === id && r.state === "queued");
|
|
19
|
+
if (!mine) return { status: 404, json: { error: "not_found" } };
|
|
20
|
+
let r = null;
|
|
21
|
+
try {
|
|
22
|
+
r = await stopRun({ id, onBehalfOf: principal.email }); // — same lane, same reason
|
|
23
|
+
} catch (e) {
|
|
24
|
+
const detail = String(e?.message ?? e);
|
|
25
|
+
audit({ event: "queue-cancel", by: principal.email, account, id, ok: false, error: detail });
|
|
26
|
+
return { status: 502, json: { ok: false, unwired: /not wired|verb|scope/i.test(detail),
|
|
27
|
+
error: seesEverything(principal) ? detail : "It could not be cancelled just now. Nothing has been charged." } };
|
|
28
|
+
}
|
|
29
|
+
audit({ event: "queue-cancel", by: principal.email, account, id, ok: Boolean(r?.ok), action: r?.action ?? null });
|
|
30
|
+
// ALREADY-CLAIMED IS A RACE, NOT AN ERROR. The runner picked it up between the click and the
|
|
31
|
+
// request. Say so plainly and let the caller re-read the list, where it is now a running card —
|
|
32
|
+
// never dress a lost race as a failure, and never pre-emptively disable the control to avoid it.
|
|
33
|
+
if (r && r.ok === false && r.action === "already-claimed")
|
|
34
|
+
return { status: 409, json: { ok: false, action: "already-claimed", id,
|
|
35
|
+
error: "It started just before this reached us. It is running now — stop it from the card." } };
|
|
36
|
+
return { status: 200, json: { ok: true, id, action: r?.action ?? null } };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// /portal/api/queue/order — the order queued jobs are admitted in.
|
|
40
|
+
//
|
|
41
|
+
// Written straight to the shared order file rather than through the MCP: reordering spends
|
|
42
|
+
// nothing and starts nothing, so putting it behind an ops verb would widen that token's authority
|
|
43
|
+
// for no gain. The tenancy wall is the same one every other route uses — the caller's resolved
|
|
44
|
+
// account — applied per id.
|
|
45
|
+
if (parts[1] === "api" && parts[2] === "queue" && parts[3] === "order" && method === "POST") {
|
|
46
|
+
const account = assertPrincipal(principal, { account: query.account ?? null, tenant: query.tenant ?? null, run: true });
|
|
47
|
+
if (!account) return { status: 400, json: { error: "name an account (?account=)" } };
|
|
48
|
+
const asked = Array.isArray(body?.order) ? body.order.filter((s) => typeof s === "string" && s) : null;
|
|
49
|
+
if (!asked) return { status: 400, json: { error: "send { order: [id, …] }" } };
|
|
50
|
+
// Only ids this caller actually holds, and only ones still queued. Anything else is dropped
|
|
51
|
+
// SILENTLY rather than refused: a rejection that named the offending id would confirm that some
|
|
52
|
+
// other tenant's job exists, which is the one thing every refusal here is shaped to avoid.
|
|
53
|
+
const ownQueued = new Map(
|
|
54
|
+
scanAccountRuns({ poolRoot, workspaceRoot, account, queueDirs: queueDirs() })
|
|
55
|
+
.filter((r) => r.state === "queued")
|
|
56
|
+
.map((r) => [r.runId, r]),
|
|
57
|
+
);
|
|
58
|
+
const wanted = asked.filter((id) => ownQueued.has(id));
|
|
59
|
+
const applied = reorderQueue({ workspaceRoot, order: wanted, allowed: new Set(ownQueued.keys()) });
|
|
60
|
+
audit({ event: "queue-order", by: principal.email, account, ids: wanted.length, lanes: applied.lanes });
|
|
61
|
+
return { status: 200, json: { ok: true, order: wanted, lanes: applied.lanes } };
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
@@ -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
|
+
//
|
|
4
|
+
// portal-routes/report.mjs — a run's report page and its audit workbook, served to a reader the run belongs to.
|
|
5
|
+
//
|
|
6
|
+
// One of the portal service's route groups, moved out of its dispatcher unchanged; makePortalService says how it asks them.
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { assertPrincipal, mayReadRun, seesEverything } from "../portal-access.mjs";
|
|
10
|
+
import { readReport, resolveReportFile } from "../portal-report.mjs";
|
|
11
|
+
import { readJson } from "../run-record.mjs";
|
|
12
|
+
|
|
13
|
+
export async function reportRoutes({ poolRoot, auditLog }, { method, parts, principal }) {
|
|
14
|
+
// /portal/report/<runId>/audit.xlsx — the audit workbook.
|
|
15
|
+
//
|
|
16
|
+
// MUST be branched before the report route below, which matches any parts.length >= 3 and would
|
|
17
|
+
// otherwise answer this with the report's HTML under a spreadsheet's name.
|
|
18
|
+
//
|
|
19
|
+
// The comment this replaces said the portal "does not serve the file", and the embed strip removes
|
|
20
|
+
// the report's own .xlsx link for that reason — so the workbook has been unreachable from the
|
|
21
|
+
// portal since the portal existed. That was treated as a policy. It is not: the workbook is part of
|
|
22
|
+
// the deliverable, and a link that is stripped without being replaced is a feature that quietly
|
|
23
|
+
// stopped existing.
|
|
24
|
+
//
|
|
25
|
+
// The old objection — "a route serving archive files addressed by a path from the URL is the shape
|
|
26
|
+
// of the bypass that leaked reports" — is answered by construction rather than by declining to
|
|
27
|
+
// build it. The URL supplies ONE path segment, the run id, which is validated to be a directory
|
|
28
|
+
// name and nothing else. The FILENAME is read from that run's meta.json. There is no component of
|
|
29
|
+
// the served path a caller can influence, which is precisely what the report route already does.
|
|
30
|
+
if (parts[1] === "report" && parts.length === 4 && parts[3] === "audit.xlsx" && method === "GET") {
|
|
31
|
+
assertPrincipal(principal, { door: true });
|
|
32
|
+
const runId = parts[2];
|
|
33
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,180}$/.test(runId) || runId.includes(".."))
|
|
34
|
+
return { status: 404, json: { error: "not_found" } };
|
|
35
|
+
const dir = join(poolRoot, runId);
|
|
36
|
+
let meta; try { meta = readJson(join(dir, "meta.json")); } catch { return { status: 404, json: { error: "not_found" } }; }
|
|
37
|
+
const owner = meta.customerKey || "generic";
|
|
38
|
+
if (!mayReadRun(principal, { owner, organisation: meta.organisation ?? null })) return { status: 404, json: { error: "not_found" } };
|
|
39
|
+
// NOT staff-only any more. This route used to 404 a client on role alone — "the workbook is the
|
|
40
|
+
// working paper behind the opinion, not the opinion" — with the note that widening it was a
|
|
41
|
+
// disclosure decision and not one to make in passing. The owner made it on 2026-07-27, in the same
|
|
42
|
+
// ruling that retired the two-report split: one report for everyone, and every reader who owns the
|
|
43
|
+
// run may download its workbook. The ownership check two lines up is the boundary that matters and
|
|
44
|
+
// it is unchanged — a client still sees exactly their own accounts' runs and 404s on anyone else's.
|
|
45
|
+
//
|
|
46
|
+
// (An audit's other half: the link we emailed pointed at the archive path, which the edge stopped
|
|
47
|
+
// serving at the portal cutover, so no client had ever reached this gate to be refused by it. Both
|
|
48
|
+
// ends are fixed together — auditUrlFor() in publish/index.mjs is the other one.)
|
|
49
|
+
// (The held-run 404 that stood here is retired — one report, spec 2026-07-30 §5: ownership is
|
|
50
|
+
// the boundary, and the workbook now carries the machine-QC row every owner may read.)
|
|
51
|
+
// The name comes from the RUN, and is re-checked to be a plain basename even so: meta.json is a
|
|
52
|
+
// generated file, and "generated by us" is not the same as "safe to concatenate into a path".
|
|
53
|
+
const name = typeof meta.auditFile === "string" ? meta.auditFile : "";
|
|
54
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*\.xlsx$/.test(name)) return { status: 404, json: { error: "not_found" } };
|
|
55
|
+
let bytes; try { bytes = readFileSync(join(dir, name)); } catch { return { status: 404, json: { error: "not_found" } }; }
|
|
56
|
+
auditLog(`audit-download run=${runId} by=${principal.email}`);
|
|
57
|
+
return { status: 200, file: {
|
|
58
|
+
body: bytes,
|
|
59
|
+
filename: name,
|
|
60
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
61
|
+
} };
|
|
62
|
+
}
|
|
63
|
+
// /portal/report/<runId>/… — ownership-checked client report; foreign = 404 (never 403)
|
|
64
|
+
if (parts[1] === "report" && parts.length >= 3 && method === "GET") {
|
|
65
|
+
assertPrincipal(principal, { door: true }); // door only — ownership is checked against the META below
|
|
66
|
+
const runId = parts[2];
|
|
67
|
+
// slug gate (review 2026-07-18: the old resolve-vs-resolve clause was a tautology): a runId is a
|
|
68
|
+
// pool dir NAME — one path segment, no dots-only names, nothing traversal-shaped ever reaches fs
|
|
69
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,180}$/.test(runId) || runId.includes(".."))
|
|
70
|
+
return { status: 404, json: { error: "not_found" } };
|
|
71
|
+
const dir = join(poolRoot, runId);
|
|
72
|
+
let meta; try { meta = readJson(join(dir, "meta.json")); } catch { return { status: 404, json: { error: "not_found" } }; }
|
|
73
|
+
const owner = meta.customerKey || "generic";
|
|
74
|
+
// Foreign is 404, never 403, and a Generic run is its organisation's — the same question the connector asks (LEAK-#9 alignment).
|
|
75
|
+
if (!mayReadRun(principal, { owner, organisation: meta.organisation ?? null })) return { status: 404, json: { error: "not_found" } };
|
|
76
|
+
// ONE REPORT PER MARK: `/portal/report/<runId>/` serves a run that has one document, and
|
|
77
|
+
// `/portal/report/<runId>/<slug>/` serves one name's document out of a batch. A batch has no
|
|
78
|
+
// run-level document at all — resolveReportFile returns null and this 404s — because serving mark
|
|
79
|
+
// one of eight as "the report" is the defect the fan-out removed. report.client.html stays
|
|
80
|
+
// retired (the cutover is done: clients.example.com serves through this same readReport
|
|
81
|
+
// preparation). A run you have rights to is always served; the old held-run 404 is deleted with
|
|
82
|
+
// the readiness state it enforced (spec 2026-07-30 §5 — the machine checks moved to the audit
|
|
83
|
+
// workbook and decide nothing here).
|
|
84
|
+
//
|
|
85
|
+
// The slug is matched against the run's OWN list, never used to build a path: `meta.reports` is
|
|
86
|
+
// the only source of a filename here, so a crafted segment can name nothing that is not already a
|
|
87
|
+
// document this run published.
|
|
88
|
+
const wantSlug = parts[3] && parts[3] !== "audit.xlsx" ? parts[3] : null;
|
|
89
|
+
const reportFile = resolveReportFile(meta, wantSlug);
|
|
90
|
+
if (!reportFile || !existsSync(join(dir, reportFile))) return { status: 404, json: { error: "not_found" } };
|
|
91
|
+
// poolRoot is passed so the report's own stylesheet can be inlined: it is linked RELATIVE to the
|
|
92
|
+
// archive (`../assets/chrome.css`) and 404s from under /portal/report/, which is what made every
|
|
93
|
+
// report render with the wrong fonts and a 300px Swiss flag. See portal-report.mjs.
|
|
94
|
+
// — NO FLAG CONTROL IS INJECTED, on this host or any other.
|
|
95
|
+
//
|
|
96
|
+
// `feedback` defaults OFF in prepareReportForEmbed, and this call site was the only opt-in in the
|
|
97
|
+
// tree. Retiring the control is therefore the ABSENCE of an argument rather than a new one — which
|
|
98
|
+
// is why nothing here reads a switch and nothing new was minted to hold one.
|
|
99
|
+
//
|
|
100
|
+
// The injection stays where it is (portal-report.mjs's FEEDBACK_CSS/FEEDBACK_JS, still exercised
|
|
101
|
+
// by portal-report.test.mjs's `feedback: true` arms). The owner ruled disable, not delete, so
|
|
102
|
+
// re-enabling the document half is this argument coming back.
|
|
103
|
+
return { status: 200, html: readReport(dir, { log: auditLog, staff: seesEverything(principal), poolRoot, file: reportFile }) };
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|