Skip to content

V45 Gate 13: Deterministic BTD Quote Conservation#216

Merged
geraldarthurdavis merged 1 commit into
version/v45from
v45/gate-13-btd-scalar-volume-quote-conservation
May 31, 2026
Merged

V45 Gate 13: Deterministic BTD Quote Conservation#216
geraldarthurdavis merged 1 commit into
version/v45from
v45/gate-13-btd-scalar-volume-quote-conservation

Conversation

@geraldarthurdavis

Copy link
Copy Markdown
Contributor

Summary

  • add package-owned BTD scalar-volume quote-conservation projection for Need-relative fixed-point measurement rows, deterministic quote audit, BTD range projection, rights receipt posture, and source-to-shares readback
  • cover final-BTD blockers for reviewed Need, selected Fit set, synthesized Need-Fit AssetPack, deterministic weights, proof/dedupe roots, settlement-bound quote, and BTD range assignment
  • wire package exports, V45 parity readback, and the Gate 13 closure checker

Verification

  • pnpm --filter @bitcode/pipeline-asset-pack exec jest --config jest.config.cjs src/tests/btd-scalar-volume-quote.test.ts --runInBand
  • pnpm --filter @bitcode/pipeline-asset-pack typecheck
  • pnpm run check:v45-gate13
  • pnpm run check:v45-gate12
  • node scripts/check-bitcode-spec-family.mjs --version V45 --mode draft --current-target V44
  • node scripts/check-bitcode-canon-posture-drift.mjs --active-canon V44 --draft-target V45
  • pnpm --filter @bitcode/pipeline-asset-pack exec jest --config jest.config.cjs src/tests/read-need.test.ts src/tests/asset-pack-settlement-rights-delivery.test.ts --runInBand
  • pnpm --filter @bitcode/btd exec jest --config jest.config.cjs tests/source-to-shares.test.ts --runInBand
  • git diff --check
  • pnpm --filter @bitcode/pipeline-asset-pack exec jest --config jest.config.cjs --runInBand

Add a package-owned BTD scalar-volume quote-conservation bridge that computes Need-relative fixed-point measurement rows, deterministic quote audits, BTD range projection, and source-to-shares conservation readback from selected Fits.

Cover final-BTD blocker requirements, one-Fit and many-Fit source-to-shares conservation, export the primitive, and wire the Gate 13 closure checker plus parity readback.
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
engi-uapi Ready Ready Preview, Comment May 31, 2026 11:47pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64436300d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

BigInt(weightBps) *
BigInt(input.admittedFitQualityBps);
const denominator = BPS_SCALE_BIGINT * BPS_SCALE_BIGINT;
const scalarMicroBtd = numerator / denominator;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve fractional row remainders before quote comparison

When a valid quote is produced by buildShareToFeePreview, it rounds the total weighted admitted volume after summing the measurement vector, but this path floors each row to micro-BTD before summing. For fractional measurement volumes whose per-row micro remainders add up, e.g. two 50% rows with volume: 1.000001 and quality 1, the existing quote builder can emit 1,000,001 sats at 1,000,000 sats/volume while this audit computes 1,000,000 and adds quote_conservation_failed, so valid settlement-bound quotes are rejected.

Useful? React with 👍 / 👎.

}

function selectedFitIds(selectedFits: readonly BtdScalarVolumeSelectedFitInput[]): string[] {
return uniqueStrings(selectedFits.map((fit) => firstString(fit.depositId, fit.assetId)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect duplicate selected fits before deduping IDs

For an input with duplicate selected Fit IDs, this helper collapses duplicates before the blocker check later compares selectedIds.length to new Set(selectedIds).size, making that duplicate check unreachable. The projection then reaches buildSourceToSharesProof, which throws Duplicate source-to-shares fit deposit instead of returning a fail-closed final_btd_scalar_volume_blocked projection with selected_fit_set_required, so malformed Fit-set data can crash callers that expect blocker readback.

Useful? React with 👍 / 👎.

@geraldarthurdavis
geraldarthurdavis merged commit 6ea0619 into version/v45 May 31, 2026
28 checks passed
@geraldarthurdavis
geraldarthurdavis deleted the v45/gate-13-btd-scalar-volume-quote-conservation branch May 31, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant