chore(storage): bound build retention, caches and test resources
Track build ownership, qualified pins and bounded cache/log lifecycles. Move Vite fixtures to a job-owned server helper and preserve private outputs outside Git.
This commit is contained in:
@@ -56,3 +56,6 @@ node_modules
|
|||||||
|
|
||||||
# Private experiment evidence and generated build archives.
|
# Private experiment evidence and generated build archives.
|
||||||
/outputs/
|
/outputs/
|
||||||
|
|
||||||
|
# Packaged WireGuard binaries are published artifacts, not source.
|
||||||
|
/apps/wireguard-client/build/
|
||||||
|
|||||||
@@ -27,9 +27,36 @@ links to that record for monorepo, storage, resource and live-only telemetry rul
|
|||||||
build-input packages per active build line; preserve separately designated
|
build-input packages per active build line; preserve separately designated
|
||||||
qualified releases and required rollback artifacts. Do not accumulate a new
|
qualified releases and required rollback artifacts. Do not accumulate a new
|
||||||
full package after every iteration without retiring superseded intermediates.
|
full package after every iteration without retiring superseded intermediates.
|
||||||
|
- Build storage lifecycle is implemented by `scripts/packaging/build_retention.py`;
|
||||||
|
follow `docs/STORAGE_RETENTION.md`. New input generators return a persistent
|
||||||
|
active owner handle. After the remote job/transfer/qualification is confirmed
|
||||||
|
terminal, close only your own hold with `finish` (pin qualified/rollback
|
||||||
|
outcomes), review its plan and apply it as part of build completion. Never
|
||||||
|
expire active holds by age or declare unknown legacy inputs disposable.
|
||||||
|
- Run local Python validation through `scripts/check_python.py pytest|ruff|mypy`
|
||||||
|
(pass the usual file/selection arguments). It owns temporary caches, disables
|
||||||
|
persistent pytest/Ruff cache output, and cleans its own scratch after child
|
||||||
|
processes end. Never sweep another active job's cache or unknown crash residue.
|
||||||
|
- Runtime cache publication quotas and bounded service journals are defined in
|
||||||
|
`docs/STORAGE_RETENTION.md`. Existing replay/overlay data remains protected;
|
||||||
|
a full quota refuses a new copy rather than deleting recovery material.
|
||||||
- Check disk space before large builds or captures. Keep task scratch work
|
- Check disk space before large builds or captures. Keep task scratch work
|
||||||
under `.runtime` and clean generated scratch at completion; do not scatter
|
under `.runtime` and clean generated scratch at completion; do not scatter
|
||||||
temporary project folders through the parent repository directory.
|
temporary project folders through the parent repository directory.
|
||||||
|
- Owner amendment, 2026-10-19: completed simulation/urban-infrastructure
|
||||||
|
engineering experiments must not retain unlimited raw frames, render arrays
|
||||||
|
and step-by-step traces by default. At closeout preserve a compact textual
|
||||||
|
report, exact inputs/configuration/source identities, result/limitations and
|
||||||
|
regression evidence; archive text with verified hashes, then retire the
|
||||||
|
explicitly inventoried disposable derived files after all owners stop.
|
||||||
|
Use one content-addressed text copy for duplicates. Keep only the limited
|
||||||
|
visual evidence needed by the final report. Do not leave a complete new
|
||||||
|
media export after every iteration or require the owner to clean it manually.
|
||||||
|
This is a closeout obligation for engineering-owned scratch, not permission
|
||||||
|
to TTL-delete application runs, scans, accepted maps, working code, offline
|
||||||
|
dependencies, installers, qualified releases or pinned rollback. Unknown or
|
||||||
|
active ownership blocks removal; retain a deletion receipt and link the
|
||||||
|
archive from the report/Ops. See the amendment in docs/STORAGE_RETENTION.md.
|
||||||
- Other repositories, platform worktrees, infrastructure, DOC, workspace bridge,
|
- Other repositories, platform worktrees, infrastructure, DOC, workspace bridge,
|
||||||
Site/SEO, BIM Viewer, Device Core, Design Guideline, and Gaussian Pipeline are
|
Site/SEO, BIM Viewer, Device Core, Design Guideline, and Gaussian Pipeline are
|
||||||
separate ownership boundaries. Mission Core cleanup must not alter them.
|
separate ownership boundaries. Mission Core cleanup must not alter them.
|
||||||
@@ -39,6 +66,14 @@ links to that record for monorepo, storage, resource and live-only telemetry rul
|
|||||||
monitoring requires an explicitly provisioned separate service; simulation
|
monitoring requires an explicitly provisioned separate service; simulation
|
||||||
evidence and recordings have a separate lifecycle and must not be deleted as
|
evidence and recordings have a separate lifecycle and must not be deleted as
|
||||||
part of telemetry cleanup.
|
part of telemetry cleanup.
|
||||||
|
- Owner amendment, 2026-10-20: new semantic-learning images, observations,
|
||||||
|
datasets, checkpoints and heavy experiments belong to a separate portable
|
||||||
|
persistent store on Worker 006, outside the source checkout and container
|
||||||
|
writable layer. Never accumulate them on the operator Mac or add a local
|
||||||
|
fallback. Core may keep viewer scenes, semantic results and bounded edit
|
||||||
|
metadata. Saving an edit is not dataset preparation or training acceptance;
|
||||||
|
retain the immutable algorithm result and human provenance separately.
|
||||||
|
See `docs/SEMANTIC_EDITOR.md` for the delivered scope and outstanding gates.
|
||||||
|
|
||||||
## Non-negotiable safety boundaries
|
## Non-negotiable safety boundaries
|
||||||
|
|
||||||
@@ -254,3 +289,40 @@ decoders before BLE/Wi-Fi/data-session evidence exists.
|
|||||||
- Spatial evidence uses 3D by default. Image-space reprojection may be offered
|
- Spatial evidence uses 3D by default. Image-space reprojection may be offered
|
||||||
as a 2D diagnostic mode inside the same reusable viewer. Primary evidence
|
as a 2D diagnostic mode inside the same reusable viewer. Primary evidence
|
||||||
viewers must provide the canonical expand/restore action.
|
viewers must provide the canonical expand/restore action.
|
||||||
|
|
||||||
|
|
||||||
|
## Urban semantic agent contract — owner requirement, 2026-10-26
|
||||||
|
|
||||||
|
- Product foundation: read `docs/SCENE_SEMANTICS_PRODUCT_CONCEPT.md`. Each scan is
|
||||||
|
a standalone local scene, including unnamed/unmapped locations. Raw recorded
|
||||||
|
sensor points support localization; Gaussian observations support the current
|
||||||
|
semantic research. Never substitute Gaussian-derived geometry for raw points.
|
||||||
|
- No GPS/address/public-map prerequisite and no automatic cross-scan geographic
|
||||||
|
matching, overlap search, registration or merging. Those require a separate
|
||||||
|
explicit owner request. Named train/evaluation source lists do not authorize
|
||||||
|
geographic investigation. Preserve source lineage and evaluation honesty.
|
||||||
|
- Crosswalks are functionally important; the target includes all observed road
|
||||||
|
markings for scene context, interface/product value and difficult-task
|
||||||
|
validation. Do not reduce the scope to demo-only markings or crosswalks only.
|
||||||
|
|
||||||
|
- For automated infrastructure annotation, dataset preparation and learning,
|
||||||
|
begin with live Ops MISSIONCOR-93 (agent contract) and MISSIONCOR-88 (product),
|
||||||
|
then `docs/SEMANTIC_AGENT_OPERATING_CONTRACT.md`. Reuse the current hypothesis
|
||||||
|
register and existing experiments; a new chat does not reset the investigation.
|
||||||
|
- The owner explicitly requests MISSIONCOR-93 to hold current architecture,
|
||||||
|
rules, bounded next steps and portable handoff. This is the scoped exception
|
||||||
|
to the earlier delivered-results-only Ops rule. Keep raw logs/media in local
|
||||||
|
engineering evidence; update the current card blocks after meaningful changes.
|
||||||
|
- Root owns the useful outcome, real dispatch, integration and final decision.
|
||||||
|
Use one reusable critic and an optional bounded research scout, at most two
|
||||||
|
active helpers and no nested delegation. Send compact briefs, not full history.
|
||||||
|
- New annotation cycles use the v2 objective/dispatch contract. Approved partial
|
||||||
|
annotations are distinct from completing the enclosing product work package.
|
||||||
|
Handle introduced critical regressions within the session or revert/isolate
|
||||||
|
the change. Do not declare success merely because a ledger or test completed.
|
||||||
|
- Choose reusable pipelines against actual inputs/outputs and accumulated
|
||||||
|
evidence before narrow tuning. Every closed hypothesis states tested scope,
|
||||||
|
supporting artifacts and a substantive condition for reopening. Do not repeat
|
||||||
|
unchanged searches or model variants under a new name.
|
||||||
|
- Worker access/power/runtime authority comes from the owner's current session
|
||||||
|
instructions, never from the card or an old experiment's training allowance.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchAdvancedLaboratoryResults;
|
let fetchAdvancedLaboratoryResults;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {after,before,test} from 'node:test';
|
import {after,before,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
let server,layout,source,fanout,catalog;
|
let server,layout,source,fanout,catalog;
|
||||||
before(async()=>{
|
before(async()=>{
|
||||||
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let canonicalMapGravityLocalPointToBodyGround;
|
let canonicalMapGravityLocalPointToBodyGround;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
|
|
||||||
let server,readContourSnapshot,contourSummary,workerAvailable;
|
let server,readContourSnapshot,contourSummary,workerAvailable;
|
||||||
before(async()=>{
|
before(async()=>{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseDatasetGatewayCatalog;
|
let parseDatasetGatewayCatalog;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseDevicePluginManifest;
|
let parseDevicePluginManifest;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|||||||
import { dirname, join, resolve } from "node:path";
|
import { dirname, join, resolve } from "node:path";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
const testRoot = dirname(fileURLToPath(import.meta.url));
|
const testRoot = dirname(fileURLToPath(import.meta.url));
|
||||||
const controlStationRoot = resolve(testRoot, "..");
|
const controlStationRoot = resolve(testRoot, "..");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { after, before, test } from "node:test";
|
|||||||
|
|
||||||
import React, { createElement } from "react";
|
import React, { createElement } from "react";
|
||||||
import { renderToStaticMarkup } from "react-dom/server";
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let DEVICE_PLUGIN_SELECTED_MODEL_STORAGE_KEY;
|
let DEVICE_PLUGIN_SELECTED_MODEL_STORAGE_KEY;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseE29EvidenceCatalog;
|
let parseE29EvidenceCatalog;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseE30EngineeringCatalog;
|
let parseE30EngineeringCatalog;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseE30HumanReviewDraft;
|
let parseE30HumanReviewDraft;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseE30ReviewCatalog;
|
let parseE30ReviewCatalog;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseE40CaseCatalog;
|
let parseE40CaseCatalog;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46CVideoOverlay;
|
let fetchE46CVideoOverlay;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import test, { after, before } from "node:test";
|
import test, { after, before } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46DTemporalFailureAudit;
|
let fetchE46DTemporalFailureAudit;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import test, { after, before } from "node:test";
|
import test, { after, before } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46EReadyStack;
|
let fetchE46EReadyStack;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import test, { after, before } from "node:test";
|
import test, { after, before } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46FDashCamBakeoff;
|
let fetchE46FDashCamBakeoff;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import test, { after, before } from "node:test";
|
import test, { after, before } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46GRectifiedDetectorBakeoff;
|
let fetchE46GRectifiedDetectorBakeoff;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import test, { after, before } from "node:test";
|
import test, { after, before } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46HFullRectifiedFrontReplay;
|
let fetchE46HFullRectifiedFrontReplay;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import test, { after, before } from "node:test";
|
import test, { after, before } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE46JRawFisheyeRealtime;
|
let fetchE46JRawFisheyeRealtime;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchE47SemanticSlamResult;
|
let fetchE47SemanticSlamResult;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { after, before, test } from "node:test";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { renderToStaticMarkup } from "react-dom/server";
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let backgroundMedia;
|
let backgroundMedia;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let environment;
|
let environment;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let ghostPins;
|
let ghostPins;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let decodeGroundQualification;
|
let decodeGroundQualification;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {after,before,test} from 'node:test';
|
import {after,before,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
let server,optics,exposure;
|
let server,optics,exposure;
|
||||||
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});optics=await server.ssrLoadModule('../../plugins/insta360-x4/frontend/src/panoramaCalibration.ts');exposure=await server.ssrLoadModule('../../plugins/insta360-x4/frontend/src/panoramaExposure.ts');});
|
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});optics=await server.ssrLoadModule('../../plugins/insta360-x4/frontend/src/panoramaCalibration.ts');exposure=await server.ssrLoadModule('../../plugins/insta360-x4/frontend/src/panoramaExposure.ts');});
|
||||||
after(async()=>{await server?.close();});
|
after(async()=>{await server?.close();});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { after, before, test } from "node:test";
|
|||||||
|
|
||||||
import React, { createElement } from "react";
|
import React, { createElement } from "react";
|
||||||
import { renderToStaticMarkup } from "react-dom/server";
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let activeStreamForceFinishAuthority;
|
let activeStreamForceFinishAuthority;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
|||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {createElement} from 'react';
|
import {createElement} from 'react';
|
||||||
import {renderToStaticMarkup} from 'react-dom/server';
|
import {renderToStaticMarkup} from 'react-dom/server';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
|
|
||||||
let server,Detail,presentation,enrolledDevice;
|
let server,Detail,presentation,enrolledDevice;
|
||||||
before(async()=>{
|
before(async()=>{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {execFileSync} from 'node:child_process';
|
import {execFileSync} from 'node:child_process';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
let server,previewFrames,assertRrd,previewFreshness,previewCamera;
|
let server,previewFrames,assertRrd,previewFreshness,previewCamera;
|
||||||
before(async()=>{
|
before(async()=>{
|
||||||
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { after, before, test } from "node:test";
|
|||||||
|
|
||||||
import React, { createElement } from "react";
|
import React, { createElement } from "react";
|
||||||
import { renderToStaticMarkup } from "react-dom/server";
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let normalizeXgridsK1MissionState;
|
let normalizeXgridsK1MissionState;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server, fetchLabViewProfile, saveLabViewProfile, normalizeLabSceneSettings;
|
let server, fetchLabViewProfile, saveLabViewProfile, normalizeLabSceneSettings;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchLaboratoryValueReviewIndex;
|
let fetchLaboratoryValueReviewIndex;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let laboratoryRecordedEvidenceDemand;
|
let laboratoryRecordedEvidenceDemand;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseLidarReplayCatalog;
|
let parseLidarReplayCatalog;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let advanceLiveReceiverOpenWatchdog;
|
let advanceLiveReceiverOpenWatchdog;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let createLiveViewerDiagnosticLifecycle;
|
let createLiveViewerDiagnosticLifecycle;
|
||||||
let createAbortFencedBuildVerifier;
|
let createAbortFencedBuildVerifier;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let parseLidarLocalSurfaceCatalog;
|
let parseLidarLocalSurfaceCatalog;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchM47ReferenceGraphLab;
|
let fetchM47ReferenceGraphLab;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFileSync, readdirSync } from "node:fs";
|
import { readFileSync, readdirSync } from "node:fs";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let decodeM48GateStatus;
|
let decodeM48GateStatus;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { existsSync, readFileSync } from "node:fs";
|
import { existsSync, readFileSync } from "node:fs";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchM48SmallStaticRegression;
|
let fetchM48SmallStaticRegression;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchM48SFixedClassDetectorResult;
|
let fetchM48SFixedClassDetectorResult;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchM48TRiskQualityResult;
|
let fetchM48TRiskQualityResult;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { createHash } from "node:crypto";
|
import { createHash } from "node:crypto";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let M49PhysicalSafetyPlaybackBuffer;
|
let M49PhysicalSafetyPlaybackBuffer;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchM49TgsFullShadowSpatialChunk;
|
let fetchM49TgsFullShadowSpatialChunk;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchM4ThreatReplayResult;
|
let fetchM4ThreatReplayResult;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { before, after, test } from 'node:test';
|
import { before, after, test } from 'node:test';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from './support/vite-server.mjs';
|
||||||
let server, api;
|
let server, api;
|
||||||
before(async () => { server = await createServer({ appType: 'custom', logLevel: 'silent', server: { middlewareMode: true } }); api = await server.ssrLoadModule('/src/core/missions/planner.ts'); });
|
before(async () => { server = await createServer({ appType: 'custom', logLevel: 'silent', server: { middlewareMode: true } }); api = await server.ssrLoadModule('/src/core/missions/planner.ts'); });
|
||||||
after(async () => { await server?.close(); });
|
after(async () => { await server?.close(); });
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { before, after, test } from "node:test";
|
import { before, after, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let observeProvisioningRequest;
|
let observeProvisioningRequest;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let decodeObservationSessionCatalog;
|
let decodeObservationSessionCatalog;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { after, before, test } from "node:test";
|
|||||||
|
|
||||||
import { createElement } from "react";
|
import { createElement } from "react";
|
||||||
import { renderToStaticMarkup } from "react-dom/server";
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let xgridsK1Manifest;
|
let xgridsK1Manifest;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let applyObservatoryCatalogMutationOverlay;
|
let applyObservatoryCatalogMutationOverlay;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let deleteObservatoryLabProjection;
|
let deleteObservatoryLabProjection;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let useObservatoryRecordedJobs;
|
let useObservatoryRecordedJobs;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchObservatoryLaboratorySetups;
|
let fetchObservatoryLaboratorySetups;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchObservatoryRecordedJobs;
|
let fetchObservatoryRecordedJobs;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let decode;
|
let decode;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let admitObservatoryRecordedRunReview;
|
let admitObservatoryRecordedRunReview;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let productModel;
|
let productModel;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchPerceptionPreparationStatus;
|
let fetchPerceptionPreparationStatus;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
|
|
||||||
let server,createReporter;
|
let server,createReporter;
|
||||||
before(async()=>{
|
before(async()=>{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { before, after, test } from 'node:test';
|
import { before, after, test } from 'node:test';
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from './support/vite-server.mjs';
|
||||||
let server, api;
|
let server, api;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
server = await createServer({appType: 'custom', logLevel: 'silent', server: {middlewareMode: true}});
|
server = await createServer({appType: 'custom', logLevel: 'silent', server: {middlewareMode: true}});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
import {readFileSync} from 'node:fs';
|
import {readFileSync} from 'node:fs';
|
||||||
let server,start;
|
let server,start;
|
||||||
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});({startPlanningSceneStream:start}=await server.ssrLoadModule('/src/core/missions/planningSceneStream.ts'));});
|
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});({startPlanningSceneStream:start}=await server.ssrLoadModule('/src/core/missions/planningSceneStream.ts'));});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
import {createElement} from 'react';
|
import {createElement} from 'react';
|
||||||
import {renderToStaticMarkup} from 'react-dom/server';
|
import {renderToStaticMarkup} from 'react-dom/server';
|
||||||
import {readFileSync} from 'node:fs';
|
import {readFileSync} from 'node:fs';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
|||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {renderToStaticMarkup} from 'react-dom/server';
|
import {renderToStaticMarkup} from 'react-dom/server';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
import {readFile} from 'node:fs/promises';
|
import {readFile} from 'node:fs/promises';
|
||||||
|
|
||||||
let server,usePlanner,Settings;
|
let server,usePlanner,Settings;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let decodePolygonRunCatalog;
|
let decodePolygonRunCatalog;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let productModel;
|
let productModel;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchRecordedMediaArchive;
|
let fetchRecordedMediaArchive;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { readFileSync } from "node:fs";
|
import { readFileSync } from "node:fs";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server, readNativeRerunCameraEye;
|
let server, readNativeRerunCameraEye;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let admission;
|
let admission;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server, createIsolatedRerunHost, keepRecordedBlueprintSession, createRecordedRerunFacade, createRecordedRerunOwner, relayIsolatedRerunInput;
|
let server, createIsolatedRerunHost, keepRecordedBlueprintSession, createRecordedRerunFacade, createRecordedRerunOwner, relayIsolatedRerunInput;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let claimExclusiveLiveViewer;
|
let claimExclusiveLiveViewer;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let attemptRecordedAutoplay;
|
let attemptRecordedAutoplay;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let canPublishRecordedPlaybackController;
|
let canPublishRecordedPlaybackController;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
let server,sameConfiguration;
|
let server,sameConfiguration;
|
||||||
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});({sameConfiguration}=await server.ssrLoadModule('/src/core/fleet/configurationEquality.ts'));});
|
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});({sameConfiguration}=await server.ssrLoadModule('/src/core/fleet/configurationEquality.ts'));});
|
||||||
after(async()=>server?.close());
|
after(async()=>server?.close());
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let guard;
|
let guard;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let selectMonotonicXgridsState;
|
let selectMonotonicXgridsState;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before,after,test} from 'node:test';
|
import {before,after,test} from 'node:test';
|
||||||
import {readFileSync,readdirSync} from 'node:fs';
|
import {readFileSync,readdirSync} from 'node:fs';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
let server,api,resolveContribution,wirelessContributions,revealEnrollment;
|
let server,api,resolveContribution,wirelessContributions,revealEnrollment;
|
||||||
before(async()=>{
|
before(async()=>{
|
||||||
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import {before, after, test} from 'node:test';
|
import {before, after, test} from 'node:test';
|
||||||
import {createServer} from 'vite';
|
import {createServer} from './support/vite-server.mjs';
|
||||||
import {createElement} from 'react';
|
import {createElement} from 'react';
|
||||||
import {renderToStaticMarkup} from 'react-dom/server';
|
import {renderToStaticMarkup} from 'react-dom/server';
|
||||||
import {readFile} from 'node:fs/promises';
|
import {readFile} from 'node:fs/promises';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { before, after, test } from 'node:test';
|
import { before, after, test } from 'node:test';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from './support/vite-server.mjs';
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
let server, api;
|
let server, api;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { before, after, test } from 'node:test';
|
import { before, after, test } from 'node:test';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from './support/vite-server.mjs';
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
let server, api;
|
let server, api;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { readFile } from 'node:fs/promises';
|
|||||||
import { before, after, test } from 'node:test';
|
import { before, after, test } from 'node:test';
|
||||||
import { createElement } from 'react';
|
import { createElement } from 'react';
|
||||||
import { renderToStaticMarkup } from 'react-dom/server';
|
import { renderToStaticMarkup } from 'react-dom/server';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from './support/vite-server.mjs';
|
||||||
|
|
||||||
let server, SpatialScene;
|
let server, SpatialScene;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# SSR unit-test server
|
||||||
|
|
||||||
|
Import `createServer` from `./support/vite-server.mjs` in tests, instead of from Vite.
|
||||||
|
The helper keeps normal project resolution and plugins, disables browser/SSR
|
||||||
|
prebundling after plugin configuration, and gives every server its own directory
|
||||||
|
under the repository `.runtime/frontend-unit-tests`.
|
||||||
|
|
||||||
|
Keep the server alive for the whole test file: create it in `before`, and await
|
||||||
|
`server?.close()` in the file's existing `after` hook. A server created inside a
|
||||||
|
test must close in `finally`. Closing twice is safe. The helper cleans its own
|
||||||
|
cache after close and on initialization failure; it does not register a nested
|
||||||
|
`after` hook, which could close a file-scoped server before later tests use it.
|
||||||
|
|
||||||
|
`npm run test:unit` executes files sequentially for the operator Mac's memory
|
||||||
|
budget. Production and development Vite configuration is unchanged.
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { createServer as createViteServer } from "vite";
|
||||||
|
|
||||||
|
export const testCacheRoot = fileURLToPath(
|
||||||
|
new URL("../../../../.runtime/frontend-unit-tests/", import.meta.url),
|
||||||
|
);
|
||||||
|
|
||||||
|
// SSR unit tests compile modules; they never need the browser dependency scan.
|
||||||
|
// Each server owns its scratch directory, including failed initialization.
|
||||||
|
export async function createServer(options = {}) {
|
||||||
|
await mkdir(testCacheRoot, { recursive: true });
|
||||||
|
const cacheDir = await mkdtemp(`${testCacheRoot}vite-`);
|
||||||
|
const noDiscovery = { noDiscovery: true, include: [] };
|
||||||
|
let server;
|
||||||
|
try {
|
||||||
|
server = await createViteServer({
|
||||||
|
...options,
|
||||||
|
plugins: [
|
||||||
|
...(options.plugins ?? []),
|
||||||
|
{
|
||||||
|
name: "mission-core-ssr-unit-test",
|
||||||
|
configResolved(config) {
|
||||||
|
// React and other plugins can add includes in their config hooks.
|
||||||
|
// Disable both client and SSR prebundling after those hooks finish.
|
||||||
|
for (const environment of Object.values(config.environments)) {
|
||||||
|
environment.optimizeDeps.noDiscovery = true;
|
||||||
|
environment.optimizeDeps.include = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cacheDir,
|
||||||
|
server: { ...options.server, middlewareMode: true, hmr: false, watch: null },
|
||||||
|
optimizeDeps: { ...options.optimizeDeps, ...noDiscovery },
|
||||||
|
environments: {
|
||||||
|
...options.environments,
|
||||||
|
client: {
|
||||||
|
...options.environments?.client,
|
||||||
|
optimizeDeps: { ...options.environments?.client?.optimizeDeps, ...noDiscovery },
|
||||||
|
},
|
||||||
|
ssr: {
|
||||||
|
...options.environments?.ssr,
|
||||||
|
optimizeDeps: { ...options.environments?.ssr?.optimizeDeps, ...noDiscovery },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
await rm(cacheDir, { recursive: true, force: true });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
const close = server.close.bind(server);
|
||||||
|
let closing;
|
||||||
|
server.close = () => closing ??= (async () => {
|
||||||
|
try {
|
||||||
|
await close();
|
||||||
|
} finally {
|
||||||
|
await rm(cacheDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return server;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { access, readFile } from "node:fs/promises";
|
import { access, readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let fetchVegetationBenchmarkResult;
|
let fetchVegetationBenchmarkResult;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let LABORATORY_RECORDED_EVIDENCE_VIEWER_PROFILE;
|
let LABORATORY_RECORDED_EVIDENCE_VIEWER_PROFILE;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let createLatestAsyncCommitter;
|
let createLatestAsyncCommitter;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let viewerSettingsTargetIdentity;
|
let viewerSettingsTargetIdentity;
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { access, readdir, writeFile } from "node:fs/promises";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { test } from "node:test";
|
||||||
|
import { createServer, testCacheRoot } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
|
async function absent(path) {
|
||||||
|
await assert.rejects(access(path), { code: "ENOENT" });
|
||||||
|
}
|
||||||
|
|
||||||
|
test("SSR servers load real modules without dependency bundles and remove only their own cache", async () => {
|
||||||
|
assert.equal(testCacheRoot, fileURLToPath(new URL("../../../.runtime/frontend-unit-tests/", import.meta.url)));
|
||||||
|
const first = await createServer({ logLevel: "silent" });
|
||||||
|
const second = await createServer({ configFile: false, logLevel: "silent" });
|
||||||
|
try {
|
||||||
|
assert.notEqual(first.config.cacheDir, second.config.cacheDir);
|
||||||
|
for (const server of [first, second]) {
|
||||||
|
for (const name of ["client", "ssr"]) {
|
||||||
|
assert.equal(server.environments[name].config.optimizeDeps.noDiscovery, true);
|
||||||
|
assert.deepEqual(server.environments[name].config.optimizeDeps.include, []);
|
||||||
|
}
|
||||||
|
const loaded = await server.ssrLoadModule("/src/core/simulation/urbanMap.ts");
|
||||||
|
assert.equal(typeof loaded.loadUrbanMap, "function");
|
||||||
|
assert.deepEqual(await readdir(server.config.cacheDir), []);
|
||||||
|
}
|
||||||
|
const survivor = join(second.config.cacheDir, "owned-marker");
|
||||||
|
await writeFile(survivor, "keep");
|
||||||
|
await Promise.all([first.close(), first.close()]);
|
||||||
|
await absent(first.config.cacheDir);
|
||||||
|
await access(survivor);
|
||||||
|
} finally {
|
||||||
|
await first.close();
|
||||||
|
await second.close();
|
||||||
|
}
|
||||||
|
await absent(second.config.cacheDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("failed Vite configuration removes its scratch directory", async () => {
|
||||||
|
const before = (await readdir(testCacheRoot)).sort();
|
||||||
|
await assert.rejects(createServer({
|
||||||
|
configFile: false,
|
||||||
|
logLevel: "silent",
|
||||||
|
plugins: [{ name: "intentional-startup-failure", config() { throw new Error("expected startup failure"); } }],
|
||||||
|
}), /expected startup failure/);
|
||||||
|
assert.deepEqual((await readdir(testCacheRoot)).sort(), before);
|
||||||
|
});
|
||||||
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { after, before, test } from "node:test";
|
import { after, before, test } from "node:test";
|
||||||
|
|
||||||
import { createServer } from "vite";
|
import { createServer } from "./support/vite-server.mjs";
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
let decodeObservationWorkspaceLayoutProfile;
|
let decodeObservationWorkspaceLayoutProfile;
|
||||||
|
|||||||
@@ -58,3 +58,9 @@ provisioner should use a hidden prompt, stdin/file descriptor with strict
|
|||||||
permissions, or macOS Keychain. Logs and manifests record only that a credential
|
permissions, or macOS Keychain. Logs and manifests record only that a credential
|
||||||
was supplied, never its value or unredacted payload bytes.
|
was supplied, never its value or unredacted payload bytes.
|
||||||
|
|
||||||
|
|
||||||
|
## Storage lifecycle
|
||||||
|
|
||||||
|
See [Storage retention](STORAGE_RETENTION.md) for executable intermediate-build
|
||||||
|
retention, release/rollback pins, active build ownership, protected evidence,
|
||||||
|
cache boundaries and interrupted-cleanup recovery.
|
||||||
|
|||||||
@@ -0,0 +1,269 @@
|
|||||||
|
# Mission Core storage lifecycle
|
||||||
|
|
||||||
|
Policy revision: `operator-storage-v2` (2026-10-16).
|
||||||
|
Build-input policy remains `two-closed-inputs-per-line-v1`.
|
||||||
|
This implements the storage boundaries in `AGENTS.md` and supplements
|
||||||
|
[the artifact policy](03_ARTIFACT_POLICY.md). It applies only to the canonical
|
||||||
|
operator checkout; other repositories, boards, Worker 006 and Docker storage
|
||||||
|
are separate owners. No system-wide prune or periodic deletion timer is installed. Cache budgets
|
||||||
|
run at publication; service journal rotation runs in the owning writer.
|
||||||
|
|
||||||
|
## Classes and enforcement
|
||||||
|
|
||||||
|
| Data | Retention and mechanism |
|
||||||
|
| --- | --- |
|
||||||
|
| Source, configuration, secrets, `.git`, installed dependencies and active UI | Not disposable storage. No generic age-based cleanup. |
|
||||||
|
| Imported Gaussian worlds, recordings, evidence, missions, plans, accepted maps, session map versions | Durable application data. No TTL. Deletion belongs to the owning product workflow or an explicitly reviewed archive/removal operation. |
|
||||||
|
| Simulation qualifications, computation experiments/results, engineering materials | Preserve unique evidence and the exact input/configuration/result relationship. An old experiment is not a cache. Archive only with a verified destination and complete dependency inventory. |
|
||||||
|
| Qualified releases and rollback artifacts | Explicit pins; retain independently of the intermediate count. Retiring a release requires removing its pin by name and recording the reason. |
|
||||||
|
| Intermediate Linux build inputs | Keep two most recently **published, completed, unpinned** inputs per line, plus every transitive base of retained inputs. Lines are `node/node-only`, `node/node-core`, `x4/native`, `x4/package`, `x4/owner`. Enforced by `scripts/packaging/build_retention.py`. |
|
||||||
|
| Active/disconnected builds, transfers and qualifications | Persistent active hold, with owner token. No automatic expiry. Explicit terminal outcome releases the hold. Eight unfinished inputs per archive family block the next publication. Node profiles share this conservative unfinished limit. |
|
||||||
|
| Old or unknown inputs | Protected as `legacy-unreviewed`; importing into the registry requires a named protective pin. Neither mtime nor lack of a reference proves that a legacy file is disposable. |
|
||||||
|
| General artifact gateway cache | Existing LRU/pin implementation: default 8 GiB local quota and 2 GiB free-space reserve; pinned objects survive eviction. Configuration may override these defaults. Not handled by build retention. |
|
||||||
|
| Portable replay, integrated/canonical LAB overlays, editor scene assets | Existing generations are protected. New publication has a per-owner quota and a 2 GiB free-space reserve; no automatic eviction or TTL. Cache hits and sealed recovery remain available at quota. See the limits below. |
|
||||||
|
| Worker source CAS and sealed modular-node results | Separate Worker/result ownership. No new deletion or expiry; a source/result can be unique or required by a retained job. Existing source admission/free-space checks remain. |
|
||||||
|
| Vite unit-test cache | Each server owns a unique `.runtime/frontend-unit-tests` directory and removes it on close or failed creation. Existing test helper enforces this; tests run sequentially. Abandoned crash files need a separate verified cleanup. |
|
||||||
|
| Python check caches | `scripts/check_python.py pytest/ruff/mypy` creates one owned `.runtime/python-checks` temporary directory, disables persistent pytest/Ruff caches and redirects mypy there. Stop owned helper processes before cleanup, including failed checks. Four active/unreconciled check directories or a 512 MiB admission budget block the next check; 64 MiB of headroom is required before admission. Existing/foreign crash residue is preserved. Direct ad-hoc tool invocation is outside this managed entry point. |
|
||||||
|
| Compiler caches and other task scratch | Disposable only with no active owner. Node Linux build jobs already place Go/npm state inside their owned build folder; remote staging is a separate lifecycle. Never purge shared toolchains, downloaded offline dependencies or another job’s directory. |
|
||||||
|
| Operator monitoring | Live-only RAM: one latest snapshot per node, maximum 32 nodes, 192 KiB snapshot plus 32 KiB duplicate-comparison sample per node; 30-second expiry, one-second idle sweep and UTC daily reset. No local history database. UI/API use current observations only. Retire an obsolete replica only after live-mode acceptance with the scoped plan/apply tool; see [operator monitoring](OPERATOR_MONITORING.md). |
|
||||||
|
| Routine service logs | Core, Observatory/Gaussian worker tunnels, telemetry startup/tunnel and Map Gateway link use `rotating_process`: 8 MiB × (current + 4 backups), at most 40 MiB per service. Legacy journals remain intact and stop growing after migration. Scanner diagnostics use 5 MiB + 5 backups with 16 KiB records and private files after rotation. Existing Docker logs remain `local`, 5 MiB × 2 per container. Experiment/build/mission calculation logs remain evidence and are excluded. |
|
||||||
|
|
||||||
|
A 6 GiB build-input soft budget is reported, not used to override pins. A
|
||||||
|
producer checks the uncompressed estimated payload plus ZIP overhead and leaves
|
||||||
|
at least 2 GiB free before staging. Existing Linux/qualification-specific space
|
||||||
|
checks still apply. If protected data consumes the budget, report it and stop
|
||||||
|
creating more inputs when the free-space guard fails; do not delete evidence.
|
||||||
|
The two-input rule is a count policy, not a promise of a total storage ceiling.
|
||||||
|
|
||||||
|
## Build lifecycle
|
||||||
|
|
||||||
|
The four generators (Node Linux, X4 native, X4 package, X4 owner wrapper) publish
|
||||||
|
through the same local helper. They write a uniquely owned temporary file,
|
||||||
|
validate manifest identity and base hashes, then publish without replacing an
|
||||||
|
existing path and persist the active hold. Their existing JSON response adds:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"retention": {"path": "apps/node-agent/build/mission-core-node-linux-build-<id>.pyz", "owner": "<token>", "state": "active"}}
|
||||||
|
```
|
||||||
|
|
||||||
|
A failed writer removes only its own temporary file. A crash after publication
|
||||||
|
but before registry commit leaves a protected unknown input. The helper is
|
||||||
|
operator packaging code, not a new board/runtime dependency. Production inputs
|
||||||
|
are not rebuilt just to exercise retention.
|
||||||
|
|
||||||
|
After the remote job and every dependent transfer/qualification actually end,
|
||||||
|
the owning engineer/agent must close the hold using the returned path and owner:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py finish "$input" \
|
||||||
|
--owner "$owner" --outcome intermediate --reason "Build and transfer completed; no retained release uses this input" \
|
||||||
|
> .runtime/build-retention/review-plan.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Choose `failed` or `cancelled` only after the job has stopped. These inputs join
|
||||||
|
the two-input history; failure does not silently delete diagnostic evidence.
|
||||||
|
Choose `qualified` or `rollback` to close the active hold **and** add the named
|
||||||
|
permanent pin. Add another named pin before a later qualification/release starts
|
||||||
|
using an already completed input. Do not close someone else's active build.
|
||||||
|
A disconnected job remains active until terminal state is established.
|
||||||
|
|
||||||
|
Review the returned plan (or generate a fresh one) and apply it as the final
|
||||||
|
build-storage step; this is part of build completion, not a user-facing manual
|
||||||
|
maintenance ritual. `finish` itself never deletes bytes.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py plan \
|
||||||
|
> .runtime/build-retention/review-plan.json
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py apply \
|
||||||
|
--plan .runtime/build-retention/review-plan.json
|
||||||
|
```
|
||||||
|
|
||||||
|
On a never-initialized checkout, `plan` is read-only and does not create the
|
||||||
|
control directory; save its output to an existing task-owned directory instead.
|
||||||
|
An older plan is refused if a file, lifecycle state or pin changes. Review and
|
||||||
|
regenerate it. Do not edit the plan to force deletion. A malformed package,
|
||||||
|
missing/changed base, unexplained missing registered input, or unsafe path blocks
|
||||||
|
**all** deletions in that operation.
|
||||||
|
|
||||||
|
Explicit legacy enrollment and release pinning:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py adopt "$input" \
|
||||||
|
--pin legacy-review --reason "Retained provenance; exact evidence record path"
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py pin "$input" \
|
||||||
|
--pin release-0.1.3 --reason "Qualified release and its evidence record"
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py unpin "$input" \
|
||||||
|
--pin legacy-review --reason "Reviewed as superseded intermediate; no release or rollback depends on it"
|
||||||
|
```
|
||||||
|
|
||||||
|
`unpin` is an explicit decision, not an automatic inference from time or a failed
|
||||||
|
build log. All unknown inputs remain protected even without registry enrollment.
|
||||||
|
|
||||||
|
## Integrity, interruption and audit
|
||||||
|
|
||||||
|
Only exact build-input filenames directly under `apps/node-agent/build` and
|
||||||
|
`plugins/insta360-x4/build` are eligible. Installers, `.deb` releases, qualified
|
||||||
|
subdirectories, rollback copies and runtime data are outside the allowlist.
|
||||||
|
Symlinks and traversal paths are refused. Publications and maintenance share an
|
||||||
|
OS file lock; generators cannot race an applied plan. External tools must use
|
||||||
|
the same helper rather than mutating managed inputs in place.
|
||||||
|
|
||||||
|
The plan verifies full archive hashes, manifest IDs, profiles and dependency
|
||||||
|
closure. Apply independently recomputes the plan under lock and checks each file
|
||||||
|
again before unlink. Dependants are removed before their bases, so an interrupted
|
||||||
|
operation does not strand a retained delta. Every unlink is journaled under
|
||||||
|
`.runtime/build-retention/receipts`, including the planned identity, actual removed
|
||||||
|
paths, status and free-space observations. There is no recursive directory delete.
|
||||||
|
|
||||||
|
An interrupted apply can be reconciled using the receipt basename:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
.venv/bin/python scripts/packaging/build_retention.py recover "$receipt_basename"
|
||||||
|
```
|
||||||
|
|
||||||
|
Recovery only reconciles already journaled missing files; it performs no deletion.
|
||||||
|
After reviewing the receipt, create a new plan for the remaining files. Receipts
|
||||||
|
and lifecycle records are small engineering evidence, not raw telemetry; preserve
|
||||||
|
them. A crash before an unlink is distinguishable from one after it by the file's
|
||||||
|
presence and verified identity.
|
||||||
|
|
||||||
|
`candidate_bytes_upper_bound` is logical file size, **not** promised reclaimed
|
||||||
|
space: hardlinks/APFS clones can share blocks. Receipts report filesystem free
|
||||||
|
space before/after; concurrent system activity can affect that delta.
|
||||||
|
|
||||||
|
## Acceptance
|
||||||
|
|
||||||
|
`tests/test_build_retention.py` covers separate lines, transitive bases, release
|
||||||
|
and rollback pins, legacy protection, active owners and restart, stale/edited
|
||||||
|
plans, unsafe paths, hash changes, publication failure, missing bases, capacity
|
||||||
|
refusal, concurrent publication, partial deletion, crash recovery and hardlinks.
|
||||||
|
It also executes all four real producer wrappers with tiny synthetic input
|
||||||
|
fixtures. Existing delta reuse and artifact-cache tests remain applicable.
|
||||||
|
|
||||||
|
The initial live adoption preserves reviewed historical inputs and leaves new
|
||||||
|
unreviewed inputs protected. No old source bundle is declared disposable merely
|
||||||
|
because this policy has been installed.
|
||||||
|
|
||||||
|
|
||||||
|
## Local derived-cache budgets
|
||||||
|
|
||||||
|
`src/k1link/cache_budget.py` provides one admission/publication lock across local
|
||||||
|
processes, a full logical-byte inventory and a 2 GiB free-space reserve. Unknown
|
||||||
|
files, existing generations, partial outputs and sidecars count against capacity.
|
||||||
|
Symlink/special-file inventories are refused, never followed or deleted. Up to
|
||||||
|
10,000 files are admitted by default (4,096 for editor assets). Quotas are
|
||||||
|
conservative logical sizes; hardlinks/APFS clones do not authorize deletion.
|
||||||
|
|
||||||
|
| Cache owner | Publication quota | At capacity |
|
||||||
|
| --- | ---: | --- |
|
||||||
|
| Exact camera JPEG frames | 256 MiB | Return the validated decoded frame without a new disk copy; retained frames still work. |
|
||||||
|
| LiDAR validation proofs | 16 MiB | Validate the original normally; skip the optional proof write. |
|
||||||
|
| Prepared camera media sidecars | 64 MiB | Use the validated manifest in memory; skip the optional sidecar write. |
|
||||||
|
| Perception overlays | 1 GiB | Refuse a new cached generation; retain existing generations. |
|
||||||
|
| Calibrated fusion overlays | 1 GiB | Same. |
|
||||||
|
| Integrated perception overlays | 4 GiB | Same; reconstruct admission in memory if its optional sidecar cannot fit, so an existing sealed overlay remains usable. |
|
||||||
|
| Canonical LAB overlays + replay | 4 GiB combined | Reuse existing admitted output; refuse new publication when insufficient room. |
|
||||||
|
| Portable replay + camera proxies | 4 GiB combined | Same. |
|
||||||
|
| Editor scene assets | 4 GiB | Account for all declared, unfinished transfers before accepting a new manifest or chunk. Do not discard partial uploads or ready assets. |
|
||||||
|
|
||||||
|
Larger renderers check room before work and again under the publication lock.
|
||||||
|
The final check counts staged bytes already on disk, plus sidecar headroom. This
|
||||||
|
bounds accumulated published copies; it is **not an OS filesystem quota** or a
|
||||||
|
promise that transient renderer scratch never exceeds the publication budget.
|
||||||
|
Existing bounded renderer inputs/outputs/timeouts and `finally` cleanup still
|
||||||
|
apply. Crash residue is counted and protected, so it can stop further admission;
|
||||||
|
its owner must be investigated before removal. No broad crash-directory sweep
|
||||||
|
is enabled. A quota cannot both preserve arbitrary unique data and allow
|
||||||
|
unlimited new copies; capacity refusal is intentional and explicit.
|
||||||
|
|
||||||
|
General artifact/recording caches retain their established LRU/pin contracts.
|
||||||
|
No new automatic removal is applied to simulation worlds, source media, plans,
|
||||||
|
accepted geometry, qualifications, results, offline dependencies or rollback.
|
||||||
|
The earlier Vite SSR helper still owns/cleans each test cache and disables
|
||||||
|
unnecessary dependency prebundling. Ordinary development sessions and external
|
||||||
|
user commands are not silently enrolled into a global cleanup job.
|
||||||
|
|
||||||
|
## Bounded service journals and migration
|
||||||
|
|
||||||
|
`src/k1link/rotating_process.py` supervises the exact existing command and drains
|
||||||
|
merged stdout/stderr through a bounded binary writer. Rotation splits even a
|
||||||
|
large single write, retains current + four backups and holds an exclusive lock.
|
||||||
|
It does not copy/truncate a file concurrently written by a service. Binary bytes
|
||||||
|
are preserved within the retention window. Signals reach the child; launchd
|
||||||
|
continues to own the whole process group. If disk writes fail, the pipe is still
|
||||||
|
drained with a bounded loss counter so logging cannot deadlock Core. A recovery
|
||||||
|
marker reports dropped bytes when writing becomes possible again.
|
||||||
|
|
||||||
|
The outer `uv run --no-sync --project` uses the existing Mac execution boundary;
|
||||||
|
no packages are synchronized. Its pre-Python bootstrap stdout/stderr goes to
|
||||||
|
`/dev/null`; bootstrap failure is diagnosed through launchd exit status and the
|
||||||
|
hash-gated rollback check. Child output, including Python exceptions, goes to
|
||||||
|
`*.managed.log`. No credentials, SSH arguments, routes or Docker settings change.
|
||||||
|
|
||||||
|
The original command/environment/scheduling fields are preserved by
|
||||||
|
`scripts/manage_runtime_log_policy.py`. Apply requires an exact current plan,
|
||||||
|
saves the original plist under `.runtime/storage-maintenance/log-policy`, reloads
|
||||||
|
one existing service and verifies Core health or stable helper state. Failed
|
||||||
|
acceptance restores the exact previous declaration and checks it. Plans and
|
||||||
|
receipts contain hashes and service metadata, never environment secrets.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
.venv/bin/python scripts/manage_runtime_log_policy.py plan core > .runtime/core-log-plan.json
|
||||||
|
.venv/bin/python scripts/manage_runtime_log_policy.py apply core --plan .runtime/core-log-plan.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Other explicit owners: `observatory`, `gaussian`, `telemetry-startup`,
|
||||||
|
`telemetry-tunnel`, `map`. Existing journals are left byte-for-byte intact as a
|
||||||
|
one-time legacy baseline; they are not added to the rotating set or compressed
|
||||||
|
in place. Existing launch-agent generators emit the bounded writer declaration,
|
||||||
|
so a subsequent normal update does not restore unbounded output. A fresh plan
|
||||||
|
after installation is unchanged. No new long-running service besides each
|
||||||
|
existing service's output supervisor is introduced.
|
||||||
|
|
||||||
|
## Cache/log acceptance
|
||||||
|
|
||||||
|
Tests cover exact quotas, free-space reserve, protected unknown files, concurrent
|
||||||
|
publication, unfinished editor reservations, optional camera-cache fallback,
|
||||||
|
sealed-overlay recovery at capacity, bounded binary rotation across restart,
|
||||||
|
exclusive writers, linked-path rejection, child exit/signal handling, private
|
||||||
|
rotated diagnostics, stale migration refusal and exact rollback on failed health.
|
||||||
|
The Python-check wrapper is tested on successful and failed child exits while
|
||||||
|
preserving another job's directory. Live acceptance separately verifies all
|
||||||
|
six declarations, Core/API/catalog health, unchanged existing-cache hashes and
|
||||||
|
zero owned test-cache residue. No high-volume live log or renderer load test is
|
||||||
|
run on the operator Mac.
|
||||||
|
|
||||||
|
|
||||||
|
## Simulation experiment closeout — owner amendment 2026-10-19
|
||||||
|
|
||||||
|
The owner explicitly authorized retiring historical engineering frames, render
|
||||||
|
arrays and simulation trial traces after detailed textual preservation. This
|
||||||
|
supplements the evidence rule above; it does not remove protection from product
|
||||||
|
state, input worlds, working source, offline dependencies, releases or rollback.
|
||||||
|
|
||||||
|
For future engineering-owned simulation/infrastructure trials, closeout is part
|
||||||
|
of completing the experiment, not a later request for the owner to free disk:
|
||||||
|
|
||||||
|
1. Before capture/export, declare the exact owned temporary directory, expected
|
||||||
|
bytes and a finite capture limit. Check free space and reuse identical
|
||||||
|
source/observations by identity instead of exporting another complete copy.
|
||||||
|
2. Once all writers/remote owners are confirmed terminal, write the hypothesis,
|
||||||
|
inputs/configuration/source identities, observed result, quality/time,
|
||||||
|
failures and next decision. Preserve regression evidence and the small set
|
||||||
|
of images referenced by the final report. A failed experiment also closes.
|
||||||
|
3. Store exact textual material once per content hash; preserve the original
|
||||||
|
path-to-hash index. Verify the archive by reading it before deleting originals.
|
||||||
|
4. Review the exact file-level list, exclude sources/product data/releases and
|
||||||
|
active or unknown owners, then unlink only unchanged disposable files.
|
||||||
|
Journal removals and available space. No recursive age-based sweep.
|
||||||
|
5. Link the archive from the report and relevant Ops card. State explicitly
|
||||||
|
which original media is gone and requires rendering or running again.
|
||||||
|
|
||||||
|
The 2026-10-19 operation is recorded in
|
||||||
|
`outputs/SIMULATION_EXPERIMENT_ARCHIVE_2026-10-19/README.md`, its plan, SHA-256
|
||||||
|
inventory, archive verification and deletion receipt. Its helper is a one-shot
|
||||||
|
reviewed operation, not a scheduled garbage collector. Ad-hoc engineering
|
||||||
|
scripts have no universal disk quota: they must implement the declared capture
|
||||||
|
bound and perform closeout. Existing cache quotas and service-log rotation keep
|
||||||
|
their separate writer-owned enforcement. This amendment does not claim that a
|
||||||
|
filesystem-wide automatic limit or remote Worker cleanup has been installed.
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Run a local Python check with disposable job-owned caches.
|
||||||
|
|
||||||
|
Only this invocation's scratch is removed, after its process group has ended.
|
||||||
|
Existing caches, source, dependencies and results are outside this lifecycle.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
from contextlib import suppress
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from k1link.cache_budget import cache_publication
|
||||||
|
|
||||||
|
|
||||||
|
def stop_group(process):
|
||||||
|
try:
|
||||||
|
os.killpg(process.pid, signal.SIGTERM)
|
||||||
|
except ProcessLookupError:
|
||||||
|
return
|
||||||
|
deadline = time.monotonic() + 5
|
||||||
|
while time.monotonic() < deadline:
|
||||||
|
process.poll()
|
||||||
|
try:
|
||||||
|
os.killpg(process.pid, 0)
|
||||||
|
except ProcessLookupError:
|
||||||
|
return
|
||||||
|
time.sleep(0.05)
|
||||||
|
with suppress(ProcessLookupError):
|
||||||
|
os.killpg(process.pid, signal.SIGKILL)
|
||||||
|
process.wait(timeout=5)
|
||||||
|
|
||||||
|
|
||||||
|
def run(tool, arguments, *, root=None):
|
||||||
|
root = root or Path(__file__).resolve().parents[1]
|
||||||
|
parent = root / ".runtime/python-checks"
|
||||||
|
ancestor = parent
|
||||||
|
while not ancestor.exists():
|
||||||
|
ancestor = ancestor.parent
|
||||||
|
if ancestor.resolve() != ancestor:
|
||||||
|
raise ValueError("Check scratch ancestor must be canonical")
|
||||||
|
parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
||||||
|
if parent.resolve() != parent:
|
||||||
|
raise ValueError("Check scratch must be canonical")
|
||||||
|
with cache_publication(parent, 64 * 1024**2, limit=512 * 1024**2, max_files=50000):
|
||||||
|
if sum(p.is_dir() for p in parent.iterdir()) >= 4:
|
||||||
|
raise ValueError("Four active or unreconciled check directories; new check refused")
|
||||||
|
owned = tempfile.TemporaryDirectory(prefix=tool + "-", dir=parent)
|
||||||
|
with owned as scratch:
|
||||||
|
env = dict(
|
||||||
|
os.environ,
|
||||||
|
PYTHONDONTWRITEBYTECODE="1",
|
||||||
|
RUFF_NO_CACHE="true",
|
||||||
|
MYPY_CACHE_DIR=str(Path(scratch) / "mypy"),
|
||||||
|
TMPDIR=scratch,
|
||||||
|
)
|
||||||
|
command = [str(root / ".venv/bin/python"), "-m", tool]
|
||||||
|
if tool == "pytest":
|
||||||
|
command += ["-p", "no:cacheprovider", "--basetemp", str(Path(scratch) / "pytest")]
|
||||||
|
if tool == "ruff":
|
||||||
|
command += ["check", "--no-cache"]
|
||||||
|
process = subprocess.Popen(
|
||||||
|
[*command, *arguments], cwd=root, env=env, start_new_session=True
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
return process.wait()
|
||||||
|
finally:
|
||||||
|
stop_group(process)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("tool", choices=["pytest", "mypy", "ruff"])
|
||||||
|
parser.add_argument("arguments", nargs=argparse.REMAINDER)
|
||||||
|
args = parser.parse_args()
|
||||||
|
return run(args.tool, args.arguments)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main())
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
No remote command, NAS configuration, provider credential or cache is changed.
|
No remote command, NAS configuration, provider credential or cache is changed.
|
||||||
The user LaunchAgent reconnects independently of the Core process.
|
The user LaunchAgent reconnects independently of the Core process.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -19,6 +20,8 @@ import tempfile
|
|||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from k1link.launchd_logs import bounded_launchd_output
|
||||||
|
|
||||||
LABEL = "com.nodedc.mission-core.map-gateway-link"
|
LABEL = "com.nodedc.mission-core.map-gateway-link"
|
||||||
PORT = 18103
|
PORT = 18103
|
||||||
|
|
||||||
@@ -26,21 +29,47 @@ PORT = 18103
|
|||||||
def payload(target: str, runtime: Path) -> bytes:
|
def payload(target: str, runtime: Path) -> bytes:
|
||||||
if not re.fullmatch(r"[a-zA-Z0-9_][a-zA-Z0-9_.-]*@[a-zA-Z0-9][a-zA-Z0-9.-]*", target):
|
if not re.fullmatch(r"[a-zA-Z0-9_][a-zA-Z0-9_.-]*@[a-zA-Z0-9][a-zA-Z0-9.-]*", target):
|
||||||
raise ValueError("SSH target must be an explicit user@host")
|
raise ValueError("SSH target must be an explicit user@host")
|
||||||
return plistlib.dumps({
|
return plistlib.dumps(
|
||||||
"Label": LABEL,
|
bounded_launchd_output(
|
||||||
"ProgramArguments": [
|
{
|
||||||
"/usr/bin/ssh", "-N", "-T", "-o", "BatchMode=yes",
|
"Label": LABEL,
|
||||||
"-o", "StrictHostKeyChecking=yes", "-o", "ExitOnForwardFailure=yes",
|
"ProgramArguments": [
|
||||||
"-o", "ConnectTimeout=10", "-o", "ServerAliveInterval=15",
|
"/usr/bin/ssh",
|
||||||
"-o", "ServerAliveCountMax=3", "-o", "PermitLocalCommand=no",
|
"-N",
|
||||||
"-o", "ForwardAgent=no", "-o", "ForwardX11=no",
|
"-T",
|
||||||
"-L", f"127.0.0.1:{PORT}:127.0.0.1:{PORT}", target,
|
"-o",
|
||||||
],
|
"BatchMode=yes",
|
||||||
"RunAtLoad": True, "KeepAlive": True, "ThrottleInterval": 30,
|
"-o",
|
||||||
"ExitTimeOut": 10,
|
"StrictHostKeyChecking=yes",
|
||||||
"StandardOutPath": str(runtime / "stdout.log"),
|
"-o",
|
||||||
"StandardErrorPath": str(runtime / "stderr.log"),
|
"ExitOnForwardFailure=yes",
|
||||||
}, sort_keys=True)
|
"-o",
|
||||||
|
"ConnectTimeout=10",
|
||||||
|
"-o",
|
||||||
|
"ServerAliveInterval=15",
|
||||||
|
"-o",
|
||||||
|
"ServerAliveCountMax=3",
|
||||||
|
"-o",
|
||||||
|
"PermitLocalCommand=no",
|
||||||
|
"-o",
|
||||||
|
"ForwardAgent=no",
|
||||||
|
"-o",
|
||||||
|
"ForwardX11=no",
|
||||||
|
"-L",
|
||||||
|
f"127.0.0.1:{PORT}:127.0.0.1:{PORT}",
|
||||||
|
target,
|
||||||
|
],
|
||||||
|
"RunAtLoad": True,
|
||||||
|
"KeepAlive": True,
|
||||||
|
"ThrottleInterval": 30,
|
||||||
|
"ExitTimeOut": 10,
|
||||||
|
"StandardOutPath": str(runtime / "stdout.log"),
|
||||||
|
"StandardErrorPath": str(runtime / "stderr.log"),
|
||||||
|
},
|
||||||
|
Path(__file__).resolve().parents[1],
|
||||||
|
),
|
||||||
|
sort_keys=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def digest(value: bytes | None) -> str:
|
def digest(value: bytes | None) -> str:
|
||||||
@@ -50,9 +79,13 @@ def digest(value: bytes | None) -> str:
|
|||||||
def health() -> bool:
|
def health() -> bool:
|
||||||
connection = http.client.HTTPConnection("127.0.0.1", PORT, timeout=2)
|
connection = http.client.HTTPConnection("127.0.0.1", PORT, timeout=2)
|
||||||
try:
|
try:
|
||||||
connection.request("GET", "/healthz", headers={
|
connection.request(
|
||||||
"x-nodedc-user-id": "mission-core-loopback-operator",
|
"GET",
|
||||||
})
|
"/healthz",
|
||||||
|
headers={
|
||||||
|
"x-nodedc-user-id": "mission-core-loopback-operator",
|
||||||
|
},
|
||||||
|
)
|
||||||
response = connection.getresponse()
|
response = connection.getresponse()
|
||||||
raw = response.read(65537)
|
raw = response.read(65537)
|
||||||
if response.status != 200 or len(raw) > 65536:
|
if response.status != 200 or len(raw) > 65536:
|
||||||
@@ -66,18 +99,29 @@ def health() -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def loaded() -> bool:
|
def loaded() -> bool:
|
||||||
return subprocess.run(["launchctl", "print", f"gui/{os.getuid()}/{LABEL}"],
|
return (
|
||||||
capture_output=True, timeout=5, check=False).returncode == 0
|
subprocess.run(
|
||||||
|
["launchctl", "print", f"gui/{os.getuid()}/{LABEL}"],
|
||||||
|
capture_output=True,
|
||||||
|
timeout=5,
|
||||||
|
check=False,
|
||||||
|
).returncode
|
||||||
|
== 0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def unload() -> None:
|
def unload() -> None:
|
||||||
subprocess.run(["launchctl", "bootout", f"gui/{os.getuid()}/{LABEL}"],
|
subprocess.run(
|
||||||
capture_output=True, timeout=20, check=False)
|
["launchctl", "bootout", f"gui/{os.getuid()}/{LABEL}"],
|
||||||
|
capture_output=True,
|
||||||
|
timeout=20,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
deadline = time.monotonic() + 20
|
deadline = time.monotonic() + 20
|
||||||
while loaded():
|
while loaded():
|
||||||
if time.monotonic() > deadline:
|
if time.monotonic() > deadline:
|
||||||
raise RuntimeError("Map Gateway link did not finish unloading")
|
raise RuntimeError("Map Gateway link did not finish unloading")
|
||||||
time.sleep(.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
|
|
||||||
def write_atomic(path: Path, value: bytes) -> None:
|
def write_atomic(path: Path, value: bytes) -> None:
|
||||||
@@ -112,15 +156,22 @@ def main() -> None:
|
|||||||
if previous is not None and plistlib.loads(previous).get("Label") != LABEL:
|
if previous is not None and plistlib.loads(previous).get("Label") != LABEL:
|
||||||
raise ValueError("Refusing a foreign LaunchAgent")
|
raise ValueError("Refusing a foreign LaunchAgent")
|
||||||
desired = payload(args.target, runtime)
|
desired = payload(args.target, runtime)
|
||||||
plan = {"label": LABEL, "agent_path": str(agent), "target": args.target,
|
plan = {
|
||||||
"local_bind": f"127.0.0.1:{PORT}", "remote_bind": f"127.0.0.1:{PORT}",
|
"label": LABEL,
|
||||||
"current_sha256": digest(previous), "desired_sha256": digest(desired),
|
"agent_path": str(agent),
|
||||||
"remote_mutation": False}
|
"target": args.target,
|
||||||
|
"local_bind": f"127.0.0.1:{PORT}",
|
||||||
|
"remote_bind": f"127.0.0.1:{PORT}",
|
||||||
|
"current_sha256": digest(previous),
|
||||||
|
"desired_sha256": digest(desired),
|
||||||
|
"remote_mutation": False,
|
||||||
|
}
|
||||||
if args.action == "plan":
|
if args.action == "plan":
|
||||||
print(json.dumps(plan, indent=2))
|
print(json.dumps(plan, indent=2))
|
||||||
return
|
return
|
||||||
if (args.expected_current_sha256 != digest(previous)
|
if args.expected_current_sha256 != digest(previous) or args.expected_desired_sha256 != digest(
|
||||||
or args.expected_desired_sha256 != digest(desired)):
|
desired
|
||||||
|
):
|
||||||
raise ValueError("Map Gateway link plan changed before apply")
|
raise ValueError("Map Gateway link plan changed before apply")
|
||||||
was_loaded = loaded()
|
was_loaded = loaded()
|
||||||
if previous == desired and was_loaded and health():
|
if previous == desired and was_loaded and health():
|
||||||
@@ -137,20 +188,28 @@ def main() -> None:
|
|||||||
if was_loaded:
|
if was_loaded:
|
||||||
unload()
|
unload()
|
||||||
write_atomic(agent, desired)
|
write_atomic(agent, desired)
|
||||||
subprocess.run(["launchctl", "bootstrap", f"gui/{os.getuid()}", str(agent)],
|
subprocess.run(
|
||||||
capture_output=True, timeout=20, check=True)
|
["launchctl", "bootstrap", f"gui/{os.getuid()}", str(agent)],
|
||||||
|
capture_output=True,
|
||||||
|
timeout=20,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
deadline = time.monotonic() + 40
|
deadline = time.monotonic() + 40
|
||||||
while not health():
|
while not health():
|
||||||
if time.monotonic() > deadline:
|
if time.monotonic() > deadline:
|
||||||
raise RuntimeError("Map Gateway link did not pass health acceptance")
|
raise RuntimeError("Map Gateway link did not pass health acceptance")
|
||||||
time.sleep(.5)
|
time.sleep(0.5)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
unload()
|
unload()
|
||||||
if previous is not None:
|
if previous is not None:
|
||||||
write_atomic(agent, previous)
|
write_atomic(agent, previous)
|
||||||
if was_loaded:
|
if was_loaded:
|
||||||
subprocess.run(["launchctl", "bootstrap", f"gui/{os.getuid()}", str(agent)],
|
subprocess.run(
|
||||||
capture_output=True, timeout=20, check=True)
|
["launchctl", "bootstrap", f"gui/{os.getuid()}", str(agent)],
|
||||||
|
capture_output=True,
|
||||||
|
timeout=20,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
agent.unlink(missing_ok=True)
|
agent.unlink(missing_ok=True)
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Hash-gated bounded journals for existing, explicitly owned local LaunchAgents.
|
||||||
|
|
||||||
|
Only stdout/stderr ownership changes. Arguments, environment, schedules, SSH
|
||||||
|
trust and forwarding endpoints stay byte-for-byte equivalent after unwrapping.
|
||||||
|
Previous declarations and journals are preserved for rollback and diagnosis.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import plistlib
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from manage_mission_core_launch_agent import _reload_launch_agent, _wait_for_health, _write_atomic
|
||||||
|
from migrate_worker_tunnel_logs import reload_agent
|
||||||
|
|
||||||
|
from k1link.launchd_logs import bounded_launchd_output, service_command, service_log_path
|
||||||
|
|
||||||
|
LABELS = {
|
||||||
|
"core": "com.nodedc.mission-core.local",
|
||||||
|
"observatory": "com.nodedc.observatory-worker-tunnel.local",
|
||||||
|
"gaussian": "com.nodedc.gaussian-pipeline-tunnel.local",
|
||||||
|
"telemetry-startup": "com.nodedc.telemetry-startup.local",
|
||||||
|
"telemetry-tunnel": "com.nodedc.telemetry-tunnel.local",
|
||||||
|
"map": "com.nodedc.mission-core.map-gateway-link",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def digest(data):
|
||||||
|
return hashlib.sha256(data).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def plan(root, name, *, home=None):
|
||||||
|
home = home or Path.home()
|
||||||
|
root = root.resolve(strict=True)
|
||||||
|
label = LABELS[name]
|
||||||
|
agent = home / "Library/LaunchAgents" / f"{label}.plist"
|
||||||
|
if agent.is_symlink() or not agent.is_file():
|
||||||
|
raise ValueError("Missing or unsafe existing LaunchAgent")
|
||||||
|
before = agent.read_bytes()
|
||||||
|
document = plistlib.loads(before)
|
||||||
|
if document.get("Label") != label:
|
||||||
|
raise ValueError("Foreign LaunchAgent")
|
||||||
|
command = service_command(document)
|
||||||
|
if name == "core":
|
||||||
|
if document.get("WorkingDirectory") != str(root) or command[-2:] != ["k1link", "serve"]:
|
||||||
|
raise ValueError("Unexpected canonical Core declaration")
|
||||||
|
elif name == "telemetry-startup":
|
||||||
|
if str(root / "scripts/manage_telemetry_startup.py") not in command:
|
||||||
|
raise ValueError("Unexpected startup owner")
|
||||||
|
elif command[0] != "/usr/bin/ssh":
|
||||||
|
raise ValueError("Unexpected tunnel command")
|
||||||
|
desired = bounded_launchd_output(document, root)
|
||||||
|
assert service_command(desired) == command
|
||||||
|
for key in set(document) | set(desired):
|
||||||
|
if key not in {"ProgramArguments", "StandardOutPath", "StandardErrorPath"} and document.get(
|
||||||
|
key
|
||||||
|
) != desired.get(key):
|
||||||
|
raise ValueError("Service policy changed")
|
||||||
|
payload = plistlib.dumps(desired, sort_keys=True)
|
||||||
|
result = {
|
||||||
|
"schema": "missioncore.runtime-log-policy/v1",
|
||||||
|
"name": name,
|
||||||
|
"label": label,
|
||||||
|
"root": str(root),
|
||||||
|
"agent": str(agent),
|
||||||
|
"before_sha256": digest(before),
|
||||||
|
"desired_sha256": digest(payload),
|
||||||
|
"changed": before != payload,
|
||||||
|
"journal": str(service_log_path(desired)),
|
||||||
|
"max_bytes": 8388608,
|
||||||
|
"backups": 4,
|
||||||
|
"commands_and_environment_preserved": True,
|
||||||
|
}
|
||||||
|
return result, before, payload
|
||||||
|
|
||||||
|
|
||||||
|
def accept(name, label):
|
||||||
|
if name == "core":
|
||||||
|
if not _wait_for_health(45):
|
||||||
|
raise RuntimeError("Core health failed")
|
||||||
|
return {"operational": True}
|
||||||
|
target = f"gui/{os.getuid()}/{label}"
|
||||||
|
previous = None
|
||||||
|
stable = 0
|
||||||
|
for _ in range(15):
|
||||||
|
result = subprocess.run(
|
||||||
|
["launchctl", "print", target], capture_output=True, text=True, timeout=5
|
||||||
|
)
|
||||||
|
state = result.stdout
|
||||||
|
if name == "telemetry-startup" and "last exit code = 0" in state:
|
||||||
|
return {"last_exit_code": 0}
|
||||||
|
pid = next(
|
||||||
|
(line.strip() for line in state.splitlines() if line.strip().startswith("pid = ")), None
|
||||||
|
)
|
||||||
|
stable = stable + 1 if pid and pid == previous and "state = running" in state else 0
|
||||||
|
if stable >= 5:
|
||||||
|
return {"stable_process": pid}
|
||||||
|
previous = pid
|
||||||
|
time.sleep(1)
|
||||||
|
raise RuntimeError("LaunchAgent did not reach a stable accepted state")
|
||||||
|
|
||||||
|
|
||||||
|
def apply(expected):
|
||||||
|
current, before, payload = plan(Path(expected["root"]), expected["name"])
|
||||||
|
if current != expected:
|
||||||
|
raise ValueError("Stale log policy plan")
|
||||||
|
if not current["changed"]:
|
||||||
|
return {**current, "applied": False}
|
||||||
|
path = Path(current["agent"])
|
||||||
|
root = Path(current["root"])
|
||||||
|
backup = (
|
||||||
|
root
|
||||||
|
/ ".runtime/storage-maintenance/log-policy"
|
||||||
|
/ current["label"]
|
||||||
|
/ f"{current['before_sha256']}.plist"
|
||||||
|
)
|
||||||
|
if backup.exists() and backup.read_bytes() != before:
|
||||||
|
raise ValueError("Rollback identity collision")
|
||||||
|
if not backup.exists():
|
||||||
|
_write_atomic(backup, before)
|
||||||
|
_write_atomic(path, payload)
|
||||||
|
try:
|
||||||
|
if current["name"] == "core":
|
||||||
|
_reload_launch_agent(path)
|
||||||
|
else:
|
||||||
|
reload_agent(path, current["label"])
|
||||||
|
proof = accept(current["name"], current["label"])
|
||||||
|
except BaseException:
|
||||||
|
_write_atomic(path, before)
|
||||||
|
if current["name"] == "core":
|
||||||
|
_reload_launch_agent(path)
|
||||||
|
else:
|
||||||
|
reload_agent(path, current["label"])
|
||||||
|
accept(current["name"], current["label"])
|
||||||
|
raise
|
||||||
|
receipt = {
|
||||||
|
**current,
|
||||||
|
"applied": True,
|
||||||
|
"backup": str(backup),
|
||||||
|
"accepted": proof,
|
||||||
|
"utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||||
|
}
|
||||||
|
_write_atomic(backup.with_suffix(".receipt.json"), json.dumps(receipt, indent=2).encode())
|
||||||
|
return receipt
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
p = argparse.ArgumentParser(description=__doc__)
|
||||||
|
p.add_argument("action", choices=["plan", "apply"])
|
||||||
|
p.add_argument("name", choices=LABELS)
|
||||||
|
p.add_argument("--plan", type=Path)
|
||||||
|
a = p.parse_args()
|
||||||
|
if a.action == "plan":
|
||||||
|
value = plan(Path(__file__).resolve().parents[1], a.name)[0]
|
||||||
|
else:
|
||||||
|
if not a.plan:
|
||||||
|
p.error("apply requires --plan")
|
||||||
|
expected = json.loads(a.plan.read_text())
|
||||||
|
if expected["name"] != a.name:
|
||||||
|
p.error("plan owner does not match")
|
||||||
|
value = apply(expected)
|
||||||
|
print(json.dumps(value, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -21,7 +21,7 @@ from pathlib import Path
|
|||||||
from manage_mission_core_launch_agent import _wait_for_health, _write_atomic
|
from manage_mission_core_launch_agent import _wait_for_health, _write_atomic
|
||||||
from migrate_worker_tunnel_logs import reload_agent
|
from migrate_worker_tunnel_logs import reload_agent
|
||||||
|
|
||||||
from k1link.launchd_logs import launchd_log_path, prepare_launchd_log
|
from k1link.launchd_logs import bounded_launchd_output, launchd_log_path, prepare_launchd_log
|
||||||
from k1link.web.compute_contour_network import _replace_environment_value
|
from k1link.web.compute_contour_network import _replace_environment_value
|
||||||
|
|
||||||
STARTUP = "com.nodedc.telemetry-startup.local"
|
STARTUP = "com.nodedc.telemetry-startup.local"
|
||||||
@@ -194,6 +194,8 @@ def plan(stack: Path, ssh_alias: str, repository: Path, agents: Path):
|
|||||||
StandardOutPath="/dev/null",
|
StandardOutPath="/dev/null",
|
||||||
StandardErrorPath=str(launchd_log_path("telemetry-tunnel.log")),
|
StandardErrorPath=str(launchd_log_path("telemetry-tunnel.log")),
|
||||||
)
|
)
|
||||||
|
startup = bounded_launchd_output(startup, repository)
|
||||||
|
tunnel = bounded_launchd_output(tunnel, repository)
|
||||||
core_path = agents / (CORE + ".plist")
|
core_path = agents / (CORE + ".plist")
|
||||||
core = plistlib.loads(private_file(core_path))
|
core = plistlib.loads(private_file(core_path))
|
||||||
if core.get("Label") != CORE or core.get("WorkingDirectory") != str(repository):
|
if core.get("Label") != CORE or core.get("WorkingDirectory") != str(repository):
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ from pathlib import Path
|
|||||||
|
|
||||||
from manage_mission_core_launch_agent import _write_atomic
|
from manage_mission_core_launch_agent import _write_atomic
|
||||||
|
|
||||||
from k1link.launchd_logs import launchd_log_path, prepare_launchd_log
|
from k1link.launchd_logs import (
|
||||||
|
bounded_launchd_output,
|
||||||
|
launchd_log_path,
|
||||||
|
prepare_launchd_log,
|
||||||
|
service_command,
|
||||||
|
)
|
||||||
|
|
||||||
LABELS = {
|
LABELS = {
|
||||||
"observatory": "com.nodedc.observatory-worker-tunnel.local",
|
"observatory": "com.nodedc.observatory-worker-tunnel.local",
|
||||||
@@ -48,10 +53,11 @@ def main():
|
|||||||
raise ValueError("LaunchAgent cannot be a symlink")
|
raise ValueError("LaunchAgent cannot be a symlink")
|
||||||
previous = agent.read_bytes()
|
previous = agent.read_bytes()
|
||||||
desired = plistlib.loads(previous)
|
desired = plistlib.loads(previous)
|
||||||
if desired["Label"] != label or desired["ProgramArguments"][0] != "/usr/bin/ssh":
|
if desired["Label"] != label or service_command(desired)[0] != "/usr/bin/ssh":
|
||||||
raise ValueError("Unexpected tunnel declaration")
|
raise ValueError("Unexpected tunnel declaration")
|
||||||
log = launchd_log_path(a.tunnel + "-worker-tunnel.log")
|
log = launchd_log_path(a.tunnel + "-worker-tunnel.log")
|
||||||
desired.update(StandardOutPath=str(log), StandardErrorPath=str(log))
|
desired.update(StandardOutPath=str(log), StandardErrorPath=str(log))
|
||||||
|
desired = bounded_launchd_output(desired, Path(__file__).resolve().parents[1])
|
||||||
payload = plistlib.dumps(desired, sort_keys=True)
|
payload = plistlib.dumps(desired, sort_keys=True)
|
||||||
plan = dict(
|
plan = dict(
|
||||||
label=label,
|
label=label,
|
||||||
|
|||||||
@@ -0,0 +1,616 @@
|
|||||||
|
"""Operator-side lifecycle for intermediate Linux inputs, never runtime/evidence GC.
|
||||||
|
|
||||||
|
Only four exact archive families in two build directories are eligible. Unknown
|
||||||
|
legacy files stay protected. Producers publish atomically with a persistent
|
||||||
|
active hold; completing a build explicitly releases that hold. No TTL can guess
|
||||||
|
that a remote build, disconnected transfer or qualification has finished.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import fcntl
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import stat
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
import zipfile
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
SCHEMA = "missioncore.build-retention/v1"
|
||||||
|
POLICY = "two-closed-inputs-per-line-v1"
|
||||||
|
KEEP = 2
|
||||||
|
MAX_ACTIVE_PER_FAMILY = 8
|
||||||
|
RESERVE = 2 * 1024**3
|
||||||
|
SOFT_BUDGET = 6 * 1024**3
|
||||||
|
ROOTS = {
|
||||||
|
"apps/node-agent/build": ("mission-core-node-linux-build-",),
|
||||||
|
"plugins/insta360-x4/build": (
|
||||||
|
"mission-core-x4-build-",
|
||||||
|
"mission-core-x4-package-build-",
|
||||||
|
"mission-core-x4-owner-build-",
|
||||||
|
),
|
||||||
|
}
|
||||||
|
PATTERN = re.compile(r"(.+)-([a-f0-9]{24})\.pyz\Z")
|
||||||
|
|
||||||
|
|
||||||
|
class RetentionError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def _canonical(value):
|
||||||
|
return json.dumps(value, sort_keys=True, ensure_ascii=True, separators=(",", ":")).encode()
|
||||||
|
|
||||||
|
|
||||||
|
def _stamp(s):
|
||||||
|
return [s.st_dev, s.st_ino, s.st_size, s.st_mtime_ns, s.st_ctime_ns, s.st_nlink]
|
||||||
|
|
||||||
|
|
||||||
|
def _plain(path, *, directory=False):
|
||||||
|
s = path.lstat()
|
||||||
|
if not (stat.S_ISDIR(s.st_mode) if directory else stat.S_ISREG(s.st_mode)):
|
||||||
|
raise RetentionError(f"Not a plain {'directory' if directory else 'file'}: {path}")
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
def _atomic(path, value):
|
||||||
|
if path.exists() or path.is_symlink():
|
||||||
|
_plain(path)
|
||||||
|
temporary = path.with_name("." + path.name + "." + uuid.uuid4().hex + ".tmp")
|
||||||
|
try:
|
||||||
|
with temporary.open("xb") as stream:
|
||||||
|
os.chmod(temporary, 0o600)
|
||||||
|
stream.write(_canonical(value) + b"\n")
|
||||||
|
stream.flush()
|
||||||
|
os.fsync(stream.fileno())
|
||||||
|
os.replace(temporary, path)
|
||||||
|
fd = os.open(path.parent, os.O_RDONLY)
|
||||||
|
try:
|
||||||
|
os.fsync(fd)
|
||||||
|
finally:
|
||||||
|
os.close(fd)
|
||||||
|
finally:
|
||||||
|
temporary.unlink(missing_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
class BuildRetention:
|
||||||
|
def __init__(self, root):
|
||||||
|
supplied = Path(root).absolute()
|
||||||
|
if supplied.is_symlink():
|
||||||
|
raise RetentionError("Repository root is a symlink")
|
||||||
|
self.root = supplied.resolve(strict=True)
|
||||||
|
self.control = self.root / ".runtime/build-retention"
|
||||||
|
self.state_path = self.control / "state.json"
|
||||||
|
|
||||||
|
def _directory(self, relative, *, create=False):
|
||||||
|
current = self.root
|
||||||
|
for part in Path(relative).parts:
|
||||||
|
if part in (".", "..", "/"):
|
||||||
|
raise RetentionError("Unsafe directory")
|
||||||
|
current /= part
|
||||||
|
if create and not current.exists() and not current.is_symlink():
|
||||||
|
current.mkdir(mode=0o700, exist_ok=True)
|
||||||
|
_plain(current, directory=True)
|
||||||
|
return current
|
||||||
|
|
||||||
|
def _path(self, relative):
|
||||||
|
p = Path(relative)
|
||||||
|
if p.is_absolute() or str(p.parent) not in ROOTS:
|
||||||
|
raise RetentionError("Path is outside managed build-input families")
|
||||||
|
match = PATTERN.fullmatch(p.name)
|
||||||
|
if not match or match[1] + "-" not in ROOTS[str(p.parent)]:
|
||||||
|
raise RetentionError("Only intermediate build inputs are managed")
|
||||||
|
return self._directory(p.parent) / p.name
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def _lock(self, *, write=False):
|
||||||
|
# A fresh read-only plan does not create even a lock or state directory.
|
||||||
|
if not self.control.exists() and not self.control.is_symlink() and not write:
|
||||||
|
yield
|
||||||
|
return
|
||||||
|
self._directory(".runtime/build-retention", create=write)
|
||||||
|
lock = self.control / "lock"
|
||||||
|
if not write and not lock.exists():
|
||||||
|
raise RetentionError("Incomplete retention control directory")
|
||||||
|
fd = os.open(
|
||||||
|
lock, (os.O_RDWR | os.O_CREAT if write else os.O_RDONLY) | os.O_NOFOLLOW, 0o600
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
if not stat.S_ISREG(os.fstat(fd).st_mode):
|
||||||
|
raise RetentionError("Invalid retention lock")
|
||||||
|
fcntl.flock(fd, fcntl.LOCK_EX if write else fcntl.LOCK_SH)
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
os.close(fd)
|
||||||
|
|
||||||
|
def _state(self):
|
||||||
|
if not self.state_path.exists() and not self.state_path.is_symlink():
|
||||||
|
return {"schema": SCHEMA, "revision": 0, "inputs": {}}
|
||||||
|
_plain(self.state_path)
|
||||||
|
state = json.loads(self.state_path.read_text())
|
||||||
|
if state.get("schema") != SCHEMA or not isinstance(state.get("inputs"), dict):
|
||||||
|
raise RetentionError("Unknown retention registry schema")
|
||||||
|
return state
|
||||||
|
|
||||||
|
def _save(self, state):
|
||||||
|
state["revision"] += 1
|
||||||
|
_atomic(self.state_path, state)
|
||||||
|
|
||||||
|
def _read(self, relative, *, physical=None):
|
||||||
|
path = physical or self._path(relative)
|
||||||
|
before = _plain(path)
|
||||||
|
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)
|
||||||
|
with os.fdopen(fd, "rb") as stream:
|
||||||
|
if _stamp(before) != _stamp(os.fstat(stream.fileno())):
|
||||||
|
raise RetentionError("Input changed while opening")
|
||||||
|
digest = hashlib.file_digest(stream, "sha256").hexdigest()
|
||||||
|
stream.seek(0)
|
||||||
|
with zipfile.ZipFile(stream) as archive:
|
||||||
|
name = (
|
||||||
|
"manifest.json"
|
||||||
|
if "/mission-core-x4-owner-build-" in relative
|
||||||
|
else "source.json"
|
||||||
|
)
|
||||||
|
if len([x for x in archive.namelist() if x == name]) != 1:
|
||||||
|
raise RetentionError("Missing or duplicate build manifest")
|
||||||
|
if archive.getinfo(name).file_size > 16 * 1024**2:
|
||||||
|
raise RetentionError("Build manifest is too large")
|
||||||
|
raw = archive.read(name)
|
||||||
|
manifest = json.loads(raw)
|
||||||
|
if _stamp(before) != _stamp(os.fstat(stream.fileno())):
|
||||||
|
raise RetentionError("Input changed while reading")
|
||||||
|
if _stamp(before) != _stamp(_plain(path)):
|
||||||
|
raise RetentionError("Input path changed while reading")
|
||||||
|
match = PATTERN.fullmatch(Path(relative).name)
|
||||||
|
if not match or hashlib.sha256(raw).hexdigest()[:24] != match[2]:
|
||||||
|
raise RetentionError("Build manifest identity differs from filename")
|
||||||
|
prefix = match[1]
|
||||||
|
schema = manifest.get("schema")
|
||||||
|
if (
|
||||||
|
prefix == "mission-core-node-linux-build"
|
||||||
|
and schema == "missioncore.node.linux-build-source/v1"
|
||||||
|
):
|
||||||
|
profile = manifest.get("profile")
|
||||||
|
if profile not in {"node-only", "node-core"}:
|
||||||
|
raise RetentionError("Unknown Node build profile")
|
||||||
|
line = "node/" + profile
|
||||||
|
elif (
|
||||||
|
prefix in {"mission-core-x4-build", "mission-core-x4-package-build"}
|
||||||
|
and schema == "missioncore.insta360.build-source/v1"
|
||||||
|
):
|
||||||
|
kind = manifest.get("kind", "native")
|
||||||
|
if kind != ("native" if prefix == "mission-core-x4-build" else "package"):
|
||||||
|
raise RetentionError("X4 kind differs from filename")
|
||||||
|
line = "x4/" + kind
|
||||||
|
elif (
|
||||||
|
prefix == "mission-core-x4-owner-build"
|
||||||
|
and schema == "missioncore.insta360.owner-wrapper-build/v1"
|
||||||
|
):
|
||||||
|
line = "x4/owner"
|
||||||
|
else:
|
||||||
|
raise RetentionError("Unknown build manifest schema/family")
|
||||||
|
base = manifest.get("base")
|
||||||
|
if base is not None:
|
||||||
|
if not isinstance(base, dict) or set(base) != {"name", "sha256"}:
|
||||||
|
raise RetentionError("Invalid base reference")
|
||||||
|
if Path(base["name"]).name != base["name"] or not re.fullmatch(
|
||||||
|
r"[a-f0-9]{64}", base["sha256"]
|
||||||
|
):
|
||||||
|
raise RetentionError("Unsafe base reference")
|
||||||
|
base = {"path": str(Path(relative).parent / base["name"]), "sha256": base["sha256"]}
|
||||||
|
self._path(base["path"])
|
||||||
|
return {
|
||||||
|
"path": relative,
|
||||||
|
"line": line,
|
||||||
|
"sha256": digest,
|
||||||
|
"bytes": before.st_size,
|
||||||
|
"stamp": _stamp(before),
|
||||||
|
"base": base,
|
||||||
|
}
|
||||||
|
|
||||||
|
def _inventory(self):
|
||||||
|
rows, errors = {}, []
|
||||||
|
for directory, prefixes in ROOTS.items():
|
||||||
|
if not (self.root / directory).exists() and not (self.root / directory).is_symlink():
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
root = self._directory(directory)
|
||||||
|
for p in sorted(root.iterdir()):
|
||||||
|
# Recognizable but malformed archives block deletion, rather than disappearing.
|
||||||
|
if p.suffix != ".pyz" or not p.name.startswith(prefixes):
|
||||||
|
continue
|
||||||
|
relative = str(p.relative_to(self.root))
|
||||||
|
try:
|
||||||
|
self._path(relative)
|
||||||
|
rows[relative] = self._read(relative)
|
||||||
|
except (
|
||||||
|
RetentionError,
|
||||||
|
OSError,
|
||||||
|
ValueError,
|
||||||
|
KeyError,
|
||||||
|
TypeError,
|
||||||
|
zipfile.BadZipFile,
|
||||||
|
) as exc:
|
||||||
|
errors.append(f"{relative}: {exc}")
|
||||||
|
except (RetentionError, OSError) as exc:
|
||||||
|
errors.append(f"{directory}: {exc}")
|
||||||
|
return rows, errors
|
||||||
|
|
||||||
|
def _plan(self):
|
||||||
|
state = self._state()
|
||||||
|
rows, errors = self._inventory()
|
||||||
|
reasons = {name: [] for name in rows}
|
||||||
|
eligible = {}
|
||||||
|
for name, record in state["inputs"].items():
|
||||||
|
if not record.get("deleted") and name not in rows:
|
||||||
|
errors.append(f"Registered input missing: {name}")
|
||||||
|
for name, row in rows.items():
|
||||||
|
record = state["inputs"].get(name)
|
||||||
|
if not record:
|
||||||
|
reasons[name].append("legacy-unreviewed")
|
||||||
|
else:
|
||||||
|
if record.get("deleted") or any(
|
||||||
|
record.get(k) != row[k] for k in ("sha256", "bytes", "line", "base")
|
||||||
|
):
|
||||||
|
errors.append(f"Registered identity changed: {name}")
|
||||||
|
if record["state"] == "active":
|
||||||
|
reasons[name].append("active-build:" + record["owner"])
|
||||||
|
elif record["state"] != "closed":
|
||||||
|
errors.append(f"Invalid lifecycle state: {name}")
|
||||||
|
for pin, reason in sorted(record["pins"].items()):
|
||||||
|
reasons[name].append(f"pin:{pin}:{reason}")
|
||||||
|
if record["state"] == "closed" and not record["pins"]:
|
||||||
|
eligible.setdefault(row["line"], []).append(name)
|
||||||
|
base = row["base"]
|
||||||
|
if base and (
|
||||||
|
base["path"] not in rows or rows[base["path"]]["sha256"] != base["sha256"]
|
||||||
|
):
|
||||||
|
errors.append(f"Missing or changed base: {name}")
|
||||||
|
for names in eligible.values():
|
||||||
|
names.sort(key=lambda n: (state["inputs"][n]["published_ns"], n), reverse=True)
|
||||||
|
for name in names[:KEEP]:
|
||||||
|
reasons[name].append("latest-two-completed-in-line")
|
||||||
|
# Protect the entire dependency closure, including legacy/active/pinned roots.
|
||||||
|
visiting, visited = set(), set()
|
||||||
|
|
||||||
|
def protect(name):
|
||||||
|
if name in visiting:
|
||||||
|
errors.append(f"Cyclic base graph: {name}")
|
||||||
|
return
|
||||||
|
if name in visited:
|
||||||
|
return
|
||||||
|
visiting.add(name)
|
||||||
|
base = rows[name]["base"]
|
||||||
|
if base and base["path"] in rows:
|
||||||
|
reasons[base["path"]].append("base-of:" + name)
|
||||||
|
protect(base["path"])
|
||||||
|
visiting.remove(name)
|
||||||
|
visited.add(name)
|
||||||
|
|
||||||
|
for name in sorted(rows):
|
||||||
|
if reasons[name]:
|
||||||
|
protect(name)
|
||||||
|
|
||||||
|
# Validate even candidate-only dependency components before any unlink.
|
||||||
|
def cycle(name, chain):
|
||||||
|
if name in chain:
|
||||||
|
errors.append(f"Cyclic base graph: {name}")
|
||||||
|
return
|
||||||
|
base = rows[name]["base"]
|
||||||
|
if base and base["path"] in rows:
|
||||||
|
cycle(base["path"], chain | {name})
|
||||||
|
|
||||||
|
for name in rows:
|
||||||
|
cycle(name, set())
|
||||||
|
decisions = [
|
||||||
|
dict(
|
||||||
|
row,
|
||||||
|
action="retain" if reasons[name] or errors else "delete",
|
||||||
|
reasons=sorted(set(reasons[name]))
|
||||||
|
or (["blocked-by-inventory-error"] if errors else ["superseded-completed-input"]),
|
||||||
|
)
|
||||||
|
for name, row in sorted(rows.items())
|
||||||
|
]
|
||||||
|
total = sum(x["bytes"] for x in decisions)
|
||||||
|
result = {
|
||||||
|
"schema": "missioncore.build-retention-plan/v1",
|
||||||
|
"policy": POLICY,
|
||||||
|
"root": str(self.root),
|
||||||
|
"registry_sha256": hashlib.sha256(_canonical(state)).hexdigest(),
|
||||||
|
"inputs": decisions,
|
||||||
|
"errors": sorted(set(errors)),
|
||||||
|
"total_logical_bytes": total,
|
||||||
|
"soft_budget_bytes": SOFT_BUDGET,
|
||||||
|
"over_soft_budget": total > SOFT_BUDGET,
|
||||||
|
"candidate_bytes_upper_bound": sum(
|
||||||
|
x["bytes"] for x in decisions if x["action"] == "delete"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
result["plan_id"] = hashlib.sha256(_canonical(result)).hexdigest()
|
||||||
|
return result
|
||||||
|
|
||||||
|
def plan(self):
|
||||||
|
with self._lock():
|
||||||
|
return self._plan()
|
||||||
|
|
||||||
|
def _record(self, state, row, *, active, reason, pin=None):
|
||||||
|
name = row["path"]
|
||||||
|
previous = state["inputs"].get(name)
|
||||||
|
if previous and not previous.get("deleted"):
|
||||||
|
raise RetentionError("Input already registered; use finish/pin/unpin")
|
||||||
|
record = {k: row[k] for k in ("sha256", "bytes", "line", "base")}
|
||||||
|
record.update(
|
||||||
|
state="active" if active else "closed",
|
||||||
|
published_ns=time.time_ns() if active else row["stamp"][3],
|
||||||
|
owner=uuid.uuid4().hex,
|
||||||
|
reason=reason,
|
||||||
|
pins={pin: reason} if pin else {},
|
||||||
|
)
|
||||||
|
state["inputs"][name] = record
|
||||||
|
self._save(state)
|
||||||
|
return record["owner"]
|
||||||
|
|
||||||
|
def adopt(self, relative, *, pin, reason):
|
||||||
|
"""Legacy enrollment always pins; it never silently makes a file disposable."""
|
||||||
|
if not pin or not reason.strip():
|
||||||
|
raise RetentionError("A legacy hold and a reason are required")
|
||||||
|
with self._lock(write=True):
|
||||||
|
return self._record(
|
||||||
|
self._state(), self._read(relative), active=False, pin=pin, reason=reason
|
||||||
|
)
|
||||||
|
|
||||||
|
def pin(self, relative, *, pin, reason, remove=False):
|
||||||
|
if not pin or not reason.strip():
|
||||||
|
raise RetentionError("A pin identity and reason are required")
|
||||||
|
with self._lock(write=True):
|
||||||
|
state = self._state()
|
||||||
|
record = state["inputs"][relative]
|
||||||
|
row = self._read(relative)
|
||||||
|
if record.get("deleted") or row["sha256"] != record["sha256"]:
|
||||||
|
raise RetentionError("Registered input changed")
|
||||||
|
if remove:
|
||||||
|
if pin not in record["pins"]:
|
||||||
|
raise RetentionError("Unknown pin")
|
||||||
|
del record["pins"][pin]
|
||||||
|
else:
|
||||||
|
record["pins"][pin] = reason
|
||||||
|
record["reason"] = reason
|
||||||
|
self._save(state)
|
||||||
|
|
||||||
|
def finish(self, relative, *, owner, outcome, reason):
|
||||||
|
if (
|
||||||
|
outcome not in {"intermediate", "failed", "cancelled", "qualified", "rollback"}
|
||||||
|
or not reason.strip()
|
||||||
|
):
|
||||||
|
raise RetentionError("Explicit terminal outcome and reason required")
|
||||||
|
with self._lock(write=True):
|
||||||
|
state = self._state()
|
||||||
|
record = state["inputs"][relative]
|
||||||
|
row = self._read(relative)
|
||||||
|
if record.get("deleted") or record["sha256"] != row["sha256"]:
|
||||||
|
raise RetentionError("Registered input changed")
|
||||||
|
if record["state"] != "active" or record["owner"] != owner:
|
||||||
|
raise RetentionError("Build owner changed or build is already closed")
|
||||||
|
record.update(state="closed", outcome=outcome, reason=reason)
|
||||||
|
if outcome in {"qualified", "rollback"}:
|
||||||
|
record["pins"][outcome] = reason
|
||||||
|
self._save(state)
|
||||||
|
# A finish only releases a hold. Destructive work uses a reviewable plan.
|
||||||
|
return self.plan()
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def publish(self, output, *, required_bytes=0):
|
||||||
|
"""Atomic publication + persistent hold; failed staging removes only its own temp."""
|
||||||
|
output = Path(output).absolute()
|
||||||
|
relative = str(output.relative_to(self.root))
|
||||||
|
with self._lock(write=True):
|
||||||
|
path = self._path(relative)
|
||||||
|
if path.exists() or path.is_symlink():
|
||||||
|
raise FileExistsError(path)
|
||||||
|
state = self._state()
|
||||||
|
# Family prefix gives a conservative count before the archive exists.
|
||||||
|
prefix = PATTERN.fullmatch(path.name)[1]
|
||||||
|
active = sum(
|
||||||
|
1
|
||||||
|
for n, r in state["inputs"].items()
|
||||||
|
if not r.get("deleted")
|
||||||
|
and r["state"] == "active"
|
||||||
|
and Path(n).name.startswith(prefix + "-")
|
||||||
|
)
|
||||||
|
if active >= MAX_ACTIVE_PER_FAMILY:
|
||||||
|
raise RetentionError(
|
||||||
|
"Eight unfinished inputs in this family; finish or cancel their owners first"
|
||||||
|
)
|
||||||
|
if required_bytes < 0 or shutil.disk_usage(path.parent).free < RESERVE + required_bytes:
|
||||||
|
raise RetentionError("Insufficient build space; preserve 2 GiB after staging")
|
||||||
|
temporary = path.with_name(".retention-" + uuid.uuid4().hex + ".part")
|
||||||
|
try:
|
||||||
|
yield temporary
|
||||||
|
row = self._read(relative, physical=temporary)
|
||||||
|
seen, base = {relative}, row["base"]
|
||||||
|
while base:
|
||||||
|
if base["path"] in seen:
|
||||||
|
raise RetentionError("Cyclic publication base graph")
|
||||||
|
seen.add(base["path"])
|
||||||
|
dependency = self._read(base["path"])
|
||||||
|
if dependency["sha256"] != base["sha256"]:
|
||||||
|
raise RetentionError("Publication base changed")
|
||||||
|
base = dependency["base"]
|
||||||
|
os.chmod(temporary, 0o600)
|
||||||
|
with temporary.open("rb") as stream:
|
||||||
|
os.fsync(stream.fileno())
|
||||||
|
# No replace: a non-cooperating publisher must not lose its file.
|
||||||
|
os.link(temporary, path, follow_symlinks=False)
|
||||||
|
temporary.unlink()
|
||||||
|
# A crash before registry commit leaves an unknown, protected file.
|
||||||
|
self._record(state, row, active=True, reason="Awaiting explicit build outcome")
|
||||||
|
finally:
|
||||||
|
temporary.unlink(missing_ok=True)
|
||||||
|
|
||||||
|
def apply(self, expected):
|
||||||
|
with self._lock(write=True):
|
||||||
|
current = self._plan()
|
||||||
|
if expected != current:
|
||||||
|
raise RetentionError("Stale or edited plan; generate a fresh plan")
|
||||||
|
if current["errors"]:
|
||||||
|
raise RetentionError("Inventory errors block all deletions")
|
||||||
|
state = self._state()
|
||||||
|
candidates = [x for x in current["inputs"] if x["action"] == "delete"]
|
||||||
|
|
||||||
|
# Delete dependants before bases: interruption must leave a usable graph.
|
||||||
|
def depth(row):
|
||||||
|
count, base = 0, row["base"]
|
||||||
|
by_path = {x["path"]: x for x in current["inputs"]}
|
||||||
|
while base:
|
||||||
|
count += 1
|
||||||
|
base = by_path[base["path"]]["base"]
|
||||||
|
return count
|
||||||
|
|
||||||
|
candidates.sort(key=lambda row: (-depth(row), row["path"]))
|
||||||
|
receipt_dir = self._directory(".runtime/build-retention/receipts", create=True)
|
||||||
|
receipt_path = receipt_dir / (uuid.uuid4().hex + ".json")
|
||||||
|
receipt = {
|
||||||
|
"schema": "missioncore.build-retention-receipt/v1",
|
||||||
|
"plan_id": current["plan_id"],
|
||||||
|
"started_ns": time.time_ns(),
|
||||||
|
"status": "applying",
|
||||||
|
"plan": current,
|
||||||
|
"removed": [],
|
||||||
|
"free_before": shutil.disk_usage(self.root).free,
|
||||||
|
}
|
||||||
|
_atomic(receipt_path, receipt)
|
||||||
|
try:
|
||||||
|
# All bytes were verified by _plan under the shared publication lock.
|
||||||
|
# Metadata is checked again immediately before each unlink.
|
||||||
|
for row in candidates:
|
||||||
|
path = self._path(row["path"])
|
||||||
|
if _stamp(_plain(path)) != row["stamp"]:
|
||||||
|
raise RetentionError("Input changed before unlink")
|
||||||
|
receipt["next"] = row["path"]
|
||||||
|
_atomic(receipt_path, receipt)
|
||||||
|
path.unlink()
|
||||||
|
receipt["removed"].append(
|
||||||
|
{"path": row["path"], "sha256": row["sha256"], "bytes": row["bytes"]}
|
||||||
|
)
|
||||||
|
state["inputs"][row["path"]]["deleted"] = True
|
||||||
|
self._save(state)
|
||||||
|
_atomic(receipt_path, receipt)
|
||||||
|
receipt["status"] = "complete"
|
||||||
|
except BaseException as exc:
|
||||||
|
receipt.update(status="interrupted", error=str(exc))
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
receipt.update(
|
||||||
|
finished_ns=time.time_ns(), free_after=shutil.disk_usage(self.root).free
|
||||||
|
)
|
||||||
|
_atomic(receipt_path, receipt)
|
||||||
|
return dict(receipt, receipt=str(receipt_path))
|
||||||
|
|
||||||
|
def recover(self, receipt_name):
|
||||||
|
"""Reconcile only journaled unlinks after a process/storage interruption."""
|
||||||
|
if not re.fullmatch(r"[a-f0-9]{32}\.json", receipt_name):
|
||||||
|
raise RetentionError("Invalid receipt name")
|
||||||
|
with self._lock(write=True):
|
||||||
|
path = self._directory(".runtime/build-retention/receipts") / receipt_name
|
||||||
|
_plain(path)
|
||||||
|
receipt = json.loads(path.read_text())
|
||||||
|
if receipt["schema"] != "missioncore.build-retention-receipt/v1" or receipt[
|
||||||
|
"status"
|
||||||
|
] not in {"applying", "interrupted"}:
|
||||||
|
raise RetentionError("Receipt does not need recovery")
|
||||||
|
state = self._state()
|
||||||
|
planned = {x["path"]: x for x in receipt["plan"]["inputs"] if x["action"] == "delete"}
|
||||||
|
journaled = {x["path"] for x in receipt["removed"]} | {receipt.get("next")}
|
||||||
|
recovered = []
|
||||||
|
for name in sorted(n for n in journaled if n is not None):
|
||||||
|
row = planned[name]
|
||||||
|
record = state["inputs"][name]
|
||||||
|
if (
|
||||||
|
record["sha256"] != row["sha256"]
|
||||||
|
or record["state"] != "closed"
|
||||||
|
or record["pins"]
|
||||||
|
):
|
||||||
|
raise RetentionError("Recovery input was changed or protected")
|
||||||
|
candidate = self._path(name)
|
||||||
|
if candidate.exists() or candidate.is_symlink():
|
||||||
|
if self._read(name)["sha256"] != row["sha256"]:
|
||||||
|
raise RetentionError("Recovery input identity changed")
|
||||||
|
elif not record.get("deleted"):
|
||||||
|
record["deleted"] = True
|
||||||
|
recovered.append(name)
|
||||||
|
self._save(state)
|
||||||
|
receipt.update(
|
||||||
|
status="reconciled", reconciled_ns=time.time_ns(), recovered_missing=recovered
|
||||||
|
)
|
||||||
|
_atomic(path, receipt)
|
||||||
|
return {"recovered_missing": recovered, "receipt": str(path), "deleted_now": 0}
|
||||||
|
|
||||||
|
|
||||||
|
def publish_input(output, *, required_bytes=0):
|
||||||
|
"""Producer hook; this module is operator tooling, not an onboard dependency."""
|
||||||
|
return BuildRetention(Path(__file__).resolve().parents[2]).publish(
|
||||||
|
output, required_bytes=required_bytes
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def input_hold(output):
|
||||||
|
"""Small lifecycle handle included in the producer's existing JSON response."""
|
||||||
|
store = BuildRetention(Path(__file__).resolve().parents[2])
|
||||||
|
relative = str(Path(output).absolute().relative_to(store.root))
|
||||||
|
with store._lock():
|
||||||
|
record = store._state()["inputs"][relative]
|
||||||
|
return {"path": relative, "owner": record["owner"], "state": record["state"]}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[2])
|
||||||
|
commands = parser.add_subparsers(dest="command", required=True)
|
||||||
|
commands.add_parser("plan")
|
||||||
|
apply = commands.add_parser("apply")
|
||||||
|
apply.add_argument("--plan", type=Path, required=True)
|
||||||
|
recover = commands.add_parser("recover")
|
||||||
|
recover.add_argument("receipt", help="Basename of an interrupted receipt")
|
||||||
|
for name in ("adopt", "pin", "unpin", "finish"):
|
||||||
|
child = commands.add_parser(name)
|
||||||
|
child.add_argument("path", help="Repository-relative intermediate input path")
|
||||||
|
child.add_argument("--reason", required=True)
|
||||||
|
if name == "finish":
|
||||||
|
child.add_argument(
|
||||||
|
"--owner", required=True, help="Owner from plan/registry active-build reason"
|
||||||
|
)
|
||||||
|
child.add_argument(
|
||||||
|
"--outcome",
|
||||||
|
choices=("intermediate", "failed", "cancelled", "qualified", "rollback"),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
child.add_argument("--pin", required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
store = BuildRetention(args.root)
|
||||||
|
if args.command == "plan":
|
||||||
|
result = store.plan()
|
||||||
|
elif args.command == "apply":
|
||||||
|
result = store.apply(json.loads(args.plan.read_text()))
|
||||||
|
elif args.command == "recover":
|
||||||
|
result = store.recover(args.receipt)
|
||||||
|
elif args.command == "adopt":
|
||||||
|
store.adopt(args.path, pin=args.pin, reason=args.reason)
|
||||||
|
result = store.plan()
|
||||||
|
elif args.command == "finish":
|
||||||
|
result = store.finish(args.path, owner=args.owner, outcome=args.outcome, reason=args.reason)
|
||||||
|
else:
|
||||||
|
store.pin(args.path, pin=args.pin, reason=args.reason, remove=args.command == "unpin")
|
||||||
|
result = store.plan()
|
||||||
|
print(json.dumps(result, indent=2, sort_keys=True))
|
||||||
|
if result.get("errors"):
|
||||||
|
raise SystemExit(2)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
"""Publication budgets for local derived caches; never evicts retained data.
|
||||||
|
|
||||||
|
Existing generations, unknown files and in-flight files all count. Budget
|
||||||
|
exhaustion refuses a new disk copy; callers that can work without it may skip it.
|
||||||
|
This is a publication quota, not a filesystem quota for renderer scratch output.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import stat
|
||||||
|
import threading
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
GiB = 1024**3
|
||||||
|
MiB = 1024**2
|
||||||
|
LIMITS = {
|
||||||
|
"camera-frame-cache": 256 * MiB,
|
||||||
|
"lidar-read-cache": 16 * MiB,
|
||||||
|
"camera-media-index": 64 * MiB,
|
||||||
|
"perception-overlays": GiB,
|
||||||
|
"calibrated-fusion-overlays": GiB,
|
||||||
|
"integrated-perception-overlays": 4 * GiB,
|
||||||
|
"laboratory-rerun-overlays": 4 * GiB,
|
||||||
|
"observatory-portable-replay-cache": 4 * GiB,
|
||||||
|
"editor-cache": 4 * GiB,
|
||||||
|
}
|
||||||
|
FREE_RESERVE = 2 * GiB
|
||||||
|
_LOCK = threading.RLock()
|
||||||
|
_LOCK_NAME = ".publication-budget.lock"
|
||||||
|
|
||||||
|
|
||||||
|
class CacheCapacityError(ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def usage(root: Path) -> tuple[int, int]:
|
||||||
|
total = count = 0
|
||||||
|
for base, directories, files in os.walk(root, followlinks=False):
|
||||||
|
for name in directories + files:
|
||||||
|
p = Path(base) / name
|
||||||
|
s = p.lstat()
|
||||||
|
if stat.S_ISDIR(s.st_mode):
|
||||||
|
continue
|
||||||
|
if not stat.S_ISREG(s.st_mode):
|
||||||
|
raise CacheCapacityError("Cache contains an unsafe path; preserved")
|
||||||
|
if p == root / _LOCK_NAME:
|
||||||
|
continue
|
||||||
|
total += s.st_size
|
||||||
|
count += 1
|
||||||
|
if count > 100000:
|
||||||
|
raise CacheCapacityError("Cache inventory exceeds its file budget; preserved")
|
||||||
|
return total, count
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def cache_publication(
|
||||||
|
root: Path,
|
||||||
|
additional_bytes: int,
|
||||||
|
*,
|
||||||
|
kind=None,
|
||||||
|
limit=None,
|
||||||
|
reserve=FREE_RESERVE,
|
||||||
|
max_files=10000,
|
||||||
|
error_type=CacheCapacityError,
|
||||||
|
):
|
||||||
|
"""Lock admission through publication. Count temporary bytes already on disk.
|
||||||
|
|
||||||
|
additional_bytes includes only bytes not yet in this root; a file renamed
|
||||||
|
within it contributes zero additional bytes. Callers include sidecar overhead.
|
||||||
|
Unknown legacy contents stay in place even if already above the new limit.
|
||||||
|
"""
|
||||||
|
root = root.expanduser().absolute()
|
||||||
|
maximum = LIMITS[kind or root.name] if limit is None else limit
|
||||||
|
if type(additional_bytes) is not int or additional_bytes < 0 or maximum < 1:
|
||||||
|
raise ValueError("Invalid cache publication budget")
|
||||||
|
ancestor = root
|
||||||
|
while not ancestor.exists():
|
||||||
|
ancestor = ancestor.parent
|
||||||
|
if ancestor.resolve() != ancestor:
|
||||||
|
raise CacheCapacityError("Cache ancestor is not canonical")
|
||||||
|
root.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||||
|
if root.resolve() != root or not stat.S_ISDIR(root.lstat().st_mode):
|
||||||
|
raise CacheCapacityError("Cache root is not canonical")
|
||||||
|
with _LOCK:
|
||||||
|
fd = os.open(root / _LOCK_NAME, os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
|
||||||
|
try:
|
||||||
|
s = os.fstat(fd)
|
||||||
|
if not stat.S_ISREG(s.st_mode) or s.st_nlink != 1 or s.st_uid != os.getuid():
|
||||||
|
raise CacheCapacityError("Unsafe cache publication lock")
|
||||||
|
# Operator cache publication is Mac/Linux owned, never the remote Worker.
|
||||||
|
import fcntl
|
||||||
|
|
||||||
|
fcntl.flock(fd, fcntl.LOCK_EX)
|
||||||
|
current, count = usage(root)
|
||||||
|
if current + additional_bytes > maximum or count >= max_files:
|
||||||
|
raise CacheCapacityError("Достигнут лимит кэша. Сохранённые данные не удалены.")
|
||||||
|
if shutil.disk_usage(root).free < additional_bytes + reserve:
|
||||||
|
raise CacheCapacityError("Недостаточно свободного места для новой копии кэша.")
|
||||||
|
yield
|
||||||
|
except CacheCapacityError as exc:
|
||||||
|
if error_type is CacheCapacityError:
|
||||||
|
raise
|
||||||
|
raise error_type(str(exc)) from exc
|
||||||
|
finally:
|
||||||
|
os.close(fd)
|
||||||
|
|
||||||
|
|
||||||
|
def require_cache_room(root: Path, additional_bytes=0, **kwargs):
|
||||||
|
with cache_publication(root, additional_bytes, **kwargs):
|
||||||
|
pass
|
||||||
@@ -18,6 +18,7 @@ import rerun as rr
|
|||||||
from rerun.components import FillMode
|
from rerun.components import FillMode
|
||||||
|
|
||||||
from k1link.artifacts import write_json_atomic
|
from k1link.artifacts import write_json_atomic
|
||||||
|
from k1link.cache_budget import cache_publication, require_cache_room
|
||||||
from k1link.sessions import SessionIntegrityError
|
from k1link.sessions import SessionIntegrityError
|
||||||
|
|
||||||
from .jobs import CameraComputeJob, validate_camera_compute_job
|
from .jobs import CameraComputeJob, validate_camera_compute_job
|
||||||
@@ -104,31 +105,43 @@ class RecordedCalibratedFusionStore:
|
|||||||
cached = _read_cache(output, sidecar, fusion, recording_id)
|
cached = _read_cache(output, sidecar, fusion, recording_id)
|
||||||
if cached is not None:
|
if cached is not None:
|
||||||
return cached
|
return cached
|
||||||
|
require_cache_room(
|
||||||
|
self.cache_root,
|
||||||
|
65536,
|
||||||
|
kind="calibrated-fusion-overlays",
|
||||||
|
error_type=RecordedPerceptionOverlayError,
|
||||||
|
)
|
||||||
payload = _render_fusion(
|
payload = _render_fusion(
|
||||||
fusion,
|
fusion,
|
||||||
application_id=application_id,
|
application_id=application_id,
|
||||||
recording_id=recording_id,
|
recording_id=recording_id,
|
||||||
)
|
)
|
||||||
temporary = output.with_name(f".{output.name}.{os.getpid()}.tmp")
|
with cache_publication(
|
||||||
try:
|
self.cache_root,
|
||||||
with temporary.open("xb") as stream:
|
len(payload) + 65536,
|
||||||
stream.write(payload)
|
kind="calibrated-fusion-overlays",
|
||||||
stream.flush()
|
error_type=RecordedPerceptionOverlayError,
|
||||||
os.fsync(stream.fileno())
|
):
|
||||||
os.chmod(temporary, 0o600)
|
temporary = output.with_name(f".{output.name}.{os.getpid()}.tmp")
|
||||||
os.replace(temporary, output)
|
try:
|
||||||
write_json_atomic(
|
with temporary.open("xb") as stream:
|
||||||
sidecar,
|
stream.write(payload)
|
||||||
{
|
stream.flush()
|
||||||
"schema_version": "missioncore.calibrated-fusion-overlay-cache/v1",
|
os.fsync(stream.fileno())
|
||||||
"fusion_id": fusion.fusion_id,
|
os.chmod(temporary, 0o600)
|
||||||
"recording_id": recording_id,
|
os.replace(temporary, output)
|
||||||
"byte_length": len(payload),
|
write_json_atomic(
|
||||||
"sha256": hashlib.sha256(payload).hexdigest(),
|
sidecar,
|
||||||
},
|
{
|
||||||
)
|
"schema_version": "missioncore.calibrated-fusion-overlay-cache/v1",
|
||||||
finally:
|
"fusion_id": fusion.fusion_id,
|
||||||
temporary.unlink(missing_ok=True)
|
"recording_id": recording_id,
|
||||||
|
"byte_length": len(payload),
|
||||||
|
"sha256": hashlib.sha256(payload).hexdigest(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
temporary.unlink(missing_ok=True)
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
def _latest(self, session_id: str) -> RecordedCalibratedFusion | None:
|
def _latest(self, session_id: str) -> RecordedCalibratedFusion | None:
|
||||||
@@ -540,9 +553,8 @@ def _read_labels(path: Path) -> list[str]:
|
|||||||
value = json.loads(path.read_text(encoding="utf-8"))
|
value = json.loads(path.read_text(encoding="utf-8"))
|
||||||
except (OSError, UnicodeDecodeError, json.JSONDecodeError) as exc:
|
except (OSError, UnicodeDecodeError, json.JSONDecodeError) as exc:
|
||||||
raise SessionIntegrityError("calibrated fusion labels are unavailable") from exc
|
raise SessionIntegrityError("calibrated fusion labels are unavailable") from exc
|
||||||
if (
|
if not isinstance(value, list) or any(
|
||||||
not isinstance(value, list)
|
not isinstance(item, str) or not 1 <= len(item) <= 256 for item in value
|
||||||
or any(not isinstance(item, str) or not 1 <= len(item) <= 256 for item in value)
|
|
||||||
):
|
):
|
||||||
raise SessionIntegrityError("calibrated fusion labels are invalid")
|
raise SessionIntegrityError("calibrated fusion labels are invalid")
|
||||||
return value
|
return value
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user