feat(calibration): attestation-evidence envelope schema, validator, and report-data binder - #8549
feat(calibration): attestation-evidence envelope schema, validator, and report-data binder#8549michiot05 wants to merge 1 commit into
Conversation
…nd report-data binder Closes JSONbored#8541. Adds the pure typed evidence seam packages/loopover-engine/src/calibration/attestation-envelope.ts: the AttestationEnvelope schema, buildAttestationReportData (lowercase-hex sha256 of corpusChecksum:headSha:baseSha), and validateAttestationEnvelope (never-throwing structural validation of every field/constraint, accumulating all failing field paths). Structural only -- no crypto verification, no IO, no src changes, no new deps. Barrel export + node:test (engine gate) + root vitest mirror (codecov coverage).
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
Caution 🛑 LoopOver review result - fixes requiredReview updated: 2026-07-24 20:14:28 UTC
Review summary Nits — 1 non-blocking
CI checks failing
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Summary
packages/loopover-engine/src/calibration/attestation-envelope.ts— a schema type, a deterministic report-data binder, and a never-throwing structural validator — so a later runner can attach "this run executed inside an attested TEE" evidence to a persisted backtest run without inventing an ad-hoc shape. Pure structural code only: no cryptographic verification, no IO, no new dependency, nosrc/**change, no change to any existing calibration module.type AttestationEnvelope(+ theAttestationVerificationdiscriminated union) with every field constraint the issue specifies:schemaVersion: 1literal,teeTechnology"sev-snp" | "tdx", non-emptyruntimeClass≤128, 32–128-hexmeasurement, exactly-64-hexreportData, non-empty base64attestationReport≤65536, and averificationunion ofunverified/verified/failed.buildAttestationReportData({corpusChecksum, headSha, baseSha})→ lowercase-hex sha256 of${corpusChecksum}:${headSha}:${baseSha}vianode:crypto, mirroringbacktest-split.ts's existing sha256 usage (no new dependency).validateAttestationEnvelope(value: unknown)→{valid,envelope}|{valid,errors}— structural validation of every field/constraint; never throws for any input (null, primitives, arrays, objects with extra keys — extra keys are rejected, naming the key);errorsaccumulates every failing field path in one pass. ISO-8601verifiedAtis checked by shape (regex) and real-calendar validity (Date.parse), so a well-shaped but impossible datetime is still rejected.packages/loopover-engine/src/index.ts(export * from "./calibration/attestation-envelope.js";), matching the existing calibration export lines.Tests
Two suites, per the epic's "engine blind-spot rule" the issue cites (#8438):
packages/loopover-engine/test/attestation-envelope.test.ts— thenode:testsuite gating the engine workspace's ownnpm run test(all 719 engine tests pass).test/unit/attestation-envelope-engine.test.ts— the root vitest mirror importing the enginesrcpath directly, which providescodecov/patchcoverage (the engine's node:test output isn't harvested to Codecov). Exercises both arms of every rule — 63/64/65-char reportData, 31/32/128/129 measurement boundaries, hex-vs-non-hex-vs-non-string, empty/too-long/non-base64 attestationReport, each union variant valid + each with a missing/invalid member (incl. a regex-valid-but-unparseable datetime), valid-then-extra-key, and the never-throws guarantee on non-object inputs — plusbuildAttestationReportDatapinned against a precomputed vector. 100% of new lines and branches, verified locally via lcov (34/34 lines, 0 missed branches).Scope
CONTRIBUTING.md; nosite//CNAME.Closes #8541).Validation
git diff --checknpm run typechecknpm run test:coveragelocally (100% patch coverage on the new file, verified via lcov)@loopover/enginebuild + its 719-testnode:testsuitenpm run test:engine-parity,npm run engine-parity:drift-check,npm run docs:drift-checkIf any required check was skipped, explain why:
test:cisteps cannot be affected by it. Engine was rebuilt (a stale dist otherwise breaks whole-repo typecheck), typecheck is clean, and engine build/tests + engine-parity + drift checks + the unsharded coverage run all pass.Safety
attestationReportblob is treated as opaque.UI Evidence
Not applicable — a pure calibration-engine module with no visible UI, frontend, docs, or extension change.
Notes
src/**change.validateAttestationEnvelopecollects all field errors rather than short-circuiting, so a caller sees every problem at once.