diff --git a/.bitcode/v44-economic-domain-model.json b/.bitcode/v44-economic-domain-model.json new file mode 100644 index 00000000..2844a717 --- /dev/null +++ b/.bitcode/v44-economic-domain-model.json @@ -0,0 +1,906 @@ +{ + "artifactId": "v44-economic-domain-model", + "schemaId": "bitcode.v44.economicDomainModel.v1", + "version": "V44", + "currentTarget": "V43", + "sourceSafetyVerdict": "source-safe-economic-domain-model-metadata", + "generatedAt": "deterministic", + "artifactRoot": "v44-economic-domain-model:ef6092ede081c31a2dd1fa62", + "passed": true, + "economicObjectIds": [ + "EnterprisePackPortfolio", + "PackPortfolioPosition", + "PackMarketSignal", + "ReadDemandSignal", + "UnfitNeedSignal", + "DepositSupplyOpportunity", + "ReadingBudgetPolicy", + "AssetPackQuotePolicy", + "ProcurementApprovalReceipt", + "DepositorEarningStatement", + "ContributorCompensationStatement", + "PackEconomicStatement", + "OrganizationPackPolicy", + "PackGovernanceDecision", + "ScaledNetworkRehearsalReceipt", + "PortfolioRepairCase" + ], + "receiptTaxonomyIds": [ + "portfolio-position", + "market-signal", + "quote-state", + "settlement-state", + "compensation-statement", + "governance-decision", + "repair-case", + "budget-policy", + "supply-opportunity", + "network-rehearsal" + ], + "valueLabelIds": [ + "estimate", + "quote", + "observed-payment", + "final-settlement", + "contributor-allocation", + "delivery", + "repair-state" + ], + "sourceSafeFieldIds": [ + "objectId", + "receiptTaxonomyIds", + "valueLabelIds", + "state", + "scope", + "organizationId", + "repositoryRef", + "assetPackId", + "needId", + "quoteId", + "settlementId", + "compensationId", + "governanceDecisionId", + "repairCaseId", + "measurementRoot", + "policyRoot", + "proofRoot", + "telemetryRoot" + ], + "forbiddenPayloadIds": [ + "protected-source-payloads", + "unpaid-assetpack-source", + "source-snippets", + "raw-prompts", + "interpolated-prompts", + "raw-provider-responses", + "credentials", + "wallet-private-material", + "private-settlement-payloads", + "value-bearing-mainnet-admission" + ], + "domainRows": [ + { + "objectId": "EnterprisePackPortfolio", + "receiptTaxonomyIds": [ + "portfolio-position", + "market-signal", + "governance-decision" + ], + "valueLabelIds": [ + "estimate", + "quote", + "final-settlement", + "delivery" + ], + "contract": "EnterprisePackPortfolio aggregates source-safe Pack positions, Pack activity, demand/supply signals, and policy receipts for one organization.", + "stateIds": [ + "empty", + "active", + "requires-repair", + "restricted-by-policy" + ], + "sourceSafeFields": [ + "organizationId", + "positionIds", + "marketSignalIds", + "policyRoot", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "protectedSource", + "unpaidAssetPackSource", + "walletPrivateMaterial" + ], + "downstreamConsumers": [ + "/packs", + "organization-policy", + "scaled-network-rehearsal" + ], + "rowRoot": "v44-economic-domain-row:e05f5b1b5336ebf925e92f07", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "PackPortfolioPosition", + "receiptTaxonomyIds": [ + "portfolio-position", + "settlement-state", + "delivery" + ], + "valueLabelIds": [ + "estimate", + "quote", + "observed-payment", + "final-settlement", + "delivery" + ], + "contract": "PackPortfolioPosition records one AssetPack economic position with source-safe ownership, quote, settlement, delivery, and repair readback.", + "stateIds": [ + "previewable", + "quoted", + "settled", + "delivered", + "repair-required" + ], + "sourceSafeFields": [ + "assetPackId", + "quoteId", + "settlementId", + "deliveryState", + "measurementRoot" + ], + "privateFieldsNeverSerialized": [ + "protectedSource", + "privateSettlementPayload" + ], + "downstreamConsumers": [ + "/packs", + "/read", + "delivery-boundary" + ], + "rowRoot": "v44-economic-domain-row:9a163415d0e34d550013eea7", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "PackMarketSignal", + "receiptTaxonomyIds": [ + "market-signal" + ], + "valueLabelIds": [ + "estimate" + ], + "contract": "PackMarketSignal summarizes source-safe demand, supply, compensation, and settlement pressure for AssetPack discovery and portfolio search.", + "stateIds": [ + "observed", + "stale", + "suppressed-by-policy" + ], + "sourceSafeFields": [ + "signalId", + "assetPackId", + "needId", + "measurementRoot", + "telemetryRoot" + ], + "privateFieldsNeverSerialized": [ + "rawPrompt", + "rawProviderResponse", + "protectedSource" + ], + "downstreamConsumers": [ + "/packs", + "/deposit", + "supply-opportunity" + ], + "rowRoot": "v44-economic-domain-row:c6f4bdef581ad8ccd156616a", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "ReadDemandSignal", + "receiptTaxonomyIds": [ + "market-signal" + ], + "valueLabelIds": [ + "estimate" + ], + "contract": "ReadDemandSignal records source-safe Need demand for Matching Fits without exposing buyer private context or unpaid source.", + "stateIds": [ + "requested", + "reviewed-need", + "fit-found", + "unfit" + ], + "sourceSafeFields": [ + "needId", + "repositoryRef", + "measurementRoot", + "policyRoot", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "privateReadContext", + "rawPrompt", + "interpolatedPrompt" + ], + "downstreamConsumers": [ + "/read", + "/packs", + "/deposit" + ], + "rowRoot": "v44-economic-domain-row:81327be94c1f774f2d81ba72", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "UnfitNeedSignal", + "receiptTaxonomyIds": [ + "market-signal", + "supply-opportunity", + "repair-case" + ], + "valueLabelIds": [ + "estimate", + "repair-state" + ], + "contract": "UnfitNeedSignal preserves source-safe evidence that a reviewed Need lacked enough eligible Fits and can drive deposit opportunity discovery.", + "stateIds": [ + "unfit", + "reopened", + "supplied-later", + "closed" + ], + "sourceSafeFields": [ + "needId", + "reasonCode", + "measurementRoot", + "repairCaseId", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "privateReadContext", + "protectedSource" + ], + "downstreamConsumers": [ + "/deposit", + "/packs", + "repair-workflows" + ], + "rowRoot": "v44-economic-domain-row:8b714ba56d5843adea9c4ab0", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "DepositSupplyOpportunity", + "receiptTaxonomyIds": [ + "supply-opportunity", + "market-signal" + ], + "valueLabelIds": [ + "estimate", + "contributor-allocation" + ], + "contract": "DepositSupplyOpportunity estimates source-safe likelihood, criticality, ROI, and downstream compensation posture for proposed AssetPack deposits.", + "stateIds": [ + "candidate", + "eligible", + "blocked-critical-source", + "admitted", + "rejected" + ], + "sourceSafeFields": [ + "opportunityId", + "repositoryRef", + "demandSignalIds", + "measurementRoot", + "policyRoot" + ], + "privateFieldsNeverSerialized": [ + "protectedSource", + "sourceSnippet", + "credentials" + ], + "downstreamConsumers": [ + "/deposit", + "/packs", + "depository-admission" + ], + "rowRoot": "v44-economic-domain-row:ab9cfe319a0a44d25e7ad848", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "ReadingBudgetPolicy", + "receiptTaxonomyIds": [ + "budget-policy", + "governance-decision" + ], + "valueLabelIds": [ + "estimate", + "quote" + ], + "contract": "ReadingBudgetPolicy defines source-safe spend envelopes, approval thresholds, quote expiry posture, and fail-closed admission for Reading.", + "stateIds": [ + "draft", + "active", + "approval-required", + "exceeded", + "expired" + ], + "sourceSafeFields": [ + "policyId", + "organizationId", + "budgetEnvelopeRoot", + "approvalThresholdRoot" + ], + "privateFieldsNeverSerialized": [ + "walletPrivateMaterial", + "privateSettlementPayload" + ], + "downstreamConsumers": [ + "/read", + "quote-policy", + "wallet-authority" + ], + "rowRoot": "v44-economic-domain-row:4bcdee45d976bb4bbb08c02f", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "AssetPackQuotePolicy", + "receiptTaxonomyIds": [ + "quote-state", + "budget-policy", + "settlement-state" + ], + "valueLabelIds": [ + "estimate", + "quote", + "observed-payment", + "final-settlement" + ], + "contract": "AssetPackQuotePolicy binds deterministic source-to-shares measurement, quote state, expiry, payment observation, and final settlement boundaries.", + "stateIds": [ + "estimated", + "quoted", + "expired", + "payment-observed", + "settled", + "repaired" + ], + "sourceSafeFields": [ + "quoteId", + "assetPackId", + "shareCalculationRoot", + "expiry", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "unpaidAssetPackSource", + "privateSettlementPayload", + "walletPrivateMaterial" + ], + "downstreamConsumers": [ + "/read", + "/packs", + "settlement-boundary" + ], + "rowRoot": "v44-economic-domain-row:12102bc0f46bf6905b74a823", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "ProcurementApprovalReceipt", + "receiptTaxonomyIds": [ + "governance-decision", + "budget-policy", + "quote-state" + ], + "valueLabelIds": [ + "quote" + ], + "contract": "ProcurementApprovalReceipt records source-safe buyer approval, reviewer authority, budget posture, and quote admission before settlement.", + "stateIds": [ + "pending", + "approved", + "denied", + "expired", + "superseded" + ], + "sourceSafeFields": [ + "approvalId", + "quoteId", + "reviewerRole", + "policyRoot", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "credentials", + "walletPrivateMaterial", + "privateSettlementPayload" + ], + "downstreamConsumers": [ + "/read", + "organization-policy", + "settlement-boundary" + ], + "rowRoot": "v44-economic-domain-row:bfdaa52443c9093f3b37ea1d", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "DepositorEarningStatement", + "receiptTaxonomyIds": [ + "compensation-statement", + "settlement-state" + ], + "valueLabelIds": [ + "estimate", + "observed-payment", + "final-settlement", + "contributor-allocation" + ], + "contract": "DepositorEarningStatement summarizes source-safe estimated, observed, settled, and allocated value for a depositor across AssetPack use.", + "stateIds": [ + "estimated", + "payment-observed", + "settled", + "allocated", + "repair-required" + ], + "sourceSafeFields": [ + "statementId", + "assetPackId", + "depositorAccountRef", + "allocationRoot", + "settlementId" + ], + "privateFieldsNeverSerialized": [ + "walletPrivateMaterial", + "privateSettlementPayload" + ], + "downstreamConsumers": [ + "/packs", + "/deposit", + "compensation-ledger" + ], + "rowRoot": "v44-economic-domain-row:b9940282ad8b6cbcffa66a9e", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "ContributorCompensationStatement", + "receiptTaxonomyIds": [ + "compensation-statement" + ], + "valueLabelIds": [ + "contributor-allocation", + "observed-payment", + "final-settlement" + ], + "contract": "ContributorCompensationStatement preserves source-to-shares allocation conservation and contributor readback without exposing private wallet material.", + "stateIds": [ + "pending-allocation", + "allocated", + "payable", + "paid", + "repair-required" + ], + "sourceSafeFields": [ + "compensationId", + "contributorRef", + "allocationRoot", + "settlementId", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "walletPrivateMaterial", + "privateSettlementPayload", + "protectedSource" + ], + "downstreamConsumers": [ + "/packs", + "ledger-reconciliation", + "repair-workflows" + ], + "rowRoot": "v44-economic-domain-row:884a56453b012f52c63a3e39", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "PackEconomicStatement", + "receiptTaxonomyIds": [ + "portfolio-position", + "quote-state", + "settlement-state", + "compensation-statement" + ], + "valueLabelIds": [ + "estimate", + "quote", + "observed-payment", + "final-settlement", + "contributor-allocation", + "delivery" + ], + "contract": "PackEconomicStatement composes source-safe position, quote, payment, settlement, delivery, and compensation state for one AssetPack.", + "stateIds": [ + "estimated", + "quoted", + "settled", + "delivered", + "reconciled", + "repair-required" + ], + "sourceSafeFields": [ + "assetPackId", + "quoteId", + "settlementId", + "deliveryState", + "allocationRoot" + ], + "privateFieldsNeverSerialized": [ + "unpaidAssetPackSource", + "privateSettlementPayload", + "walletPrivateMaterial" + ], + "downstreamConsumers": [ + "/packs", + "/read", + "/deposit", + "promotion-rehearsal" + ], + "rowRoot": "v44-economic-domain-row:3fc15dd3ce0dfc2f40856418", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "OrganizationPackPolicy", + "receiptTaxonomyIds": [ + "budget-policy", + "governance-decision" + ], + "valueLabelIds": [ + "estimate", + "quote", + "repair-state" + ], + "contract": "OrganizationPackPolicy defines source-safe role, spending, depositing, source-criticality, and wallet authority controls across routes.", + "stateIds": [ + "draft", + "active", + "blocked", + "override-required", + "repair-required" + ], + "sourceSafeFields": [ + "policyId", + "organizationId", + "roleRoot", + "limitRoot", + "walletAuthorityRoot" + ], + "privateFieldsNeverSerialized": [ + "credentials", + "walletPrivateMaterial", + "protectedSource" + ], + "downstreamConsumers": [ + "/packs", + "/read", + "/deposit", + "wallet-authority" + ], + "rowRoot": "v44-economic-domain-row:b618ca51eaff6e1744420399", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "PackGovernanceDecision", + "receiptTaxonomyIds": [ + "governance-decision" + ], + "valueLabelIds": [ + "quote", + "delivery", + "repair-state" + ], + "contract": "PackGovernanceDecision records source-safe allow, deny, require-review, repair, and override outcomes for economic operation.", + "stateIds": [ + "allowed", + "denied", + "review-required", + "override-required", + "repair-required" + ], + "sourceSafeFields": [ + "governanceDecisionId", + "policyId", + "decisionKind", + "proofRoot", + "telemetryRoot" + ], + "privateFieldsNeverSerialized": [ + "credentials", + "walletPrivateMaterial", + "privateSettlementPayload" + ], + "downstreamConsumers": [ + "/packs", + "/read", + "/deposit", + "governance-audit" + ], + "rowRoot": "v44-economic-domain-row:3257d0a3c21379e143c8e2be", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "ScaledNetworkRehearsalReceipt", + "receiptTaxonomyIds": [ + "network-rehearsal", + "settlement-state", + "repair-case" + ], + "valueLabelIds": [ + "estimate", + "quote", + "observed-payment", + "final-settlement", + "contributor-allocation", + "delivery", + "repair-state" + ], + "contract": "ScaledNetworkRehearsalReceipt proves many deposits, Reads, Fits, quotes, settlements, contributors, deliveries, and repairs on safe lanes.", + "stateIds": [ + "local-passed", + "staging-testnet-passed", + "blocked-mainnet", + "repair-required" + ], + "sourceSafeFields": [ + "rehearsalId", + "laneId", + "scenarioRoot", + "telemetryRoot", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "credentials", + "walletPrivateMaterial", + "privateSettlementPayload", + "protectedSource" + ], + "downstreamConsumers": [ + "promotion-readiness", + "operator-audit" + ], + "rowRoot": "v44-economic-domain-row:24e85a6c8e0d59fa9cd9cc2b", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + }, + { + "objectId": "PortfolioRepairCase", + "receiptTaxonomyIds": [ + "repair-case", + "portfolio-position", + "settlement-state", + "compensation-statement" + ], + "valueLabelIds": [ + "repair-state", + "estimate", + "quote", + "final-settlement", + "delivery" + ], + "contract": "PortfolioRepairCase records source-safe economic discrepancy, stale state, reconciliation action, and closure evidence.", + "stateIds": [ + "opened", + "triaged", + "repairing", + "closed", + "escalated" + ], + "sourceSafeFields": [ + "repairCaseId", + "objectId", + "reasonCode", + "actionRoot", + "proofRoot" + ], + "privateFieldsNeverSerialized": [ + "protectedSource", + "credentials", + "privateSettlementPayload" + ], + "downstreamConsumers": [ + "/packs", + "operator-audit", + "promotion-readiness" + ], + "rowRoot": "v44-economic-domain-row:337033dcfc88cd12dbdeea5e", + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "unpaidAssetPackSourceVisible": false, + "valueBearingMainnetAdmitted": false + } + ], + "sourceRoots": { + "activePointer": "BITCODE_SPEC.txt:4ea77b214c66f69c697bff3d", + "spec": "BITCODE_SPEC_V44.md:27d0568087e0f617f8576694", + "delta": "BITCODE_SPEC_V44_DELTA.md:6cc34f9e954f1a83707af740", + "notes": "BITCODE_SPEC_V44_NOTES.md:05a13e9c9e270882dbc13ebc", + "parity": "BITCODE_SPEC_V44_PARITY_MATRIX.md:ad818785f7ad1864ca7ca237", + "roadmap": "SPECIFICATIONS_ROADMAP.md:aa89238169c79ff321e3f828", + "readme": "README.md:06a61892efa39a9bb5daf972", + "protocolReadme": "packages/protocol/README.md:8c8711285580b921cfc3b1ac", + "packageJson": "package.json:40af7a5aa6601162b9ccab7b", + "gateWorkflow": ".github/workflows/bitcode-gate-quality.yml:b9d45fc664e62530318993cc", + "canonWorkflow": ".github/workflows/bitcode-canon-quality.yml:c61a38ba01701c8f4f39a5c3", + "packageIndex": "packages/protocol/src/index.js:05205fd7a16b03943b4a0f22", + "packageTypes": "packages/protocol/src/index.d.ts:ef61d24f3eeba4aa9e537b22", + "packageSource": "packages/protocol/src/canonical/v44-economic-domain-model.js:21b8f5c80ad8322dff2909ed", + "packageTest": "packages/protocol/test/v44-economic-domain-model.test.js:b89f71aa0cf578dabbec3cd9", + "generator": "scripts/generate-v44-economic-domain-model.mjs:3390fbc087e919bedb14550c", + "checker": "scripts/check-v44-gate2-economic-domain-model.mjs:01a1d9b3df0f75545ddb7e12" + }, + "predicateResults": [ + { + "id": "active-canon-pointer-remains-v43", + "sourcePath": "BITCODE_SPEC.txt", + "passed": true + }, + { + "id": "spec-defines-gate2", + "sourcePath": "BITCODE_SPEC_V44.md", + "passed": true + }, + { + "id": "spec-names-domain-artifact", + "sourcePath": "BITCODE_SPEC_V44.md", + "passed": true + }, + { + "id": "spec-names-economic-objects", + "sourcePath": "BITCODE_SPEC_V44.md", + "passed": true + }, + { + "id": "spec-names-value-labels", + "sourcePath": "BITCODE_SPEC_V44.md", + "passed": true + }, + { + "id": "delta-records-gate2", + "sourcePath": "BITCODE_SPEC_V44_DELTA.md", + "passed": true + }, + { + "id": "notes-records-gate2", + "sourcePath": "BITCODE_SPEC_V44_NOTES.md", + "passed": true + }, + { + "id": "parity-records-gate2", + "sourcePath": "BITCODE_SPEC_V44_PARITY_MATRIX.md", + "passed": true + }, + { + "id": "roadmap-records-gate2", + "sourcePath": "SPECIFICATIONS_ROADMAP.md", + "passed": true + }, + { + "id": "readme-records-gate2", + "sourcePath": "README.md", + "passed": true + }, + { + "id": "protocol-readme-records-gate2", + "sourcePath": "packages/protocol/README.md", + "passed": true + }, + { + "id": "package-exports-gate2", + "sourcePath": "packages/protocol/src/index.js", + "passed": true + }, + { + "id": "package-types-export-gate2", + "sourcePath": "packages/protocol/src/index.d.ts", + "passed": true + }, + { + "id": "package-test-covers-gate2", + "sourcePath": "packages/protocol/test/v44-economic-domain-model.test.js", + "passed": true + }, + { + "id": "package-json-exposes-gate2", + "sourcePath": "package.json", + "passed": true + }, + { + "id": "gate-workflow-runs-gate2", + "sourcePath": ".github/workflows/bitcode-gate-quality.yml", + "passed": true + }, + { + "id": "canon-workflow-runs-gate2", + "sourcePath": ".github/workflows/bitcode-canon-quality.yml", + "passed": true + }, + { + "id": "generator-exists", + "sourcePath": "scripts/generate-v44-economic-domain-model.mjs", + "passed": true + }, + { + "id": "checker-exists", + "sourcePath": "scripts/check-v44-gate2-economic-domain-model.mjs", + "passed": true + } + ], + "coverage": { + "economicObjectsModeled": true, + "receiptTaxonomyModeled": true, + "valueLabelsComplete": true, + "portfolioPositionCovered": true, + "marketSignalsCovered": true, + "quoteStatesCovered": true, + "settlementStatesCovered": true, + "compensationStatementsCovered": true, + "governanceDecisionsCovered": true, + "repairCasesCovered": true, + "budgetPoliciesCovered": true, + "supplyOpportunitiesCovered": true, + "networkRehearsalCovered": true, + "sourceSafeMetadataOnly": true, + "protectedSourceVisible": false, + "rawSourceTextVisible": false, + "sourceSnippetVisible": false, + "rawPromptVisible": false, + "interpolatedPromptVisible": false, + "rawProviderResponseVisible": false, + "unpaidAssetPackSourceVisible": false, + "credentialsSerialized": false, + "walletPrivateMaterialVisible": false, + "settlementPrivatePayloadVisible": false, + "valueBearingMainnetAdmitted": false, + "requiredPredicateCount": 19, + "passedPredicateCount": 19, + "failedPredicateIds": [] + } +} diff --git a/.github/workflows/bitcode-canon-quality.yml b/.github/workflows/bitcode-canon-quality.yml index 4babe74e..a68b9394 100644 --- a/.github/workflows/bitcode-canon-quality.yml +++ b/.github/workflows/bitcode-canon-quality.yml @@ -364,6 +364,9 @@ jobs: if [ -f BITCODE_SPEC_V44.md ]; then node scripts/check-bitcode-spec-family.mjs --version V44 --mode draft --current-target V43 node scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs --skip-branch-check + if [ -f scripts/check-v44-gate2-economic-domain-model.mjs ]; then + node scripts/check-v44-gate2-economic-domain-model.mjs --skip-branch-check --skip-package-tests + fi fi else echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2 diff --git a/.github/workflows/bitcode-gate-quality.yml b/.github/workflows/bitcode-gate-quality.yml index 4ef15171..e92c7c31 100644 --- a/.github/workflows/bitcode-gate-quality.yml +++ b/.github/workflows/bitcode-gate-quality.yml @@ -493,6 +493,9 @@ jobs: if [ -f BITCODE_SPEC_V44.md ]; then node scripts/check-bitcode-spec-family.mjs --version V44 --mode draft --current-target V43 node scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs --skip-branch-check + if [ -f scripts/check-v44-gate2-economic-domain-model.mjs ]; then + node scripts/check-v44-gate2-economic-domain-model.mjs --skip-branch-check --skip-package-tests + fi fi else echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2 @@ -528,6 +531,9 @@ jobs: if [ "$POINTER" = "V43" ] && [ -f scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs ]; then node scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs --skip-branch-check fi + if [ "$POINTER" = "V43" ] && [ -f scripts/check-v44-gate2-economic-domain-model.mjs ]; then + node scripts/check-v44-gate2-economic-domain-model.mjs --skip-branch-check --skip-package-tests + fi if [ "$POINTER" != "V43" ]; then if [ -f scripts/check-v43-gate1-packs-read-deposit-roadmap.mjs ]; then node scripts/check-v43-gate1-packs-read-deposit-roadmap.mjs --skip-branch-check diff --git a/BITCODE_SPEC_V44.md b/BITCODE_SPEC_V44.md index a372214a..f18cdcb6 100644 --- a/BITCODE_SPEC_V44.md +++ b/BITCODE_SPEC_V44.md @@ -184,6 +184,23 @@ compensation statements, governance decisions, and repair cases. It must label estimate, quote, observed payment, final settlement, contributor allocation, delivery, and repair states distinctly. +Gate 2 closes through `V44EconomicDomainModel` in +`packages/protocol/src/canonical/v44-economic-domain-model.js`, deterministic +`.bitcode/v44-economic-domain-model.json`, `generate:v44-economic-domain-model`, +`check:v44-economic-domain-model`, and `check:v44-gate2`. The artifact names +EnterprisePackPortfolio, PackPortfolioPosition, PackMarketSignal, +ReadDemandSignal, UnfitNeedSignal, DepositSupplyOpportunity, +ReadingBudgetPolicy, AssetPackQuotePolicy, ProcurementApprovalReceipt, +DepositorEarningStatement, ContributorCompensationStatement, +PackEconomicStatement, OrganizationPackPolicy, PackGovernanceDecision, +ScaledNetworkRehearsalReceipt, and PortfolioRepairCase as source-safe economic +objects. The receipt taxonomy names portfolio-position, market-signal, +quote-state, settlement-state, compensation-statement, governance-decision, +repair-case, budget-policy, supply-opportunity, and network-rehearsal. It does +not expose protected source, unpaid AssetPack source, raw prompts, provider +payloads, credentials, wallet private material, private settlement payloads, or +value-bearing mainnet operation. + ## V44 Gate 3 Packs Portfolio Search And Market Intelligence Gate 3 must evolve `/packs` from activity master-detail into portfolio and @@ -561,7 +578,7 @@ quality, accessibility, visual inspectability, and generated quality evidence. | `.bitcode/v44-spec-family-report.json` | aggregate proof verdict | draft-required | | `.bitcode/v44-canonical-input-report.json` | generated artifact inventories | draft-required | | `.bitcode/v44-canon-posture-drift-report.json` | active/draft posture | draft-required | -| `.bitcode/v44-economic-domain-model.json` | economic domain model | planned | +| `.bitcode/v44-economic-domain-model.json` | economic domain model | implemented-source-safe | | `.bitcode/v44-packs-portfolio-market-intelligence.json` | Packs portfolio and market intelligence | planned | | `.bitcode/v44-reading-budget-quote-policy.json` | Reading budget and quote policy | planned | | `.bitcode/v44-depositor-earnings-supply-opportunities.json` | depositor earnings and supply opportunities | planned | @@ -629,7 +646,10 @@ explicit later launch authority, or economic receipts cannot reconcile. ## V44 validation canon -Gate 1 validates with `pnpm run check:v44-gate1`, +Gate 1 validates with `pnpm run check:v44-gate1`. Gate 2 validates with +`pnpm run generate:v44-economic-domain-model`, +`pnpm run check:v44-economic-domain-model`, and `pnpm run check:v44-gate2`. +Shared draft posture validates with `node scripts/check-bitcode-spec-family.mjs --version V44 --mode draft --current-target V43`, `node scripts/check-bitcode-canon-posture-drift.mjs --active-canon V43 --draft-target V44`, and `git diff --check`. @@ -700,7 +720,7 @@ Inherited. | `.bitcode/v44-spec-family-report.json` | aggregate proof verdict | draft-required | | `.bitcode/v44-canonical-input-report.json` | exact generated-artifact inventory | draft-required | | `.bitcode/v44-canon-posture-drift-report.json` | active/draft posture | draft-required | -| `.bitcode/v44-economic-domain-model.json` | economic domain model | planned | +| `.bitcode/v44-economic-domain-model.json` | economic domain model | implemented-source-safe | | `.bitcode/v44-packs-portfolio-market-intelligence.json` | portfolio and market intelligence | planned | | `.bitcode/v44-reading-budget-quote-policy.json` | budget and quote policy | planned | | `.bitcode/v44-depositor-earnings-supply-opportunities.json` | depositor earning opportunity | planned | @@ -715,6 +735,7 @@ Inherited. `.bitcode/v44-spec-family-report.json`, `.bitcode/v44-canonical-input-report.json`, and `.bitcode/v44-canon-posture-drift-report.json` are the opening artifacts. +Gate 2 adds deterministic `.bitcode/v44-economic-domain-model.json`. ### Shared generated-artifact fields diff --git a/BITCODE_SPEC_V44_DELTA.md b/BITCODE_SPEC_V44_DELTA.md index a19d5e1a..675d33f2 100644 --- a/BITCODE_SPEC_V44_DELTA.md +++ b/BITCODE_SPEC_V44_DELTA.md @@ -3,12 +3,12 @@ ## Status - Version: `V44` -- V44 state: draft opened for scaled engineering economy and tokenized AssetPack network work over promoted V43 +- V44 state: draft Gate 2 economic domain model work over promoted V43 - Current canonical/latest target: `V43` - Prior canonical anchor: `BITCODE_SPEC_V43.md` - Prior generated proof appendix: `BITCODE_SPEC_V43_PROVEN.md` -- Generated structured artifact inventory: no V44 generated artifacts are canonical at Gate 1; later gates must create source-safe `.bitcode/v44-*` artifacts -- Source parity state: Gate 1 aligns specification, roadmap, docs, workflow, package script, and checker posture only +- Generated structured artifact inventory: Gate 2 adds deterministic `.bitcode/v44-economic-domain-model.json` +- Source parity state: Gate 2 binds package-backed economic object contracts, receipt taxonomy, docs, workflow, package script, checker, and protocol tests - Notes companion: `BITCODE_SPEC_V44_NOTES.md` - Delta companion: `BITCODE_SPEC_V44_DELTA.md` - Parity companion: `BITCODE_SPEC_V44_PARITY_MATRIX.md` @@ -32,6 +32,9 @@ settlements, contributors, compensation statements, and repair states. settlement, contributor allocation, delivery, or repair state. - Keep source-safety stronger than UX convenience. - Keep value-bearing mainnet blocked until a later explicit launch version. +- Bind Gate 2 economic contracts in package code before route/API/UI surfaces + consume portfolio, quote, settlement, compensation, governance, or repair + objects. ## V44 gate plan @@ -53,6 +56,11 @@ APIs, budget policy engines, compensation statement materialization, governance runtime enforcement, scaled rehearsal scripts, and V44 promotion workflow until their owning gates. +V44 Gate 2 closes the source-safe economic domain model and receipt taxonomy +only. It does not implement route dashboards, quote engines, settlement +observation, compensation payout execution, organization wallet authority, or +scaled rehearsals. + ## Pre-Implementation Sequence 1. Open V44 spec family, roadmap, checker, package script, workflow posture, @@ -70,7 +78,10 @@ their owning gates. ## Validation direction -Gate 1 validates with `pnpm run check:v44-gate1`, +Gate 1 validates with `pnpm run check:v44-gate1`. Gate 2 validates with +`pnpm run generate:v44-economic-domain-model`, +`pnpm run check:v44-economic-domain-model`, and `pnpm run check:v44-gate2`. +Shared draft posture validates with `node scripts/check-bitcode-spec-family.mjs --version V44 --mode draft --current-target V43`, `node scripts/check-bitcode-canon-posture-drift.mjs --active-canon V43 --draft-target V44`, and `git diff --check`. diff --git a/BITCODE_SPEC_V44_NOTES.md b/BITCODE_SPEC_V44_NOTES.md index f1f62eb2..df9700f8 100644 --- a/BITCODE_SPEC_V44_NOTES.md +++ b/BITCODE_SPEC_V44_NOTES.md @@ -3,12 +3,12 @@ ## Status - Version: `V44` -- V44 state: draft notes opened for scaled engineering economy work over promoted V43 +- V44 state: draft notes include Gate 2 economic domain model work over promoted V43 - Current canonical/latest target: `V43` - Prior canonical anchor: `BITCODE_SPEC_V43.md` - Prior generated proof appendix: `BITCODE_SPEC_V43_PROVEN.md` -- Generated structured artifact inventory: V44 notes bind planning language only until later generated `.bitcode/v44-*` artifacts exist -- Source parity state: notes align roadmap, docs, and workflow posture for active V43 / draft V44 +- Generated structured artifact inventory: Gate 2 adds deterministic `.bitcode/v44-economic-domain-model.json` +- Source parity state: notes align roadmap, docs, workflow posture, package source, generated artifact, and receipt taxonomy for active V43 / draft V44 - Scope: V44 notes for digitizing and tokenizing scaled engineering economies through enterprise AssetPack portfolio, market intelligence, BTD/BTC accounting, governance, and compensation operation - Last fully realized canonical target preserved in source: `V43` @@ -82,3 +82,15 @@ wallet private material, or private settlement payloads. Gate 1 is intentionally a posture gate. It opens the V44 family and validates that the repo now understands V43 active / V44 draft. It must not implement later economic products under a loose roadmap commit. + +## Gate 2 note + +Gate 2 names the economic objects before later gates render or execute them. +The package-backed receipt taxonomy distinguishes portfolio-position, +market-signal, quote-state, settlement-state, compensation-statement, +governance-decision, repair-case, budget-policy, supply-opportunity, and +network-rehearsal receipts. Its value labels remain estimate, quote, observed +payment, final settlement, contributor allocation, delivery, and repair state. +This is intentionally source-safe: it carries identifiers, roots, states, and +contracts, not protected source, unpaid AssetPack source, raw prompts, provider +payloads, credentials, wallet private material, or private settlement payloads. diff --git a/BITCODE_SPEC_V44_PARITY_MATRIX.md b/BITCODE_SPEC_V44_PARITY_MATRIX.md index ceb9a798..f4724ce0 100644 --- a/BITCODE_SPEC_V44_PARITY_MATRIX.md +++ b/BITCODE_SPEC_V44_PARITY_MATRIX.md @@ -3,12 +3,12 @@ ## Status - Version: `V44` -- V44 state: draft parity opened for scaled engineering economy and tokenized AssetPack network work +- V44 state: draft parity includes Gate 2 economic domain model work - Current canonical/latest target: `V43` - Prior canonical anchor: `BITCODE_SPEC_V43.md` - Prior generated proof appendix: `BITCODE_SPEC_V43_PROVEN.md` -- Generated structured artifact inventory: V44 parity begins as planning metadata; later gates must close generated `.bitcode/v44-*` artifacts -- Source parity state: Gate 1 requires spec/docs/workflow/checker parity only +- Generated structured artifact inventory: Gate 2 adds deterministic `.bitcode/v44-economic-domain-model.json` +- Source parity state: Gate 2 requires package/docs/workflow/checker/test parity for the economic receipt taxonomy - Scope: parity for V44 enterprise economic operation over promoted V43 product routes - Last fully realized canonical target preserved in source: `V43` @@ -28,8 +28,8 @@ artifacts, workflow checks, and local/staging rehearsal receipts. | Area | Required V44 result | Current judgment | | --- | --- | --- | -| Gate 1 roadmap | V43 active / V44 draft posture, spec family, docs, workflow, package script, checker | drafted | -| Economic domain model | Portfolio positions, market signals, quote states, settlement states, statements, repair cases | drafted | +| Gate 1 roadmap | V43 active / V44 draft posture, spec family, docs, workflow, package script, checker | implemented | +| Economic domain model | Portfolio positions, market signals, quote states, settlement states, statements, repair cases | implemented | | Packs portfolio | `/packs` portfolio search, market intelligence, saved filters, economic facets | drafted | | Reading procurement | Budget, quote policy, approval thresholds, purchase governance | drafted | | Depositor earnings | ROI, demand, compensation opportunity, supply recommendations | drafted | @@ -43,8 +43,8 @@ artifacts, workflow checks, and local/staging rehearsal receipts. | Area | Required V44 result | Current judgment | | --- | --- | --- | -| Source safety | No protected source, unpaid source, raw prompts, provider payloads, credentials, wallet secrets | drafted | -| Economic labels | Estimate, quote, observed payment, settlement, allocation, delivery, repair are distinct | drafted | +| Source safety | No protected source, unpaid source, raw prompts, provider payloads, credentials, wallet secrets | implemented | +| Economic labels | Estimate, quote, observed payment, settlement, allocation, delivery, repair are distinct | implemented | | Ledger reconciliation | Portfolio statements reconcile to receipts before finality | drafted | | Route authority | `/packs`, `/read`, `/deposit` do not bypass protocol law | drafted | | Tests and proofs | Each gate has generated artifacts, package tests, route tests, and workflow checks | drafted | diff --git a/README.md b/README.md index 0a9effdc..c2f30dcc 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,18 @@ local/staging-testnet rehearsal, and polished economic operation through `/packs`, `/read`, and `/deposit`. Gate 1 is specification, roadmap, documentation, workflow, and checker posture only. +V44 Gate 2 adds `V44EconomicDomainModel`, +`.bitcode/v44-economic-domain-model.json`, +`generate:v44-economic-domain-model`, `check:v44-economic-domain-model`, and +`check:v44-gate2`. It defines source-safe contracts for portfolio positions, +market signals, quote states, settlement states, compensation statements, +governance decisions, and repair cases while keeping economic values labeled +as estimate, quote, observed payment, final settlement, contributor +allocation, delivery, or repair state. Gate 2 does not expose protected source, +unpaid AssetPack source, raw prompts, provider payloads, credentials, wallet +private material, private settlement payloads, or value-bearing mainnet +operation. + Exchange is inherited V36 canon: market-wide activity master-detail, buy/sell/ bid/ask/cancel/accept/settle/history flows, AssetPack range trading, rights-transfer review, pricing/liquidity/wrapper analysis, settlement diff --git a/SPECIFICATIONS_ROADMAP.md b/SPECIFICATIONS_ROADMAP.md index c76805a6..cff0beae 100644 --- a/SPECIFICATIONS_ROADMAP.md +++ b/SPECIFICATIONS_ROADMAP.md @@ -5,11 +5,12 @@ - Current active canonical pointer: `BITCODE_SPEC.txt` -> `V43` - Current active canon: `BITCODE_SPEC_V43.md` - Current draft target: `BITCODE_SPEC_V44.md`. -- Current working gate: V44 Gate 1 Scaled Engineering Economy Roadmap Opening. -- Next queued work after V44 Gate 1: V44 economic domain model and receipt taxonomy, `/packs` portfolio market intelligence, Reading budget/quote governance, Depositor earning intelligence, BTD/BTC compensation statements, organization policy, enterprise UX, scaled local/staging rehearsal, and V44 promotion readiness. +- Current working gate: V44 Gate 2 Economic Domain Model And Receipt Taxonomy. +- Next queued work after V44 Gate 2: `/packs` portfolio market intelligence, Reading budget/quote governance, Depositor earning intelligence, BTD/BTC compensation statements, organization policy, enterprise UX, scaled local/staging rehearsal, and V44 promotion readiness. - Latest closed version: V43 Route Product Cleanup, which promoted `/packs`, `/read`, and `/deposit`; PackActivity master-detail; five-step Reading route UX; deposit AssetPack option synthesis; deposit criticality/ROI/compensation policy; option admission; product route UX; cross-route rehearsal; and V43 promotion readiness. - Recent V43 canonical promotion anchor: V43 canonical promotion updated `BITCODE_SPEC.txt` to `V43`, generated `BITCODE_SPEC_V43_PROVEN.md`, preserved active V43 / draft V44 runtime posture, and closed route-product cleanup canon. - V44 Gate 1 opening anchor: scaled engineering economy opens over promoted V43 with V44 SPEC, DELTA, NOTES, and PARITY files, `check:v44-gate1`, active V43 / draft V44 posture, and a ten-gate plan for economic domain models, Packs portfolio intelligence, Reading budget/quote governance, Depositor earnings/ROI intelligence, BTD/BTC compensation statements, organization policy/wallet authority, enterprise economic UX, scaled local/staging rehearsal, and promotion readiness. +- V44 Gate 2 closure anchor: scaled engineering economy now owns package-backed `V44EconomicDomainModel`, deterministic `.bitcode/v44-economic-domain-model.json`, source-safe object contracts for EnterprisePackPortfolio, PackPortfolioPosition, PackMarketSignal, ReadDemandSignal, UnfitNeedSignal, DepositSupplyOpportunity, ReadingBudgetPolicy, AssetPackQuotePolicy, ProcurementApprovalReceipt, DepositorEarningStatement, ContributorCompensationStatement, PackEconomicStatement, OrganizationPackPolicy, PackGovernanceDecision, ScaledNetworkRehearsalReceipt, and PortfolioRepairCase, receipt taxonomy coverage for portfolio positions, market signals, quote states, settlement states, compensation statements, governance decisions, repair cases, budget policies, supply opportunities, and network rehearsals, distinct estimate/quote/observed payment/final settlement/contributor allocation/delivery/repair labels, source-safe forbidden payload checks, package exports, protocol tests, workflow wiring, and `check:v44-gate2`. - Latest prior closed version: V42 Reliable MVP Experience, which promoted shortest-path Depositing, five-step Reading, ReadNeed review/resynthesis, ReadFitsFinding source-safe preview and quote, settlement rights transfer, repository delivery, AI-reading demonstration, local/staging MVP rehearsal, and V42 promotion readiness. - Recent V42 canonical promotion anchor: V42 canonical promotion updated `BITCODE_SPEC.txt` to `V42`, generated `BITCODE_SPEC_V42_PROVEN.md`, preserved active V42 / draft V43 runtime posture, and closed reliable MVP experience canon. - Recent V42 opening anchor: reliable MVP experience opens over promoted V41 with V42 SPEC, DELTA, NOTES, and PARITY files, `check:v42-gate1`, active V41 / draft V42 posture, and a nine-gate plan for shortest-path Depositing, five-step Reading, ReadNeed product closure, ReadFitsFinding preview and quote closure, settlement and repository delivery, AI-reading demonstration, local/staging rehearsal, and promotion readiness. diff --git a/package.json b/package.json index 4a2b9f7e..132d2c70 100644 --- a/package.json +++ b/package.json @@ -359,6 +359,9 @@ "check:v43-promotion-readiness": "node scripts/generate-v43-promotion-readiness-report.mjs --check", "check:v43-gate10": "node scripts/check-v43-gate10-promotion-readiness.mjs", "check:v44-gate1": "node scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs", + "generate:v44-economic-domain-model": "node scripts/generate-v44-economic-domain-model.mjs", + "check:v44-economic-domain-model": "node scripts/generate-v44-economic-domain-model.mjs --check", + "check:v44-gate2": "node scripts/check-v44-gate2-economic-domain-model.mjs", "generate:v38-inference-surface-inventory": "node scripts/generate-v38-inference-surface-inventory.mjs", "check:v38-inference-surface-inventory": "node scripts/generate-v38-inference-surface-inventory.mjs --check", "check:v38-gate2": "node scripts/check-v38-gate2-inference-surface-inventory.mjs", diff --git a/packages/protocol/README.md b/packages/protocol/README.md index 36c6f3b7..2c2cc66e 100644 --- a/packages/protocol/README.md +++ b/packages/protocol/README.md @@ -186,6 +186,16 @@ compensation statements, organization policy, wallet authority, scaled local/staging-testnet rehearsal, and `/packs`, `/read`, `/deposit` economic operation. Gate 1 is specification/documentation/workflow posture only. +V44 Gate 2 adds `V44EconomicDomainModel` through +`packages/protocol/src/canonical/v44-economic-domain-model.js`, +`packages/protocol/test/v44-economic-domain-model.test.js`, +`.bitcode/v44-economic-domain-model.json`, +`generate:v44-economic-domain-model`, `check:v44-economic-domain-model`, and +`check:v44-gate2`. It binds source-safe economic object contracts, receipt +taxonomy ids, value labels, forbidden payload ids, package exports, workflow +checks, and generated artifact freshness for later `/packs`, `/read`, and +`/deposit` economic operation. + Historical V39 promotion moved this package through the `V39` active, `V40` draft posture. V40 promotion has since advanced the current package posture to `V40` active, `V41` draft. diff --git a/packages/protocol/src/canonical/v44-economic-domain-model.js b/packages/protocol/src/canonical/v44-economic-domain-model.js new file mode 100644 index 00000000..f346af1e --- /dev/null +++ b/packages/protocol/src/canonical/v44-economic-domain-model.js @@ -0,0 +1,441 @@ +// @ts-check + +import crypto from 'node:crypto'; +import { existsSync, readFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const DEFAULT_REPO_ROOT = path.resolve(__dirname, '..', '..', '..', '..'); + +export const V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH = + '.bitcode/v44-economic-domain-model.json'; +export const V44_ECONOMIC_DOMAIN_MODEL_SCHEMA_ID = + 'bitcode.v44.economicDomainModel.v1'; +export const V44_ECONOMIC_DOMAIN_MODEL_VERSION = 'V44'; +export const V44_ECONOMIC_DOMAIN_MODEL_CURRENT_TARGET = 'V43'; +export const V44_ECONOMIC_DOMAIN_MODEL_SOURCE_SAFETY_VERDICT = + 'source-safe-economic-domain-model-metadata'; + +export const V44_ECONOMIC_OBJECT_IDS = Object.freeze([ + 'EnterprisePackPortfolio', + 'PackPortfolioPosition', + 'PackMarketSignal', + 'ReadDemandSignal', + 'UnfitNeedSignal', + 'DepositSupplyOpportunity', + 'ReadingBudgetPolicy', + 'AssetPackQuotePolicy', + 'ProcurementApprovalReceipt', + 'DepositorEarningStatement', + 'ContributorCompensationStatement', + 'PackEconomicStatement', + 'OrganizationPackPolicy', + 'PackGovernanceDecision', + 'ScaledNetworkRehearsalReceipt', + 'PortfolioRepairCase', +]); + +export const V44_ECONOMIC_RECEIPT_TAXONOMY_IDS = Object.freeze([ + 'portfolio-position', + 'market-signal', + 'quote-state', + 'settlement-state', + 'compensation-statement', + 'governance-decision', + 'repair-case', + 'budget-policy', + 'supply-opportunity', + 'network-rehearsal', +]); + +export const V44_ECONOMIC_VALUE_LABEL_IDS = Object.freeze([ + 'estimate', + 'quote', + 'observed-payment', + 'final-settlement', + 'contributor-allocation', + 'delivery', + 'repair-state', +]); + +export const V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS = Object.freeze([ + 'objectId', + 'receiptTaxonomyIds', + 'valueLabelIds', + 'state', + 'scope', + 'organizationId', + 'repositoryRef', + 'assetPackId', + 'needId', + 'quoteId', + 'settlementId', + 'compensationId', + 'governanceDecisionId', + 'repairCaseId', + 'measurementRoot', + 'policyRoot', + 'proofRoot', + 'telemetryRoot', +]); + +export const V44_ECONOMIC_FORBIDDEN_PAYLOAD_IDS = Object.freeze([ + 'protected-source-payloads', + 'unpaid-assetpack-source', + 'source-snippets', + 'raw-prompts', + 'interpolated-prompts', + 'raw-provider-responses', + 'credentials', + 'wallet-private-material', + 'private-settlement-payloads', + 'value-bearing-mainnet-admission', +]); + +const SOURCE_ROOTS = Object.freeze({ + activePointer: 'BITCODE_SPEC.txt', + spec: 'BITCODE_SPEC_V44.md', + delta: 'BITCODE_SPEC_V44_DELTA.md', + notes: 'BITCODE_SPEC_V44_NOTES.md', + parity: 'BITCODE_SPEC_V44_PARITY_MATRIX.md', + roadmap: 'SPECIFICATIONS_ROADMAP.md', + readme: 'README.md', + protocolReadme: 'packages/protocol/README.md', + packageJson: 'package.json', + gateWorkflow: '.github/workflows/bitcode-gate-quality.yml', + canonWorkflow: '.github/workflows/bitcode-canon-quality.yml', + packageIndex: 'packages/protocol/src/index.js', + packageTypes: 'packages/protocol/src/index.d.ts', + packageSource: 'packages/protocol/src/canonical/v44-economic-domain-model.js', + packageTest: 'packages/protocol/test/v44-economic-domain-model.test.js', + generator: 'scripts/generate-v44-economic-domain-model.mjs', + checker: 'scripts/check-v44-gate2-economic-domain-model.mjs', +}); + +function digest(value) { + return crypto.createHash('sha256').update(value).digest('hex').slice(0, 24); +} + +function readSource(repoRoot, sourcePath) { + const absolutePath = path.join(repoRoot, sourcePath); + return existsSync(absolutePath) ? readFileSync(absolutePath, 'utf8') : ''; +} + +function predicateResult(id, sourcePath, passed) { + return { id, sourcePath, passed: Boolean(passed) }; +} + +function sourceRoot(sourcePath) { + return `${sourcePath}:${digest(readSource(DEFAULT_REPO_ROOT, sourcePath))}`; +} + +function objectRow({ + objectId, + receiptTaxonomyIds, + valueLabelIds, + contract, + stateIds, + sourceSafeFields, + privateFieldsNeverSerialized, + downstreamConsumers, +}) { + return { + objectId, + receiptTaxonomyIds, + valueLabelIds, + contract, + stateIds, + sourceSafeFields, + privateFieldsNeverSerialized, + downstreamConsumers, + }; +} + +export const V44_ECONOMIC_DOMAIN_ROWS = Object.freeze([ + objectRow({ + objectId: 'EnterprisePackPortfolio', + receiptTaxonomyIds: ['portfolio-position', 'market-signal', 'governance-decision'], + valueLabelIds: ['estimate', 'quote', 'final-settlement', 'delivery'], + contract: + 'EnterprisePackPortfolio aggregates source-safe Pack positions, Pack activity, demand/supply signals, and policy receipts for one organization.', + stateIds: ['empty', 'active', 'requires-repair', 'restricted-by-policy'], + sourceSafeFields: ['organizationId', 'positionIds', 'marketSignalIds', 'policyRoot', 'proofRoot'], + privateFieldsNeverSerialized: ['protectedSource', 'unpaidAssetPackSource', 'walletPrivateMaterial'], + downstreamConsumers: ['/packs', 'organization-policy', 'scaled-network-rehearsal'], + }), + objectRow({ + objectId: 'PackPortfolioPosition', + receiptTaxonomyIds: ['portfolio-position', 'settlement-state', 'delivery'], + valueLabelIds: ['estimate', 'quote', 'observed-payment', 'final-settlement', 'delivery'], + contract: + 'PackPortfolioPosition records one AssetPack economic position with source-safe ownership, quote, settlement, delivery, and repair readback.', + stateIds: ['previewable', 'quoted', 'settled', 'delivered', 'repair-required'], + sourceSafeFields: ['assetPackId', 'quoteId', 'settlementId', 'deliveryState', 'measurementRoot'], + privateFieldsNeverSerialized: ['protectedSource', 'privateSettlementPayload'], + downstreamConsumers: ['/packs', '/read', 'delivery-boundary'], + }), + objectRow({ + objectId: 'PackMarketSignal', + receiptTaxonomyIds: ['market-signal'], + valueLabelIds: ['estimate'], + contract: + 'PackMarketSignal summarizes source-safe demand, supply, compensation, and settlement pressure for AssetPack discovery and portfolio search.', + stateIds: ['observed', 'stale', 'suppressed-by-policy'], + sourceSafeFields: ['signalId', 'assetPackId', 'needId', 'measurementRoot', 'telemetryRoot'], + privateFieldsNeverSerialized: ['rawPrompt', 'rawProviderResponse', 'protectedSource'], + downstreamConsumers: ['/packs', '/deposit', 'supply-opportunity'], + }), + objectRow({ + objectId: 'ReadDemandSignal', + receiptTaxonomyIds: ['market-signal'], + valueLabelIds: ['estimate'], + contract: + 'ReadDemandSignal records source-safe Need demand for Matching Fits without exposing buyer private context or unpaid source.', + stateIds: ['requested', 'reviewed-need', 'fit-found', 'unfit'], + sourceSafeFields: ['needId', 'repositoryRef', 'measurementRoot', 'policyRoot', 'proofRoot'], + privateFieldsNeverSerialized: ['privateReadContext', 'rawPrompt', 'interpolatedPrompt'], + downstreamConsumers: ['/read', '/packs', '/deposit'], + }), + objectRow({ + objectId: 'UnfitNeedSignal', + receiptTaxonomyIds: ['market-signal', 'supply-opportunity', 'repair-case'], + valueLabelIds: ['estimate', 'repair-state'], + contract: + 'UnfitNeedSignal preserves source-safe evidence that a reviewed Need lacked enough eligible Fits and can drive deposit opportunity discovery.', + stateIds: ['unfit', 'reopened', 'supplied-later', 'closed'], + sourceSafeFields: ['needId', 'reasonCode', 'measurementRoot', 'repairCaseId', 'proofRoot'], + privateFieldsNeverSerialized: ['privateReadContext', 'protectedSource'], + downstreamConsumers: ['/deposit', '/packs', 'repair-workflows'], + }), + objectRow({ + objectId: 'DepositSupplyOpportunity', + receiptTaxonomyIds: ['supply-opportunity', 'market-signal'], + valueLabelIds: ['estimate', 'contributor-allocation'], + contract: + 'DepositSupplyOpportunity estimates source-safe likelihood, criticality, ROI, and downstream compensation posture for proposed AssetPack deposits.', + stateIds: ['candidate', 'eligible', 'blocked-critical-source', 'admitted', 'rejected'], + sourceSafeFields: ['opportunityId', 'repositoryRef', 'demandSignalIds', 'measurementRoot', 'policyRoot'], + privateFieldsNeverSerialized: ['protectedSource', 'sourceSnippet', 'credentials'], + downstreamConsumers: ['/deposit', '/packs', 'depository-admission'], + }), + objectRow({ + objectId: 'ReadingBudgetPolicy', + receiptTaxonomyIds: ['budget-policy', 'governance-decision'], + valueLabelIds: ['estimate', 'quote'], + contract: + 'ReadingBudgetPolicy defines source-safe spend envelopes, approval thresholds, quote expiry posture, and fail-closed admission for Reading.', + stateIds: ['draft', 'active', 'approval-required', 'exceeded', 'expired'], + sourceSafeFields: ['policyId', 'organizationId', 'budgetEnvelopeRoot', 'approvalThresholdRoot'], + privateFieldsNeverSerialized: ['walletPrivateMaterial', 'privateSettlementPayload'], + downstreamConsumers: ['/read', 'quote-policy', 'wallet-authority'], + }), + objectRow({ + objectId: 'AssetPackQuotePolicy', + receiptTaxonomyIds: ['quote-state', 'budget-policy', 'settlement-state'], + valueLabelIds: ['estimate', 'quote', 'observed-payment', 'final-settlement'], + contract: + 'AssetPackQuotePolicy binds deterministic source-to-shares measurement, quote state, expiry, payment observation, and final settlement boundaries.', + stateIds: ['estimated', 'quoted', 'expired', 'payment-observed', 'settled', 'repaired'], + sourceSafeFields: ['quoteId', 'assetPackId', 'shareCalculationRoot', 'expiry', 'proofRoot'], + privateFieldsNeverSerialized: ['unpaidAssetPackSource', 'privateSettlementPayload', 'walletPrivateMaterial'], + downstreamConsumers: ['/read', '/packs', 'settlement-boundary'], + }), + objectRow({ + objectId: 'ProcurementApprovalReceipt', + receiptTaxonomyIds: ['governance-decision', 'budget-policy', 'quote-state'], + valueLabelIds: ['quote'], + contract: + 'ProcurementApprovalReceipt records source-safe buyer approval, reviewer authority, budget posture, and quote admission before settlement.', + stateIds: ['pending', 'approved', 'denied', 'expired', 'superseded'], + sourceSafeFields: ['approvalId', 'quoteId', 'reviewerRole', 'policyRoot', 'proofRoot'], + privateFieldsNeverSerialized: ['credentials', 'walletPrivateMaterial', 'privateSettlementPayload'], + downstreamConsumers: ['/read', 'organization-policy', 'settlement-boundary'], + }), + objectRow({ + objectId: 'DepositorEarningStatement', + receiptTaxonomyIds: ['compensation-statement', 'settlement-state'], + valueLabelIds: ['estimate', 'observed-payment', 'final-settlement', 'contributor-allocation'], + contract: + 'DepositorEarningStatement summarizes source-safe estimated, observed, settled, and allocated value for a depositor across AssetPack use.', + stateIds: ['estimated', 'payment-observed', 'settled', 'allocated', 'repair-required'], + sourceSafeFields: ['statementId', 'assetPackId', 'depositorAccountRef', 'allocationRoot', 'settlementId'], + privateFieldsNeverSerialized: ['walletPrivateMaterial', 'privateSettlementPayload'], + downstreamConsumers: ['/packs', '/deposit', 'compensation-ledger'], + }), + objectRow({ + objectId: 'ContributorCompensationStatement', + receiptTaxonomyIds: ['compensation-statement'], + valueLabelIds: ['contributor-allocation', 'observed-payment', 'final-settlement'], + contract: + 'ContributorCompensationStatement preserves source-to-shares allocation conservation and contributor readback without exposing private wallet material.', + stateIds: ['pending-allocation', 'allocated', 'payable', 'paid', 'repair-required'], + sourceSafeFields: ['compensationId', 'contributorRef', 'allocationRoot', 'settlementId', 'proofRoot'], + privateFieldsNeverSerialized: ['walletPrivateMaterial', 'privateSettlementPayload', 'protectedSource'], + downstreamConsumers: ['/packs', 'ledger-reconciliation', 'repair-workflows'], + }), + objectRow({ + objectId: 'PackEconomicStatement', + receiptTaxonomyIds: ['portfolio-position', 'quote-state', 'settlement-state', 'compensation-statement'], + valueLabelIds: ['estimate', 'quote', 'observed-payment', 'final-settlement', 'contributor-allocation', 'delivery'], + contract: + 'PackEconomicStatement composes source-safe position, quote, payment, settlement, delivery, and compensation state for one AssetPack.', + stateIds: ['estimated', 'quoted', 'settled', 'delivered', 'reconciled', 'repair-required'], + sourceSafeFields: ['assetPackId', 'quoteId', 'settlementId', 'deliveryState', 'allocationRoot'], + privateFieldsNeverSerialized: ['unpaidAssetPackSource', 'privateSettlementPayload', 'walletPrivateMaterial'], + downstreamConsumers: ['/packs', '/read', '/deposit', 'promotion-rehearsal'], + }), + objectRow({ + objectId: 'OrganizationPackPolicy', + receiptTaxonomyIds: ['budget-policy', 'governance-decision'], + valueLabelIds: ['estimate', 'quote', 'repair-state'], + contract: + 'OrganizationPackPolicy defines source-safe role, spending, depositing, source-criticality, and wallet authority controls across routes.', + stateIds: ['draft', 'active', 'blocked', 'override-required', 'repair-required'], + sourceSafeFields: ['policyId', 'organizationId', 'roleRoot', 'limitRoot', 'walletAuthorityRoot'], + privateFieldsNeverSerialized: ['credentials', 'walletPrivateMaterial', 'protectedSource'], + downstreamConsumers: ['/packs', '/read', '/deposit', 'wallet-authority'], + }), + objectRow({ + objectId: 'PackGovernanceDecision', + receiptTaxonomyIds: ['governance-decision'], + valueLabelIds: ['quote', 'delivery', 'repair-state'], + contract: + 'PackGovernanceDecision records source-safe allow, deny, require-review, repair, and override outcomes for economic operation.', + stateIds: ['allowed', 'denied', 'review-required', 'override-required', 'repair-required'], + sourceSafeFields: ['governanceDecisionId', 'policyId', 'decisionKind', 'proofRoot', 'telemetryRoot'], + privateFieldsNeverSerialized: ['credentials', 'walletPrivateMaterial', 'privateSettlementPayload'], + downstreamConsumers: ['/packs', '/read', '/deposit', 'governance-audit'], + }), + objectRow({ + objectId: 'ScaledNetworkRehearsalReceipt', + receiptTaxonomyIds: ['network-rehearsal', 'settlement-state', 'repair-case'], + valueLabelIds: ['estimate', 'quote', 'observed-payment', 'final-settlement', 'contributor-allocation', 'delivery', 'repair-state'], + contract: + 'ScaledNetworkRehearsalReceipt proves many deposits, Reads, Fits, quotes, settlements, contributors, deliveries, and repairs on safe lanes.', + stateIds: ['local-passed', 'staging-testnet-passed', 'blocked-mainnet', 'repair-required'], + sourceSafeFields: ['rehearsalId', 'laneId', 'scenarioRoot', 'telemetryRoot', 'proofRoot'], + privateFieldsNeverSerialized: ['credentials', 'walletPrivateMaterial', 'privateSettlementPayload', 'protectedSource'], + downstreamConsumers: ['promotion-readiness', 'operator-audit'], + }), + objectRow({ + objectId: 'PortfolioRepairCase', + receiptTaxonomyIds: ['repair-case', 'portfolio-position', 'settlement-state', 'compensation-statement'], + valueLabelIds: ['repair-state', 'estimate', 'quote', 'final-settlement', 'delivery'], + contract: + 'PortfolioRepairCase records source-safe economic discrepancy, stale state, reconciliation action, and closure evidence.', + stateIds: ['opened', 'triaged', 'repairing', 'closed', 'escalated'], + sourceSafeFields: ['repairCaseId', 'objectId', 'reasonCode', 'actionRoot', 'proofRoot'], + privateFieldsNeverSerialized: ['protectedSource', 'credentials', 'privateSettlementPayload'], + downstreamConsumers: ['/packs', 'operator-audit', 'promotion-readiness'], + }), +]); + +function buildPredicateResults(repoRoot) { + const sources = Object.fromEntries( + Object.entries(SOURCE_ROOTS).map(([key, sourcePath]) => [key, readSource(repoRoot, sourcePath)]), + ); + + return [ + predicateResult('active-canon-pointer-remains-v43', SOURCE_ROOTS.activePointer, sources.activePointer.trim() === 'V43'), + predicateResult('spec-defines-gate2', SOURCE_ROOTS.spec, sources.spec.includes('V44 Gate 2 Economic Domain Model And Receipt Taxonomy')), + predicateResult('spec-names-domain-artifact', SOURCE_ROOTS.spec, sources.spec.includes('v44-economic-domain-model')), + predicateResult('spec-names-economic-objects', SOURCE_ROOTS.spec, V44_ECONOMIC_OBJECT_IDS.every((objectId) => sources.spec.includes(objectId))), + predicateResult('spec-names-value-labels', SOURCE_ROOTS.spec, V44_ECONOMIC_VALUE_LABEL_IDS.every((labelId) => sources.spec.includes(labelId.replaceAll('-', ' ')) || sources.spec.includes(labelId))), + predicateResult('delta-records-gate2', SOURCE_ROOTS.delta, sources.delta.includes('Gate 2') && sources.delta.includes('v44-economic-domain-model')), + predicateResult('notes-records-gate2', SOURCE_ROOTS.notes, sources.notes.includes('Gate 2') && sources.notes.includes('receipt taxonomy')), + predicateResult('parity-records-gate2', SOURCE_ROOTS.parity, sources.parity.includes('v44-economic-domain-model')), + predicateResult('roadmap-records-gate2', SOURCE_ROOTS.roadmap, sources.roadmap.includes('V44 Gate 2 closure anchor')), + predicateResult('readme-records-gate2', SOURCE_ROOTS.readme, sources.readme.includes('V44 Gate 2')), + predicateResult('protocol-readme-records-gate2', SOURCE_ROOTS.protocolReadme, sources.protocolReadme.includes('V44 Gate 2')), + predicateResult('package-exports-gate2', SOURCE_ROOTS.packageIndex, sources.packageIndex.includes('buildV44EconomicDomainModel')), + predicateResult('package-types-export-gate2', SOURCE_ROOTS.packageTypes, sources.packageTypes.includes('buildV44EconomicDomainModel')), + predicateResult('package-test-covers-gate2', SOURCE_ROOTS.packageTest, sources.packageTest.includes('buildV44EconomicDomainModel')), + predicateResult('package-json-exposes-gate2', SOURCE_ROOTS.packageJson, sources.packageJson.includes('"generate:v44-economic-domain-model"') && sources.packageJson.includes('"check:v44-gate2"')), + predicateResult('gate-workflow-runs-gate2', SOURCE_ROOTS.gateWorkflow, sources.gateWorkflow.includes('check-v44-gate2-economic-domain-model.mjs')), + predicateResult('canon-workflow-runs-gate2', SOURCE_ROOTS.canonWorkflow, sources.canonWorkflow.includes('check-v44-gate2-economic-domain-model.mjs')), + predicateResult('generator-exists', SOURCE_ROOTS.generator, sources.generator.includes('buildV44EconomicDomainModel')), + predicateResult('checker-exists', SOURCE_ROOTS.checker, sources.checker.includes('V44 Gate 2 economic domain model check')), + ]; +} + +export function buildV44EconomicDomainModel(options = {}) { + const repoRoot = options.repoRoot || DEFAULT_REPO_ROOT; + const predicateResults = buildPredicateResults(repoRoot); + const failedPredicateIds = predicateResults + .filter((predicate) => !predicate.passed) + .map((predicate) => predicate.id); + const sourceRoots = Object.fromEntries( + Object.entries(SOURCE_ROOTS).map(([key, sourcePath]) => [key, `${sourcePath}:${digest(readSource(repoRoot, sourcePath))}`]), + ); + const artifactRoot = `v44-economic-domain-model:${digest(JSON.stringify({ + economicObjectIds: V44_ECONOMIC_OBJECT_IDS, + receiptTaxonomyIds: V44_ECONOMIC_RECEIPT_TAXONOMY_IDS, + valueLabelIds: V44_ECONOMIC_VALUE_LABEL_IDS, + sourceSafeFieldIds: V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS, + rowIds: V44_ECONOMIC_DOMAIN_ROWS.map((row) => row.objectId), + sourceRoots, + failedPredicateIds, + }))}`; + + return { + artifactId: 'v44-economic-domain-model', + schemaId: V44_ECONOMIC_DOMAIN_MODEL_SCHEMA_ID, + version: V44_ECONOMIC_DOMAIN_MODEL_VERSION, + currentTarget: V44_ECONOMIC_DOMAIN_MODEL_CURRENT_TARGET, + sourceSafetyVerdict: V44_ECONOMIC_DOMAIN_MODEL_SOURCE_SAFETY_VERDICT, + generatedAt: 'deterministic', + artifactRoot, + passed: failedPredicateIds.length === 0, + economicObjectIds: [...V44_ECONOMIC_OBJECT_IDS], + receiptTaxonomyIds: [...V44_ECONOMIC_RECEIPT_TAXONOMY_IDS], + valueLabelIds: [...V44_ECONOMIC_VALUE_LABEL_IDS], + sourceSafeFieldIds: [...V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS], + forbiddenPayloadIds: [...V44_ECONOMIC_FORBIDDEN_PAYLOAD_IDS], + domainRows: V44_ECONOMIC_DOMAIN_ROWS.map((row) => ({ + ...row, + rowRoot: `v44-economic-domain-row:${digest(row.objectId)}`, + sourceSafeMetadataOnly: true, + protectedSourceVisible: false, + unpaidAssetPackSourceVisible: false, + valueBearingMainnetAdmitted: false, + })), + sourceRoots, + predicateResults, + coverage: { + economicObjectsModeled: V44_ECONOMIC_OBJECT_IDS.length === V44_ECONOMIC_DOMAIN_ROWS.length, + receiptTaxonomyModeled: V44_ECONOMIC_RECEIPT_TAXONOMY_IDS.length === 10, + valueLabelsComplete: V44_ECONOMIC_VALUE_LABEL_IDS.length === 7, + portfolioPositionCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('portfolio-position')), + marketSignalsCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('market-signal')), + quoteStatesCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('quote-state')), + settlementStatesCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('settlement-state')), + compensationStatementsCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('compensation-statement')), + governanceDecisionsCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('governance-decision')), + repairCasesCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('repair-case')), + budgetPoliciesCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('budget-policy')), + supplyOpportunitiesCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('supply-opportunity')), + networkRehearsalCovered: V44_ECONOMIC_DOMAIN_ROWS.some((row) => row.receiptTaxonomyIds.includes('network-rehearsal')), + sourceSafeMetadataOnly: true, + protectedSourceVisible: false, + rawSourceTextVisible: false, + sourceSnippetVisible: false, + rawPromptVisible: false, + interpolatedPromptVisible: false, + rawProviderResponseVisible: false, + unpaidAssetPackSourceVisible: false, + credentialsSerialized: false, + walletPrivateMaterialVisible: false, + settlementPrivatePayloadVisible: false, + valueBearingMainnetAdmitted: false, + requiredPredicateCount: predicateResults.length, + passedPredicateCount: predicateResults.length - failedPredicateIds.length, + failedPredicateIds, + }, + }; +} + +export const V44_ECONOMIC_DOMAIN_MODEL_SOURCE_ROOTS = Object.freeze( + Object.fromEntries(Object.entries(SOURCE_ROOTS).map(([key, sourcePath]) => [key, sourceRoot(sourcePath)])), +); diff --git a/packages/protocol/src/index.d.ts b/packages/protocol/src/index.d.ts index 05accb7f..ec3134f0 100644 --- a/packages/protocol/src/index.d.ts +++ b/packages/protocol/src/index.d.ts @@ -682,6 +682,19 @@ export const V43_PROMOTION_READINESS_GATE_ARTIFACT_PATHS: readonly string[]; export const V43_PROMOTION_READINESS_GENERATED_OUTPUTS: readonly string[]; export function buildV43PromotionReadinessReport(input?: Record): BitcodeProtocolReport; export function listMissingV43PromotionReadinessSources(repoRoot?: string): string[]; +export const V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH: string; +export const V44_ECONOMIC_DOMAIN_MODEL_CURRENT_TARGET: string; +export const V44_ECONOMIC_DOMAIN_MODEL_SCHEMA_ID: string; +export const V44_ECONOMIC_DOMAIN_MODEL_VERSION: string; +export const V44_ECONOMIC_DOMAIN_MODEL_SOURCE_SAFETY_VERDICT: string; +export const V44_ECONOMIC_DOMAIN_MODEL_SOURCE_ROOTS: Readonly>; +export const V44_ECONOMIC_OBJECT_IDS: readonly string[]; +export const V44_ECONOMIC_RECEIPT_TAXONOMY_IDS: readonly string[]; +export const V44_ECONOMIC_VALUE_LABEL_IDS: readonly string[]; +export const V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS: readonly string[]; +export const V44_ECONOMIC_FORBIDDEN_PAYLOAD_IDS: readonly string[]; +export const V44_ECONOMIC_DOMAIN_ROWS: readonly Record[]; +export function buildV44EconomicDomainModel(input?: Record): BitcodeProtocolReport; export const EXCHANGE_INTENT_ORDER_CONTRACTS_ARTIFACT_PATH: string; export const EXCHANGE_INTENT_ORDER_CONTRACTS_CURRENT_TARGET: string; export const EXCHANGE_INTENT_ORDER_CONTRACTS_SCHEMA_ID: string; diff --git a/packages/protocol/src/index.js b/packages/protocol/src/index.js index e6929c71..33d7a37b 100644 --- a/packages/protocol/src/index.js +++ b/packages/protocol/src/index.js @@ -774,6 +774,21 @@ export { buildV43PromotionReadinessReport, listMissingV43PromotionReadinessSources } from './canonical/v43-promotion-readiness-report.js'; +export { + V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH, + V44_ECONOMIC_DOMAIN_MODEL_CURRENT_TARGET, + V44_ECONOMIC_DOMAIN_MODEL_SCHEMA_ID, + V44_ECONOMIC_DOMAIN_MODEL_SOURCE_ROOTS, + V44_ECONOMIC_DOMAIN_MODEL_SOURCE_SAFETY_VERDICT, + V44_ECONOMIC_DOMAIN_MODEL_VERSION, + V44_ECONOMIC_DOMAIN_ROWS, + V44_ECONOMIC_FORBIDDEN_PAYLOAD_IDS, + V44_ECONOMIC_OBJECT_IDS, + V44_ECONOMIC_RECEIPT_TAXONOMY_IDS, + V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS, + V44_ECONOMIC_VALUE_LABEL_IDS, + buildV44EconomicDomainModel +} from './canonical/v44-economic-domain-model.js'; export { EXCHANGE_INTENT_ACTION_KINDS, EXCHANGE_INTENT_ORDER_CONTRACTS_ARTIFACT_PATH, diff --git a/packages/protocol/test/v44-economic-domain-model.test.js b/packages/protocol/test/v44-economic-domain-model.test.js new file mode 100644 index 00000000..de06304f --- /dev/null +++ b/packages/protocol/test/v44-economic-domain-model.test.js @@ -0,0 +1,70 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { + V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH, + V44_ECONOMIC_DOMAIN_MODEL_SCHEMA_ID, + V44_ECONOMIC_DOMAIN_MODEL_SOURCE_SAFETY_VERDICT, + V44_ECONOMIC_DOMAIN_ROWS, + V44_ECONOMIC_OBJECT_IDS, + V44_ECONOMIC_RECEIPT_TAXONOMY_IDS, + V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS, + V44_ECONOMIC_VALUE_LABEL_IDS, + buildV44EconomicDomainModel, +} from '../src/canonical/v44-economic-domain-model.js'; + +test('V44 economic domain model binds source-safe objects, receipts, and value labels', () => { + const report = buildV44EconomicDomainModel(); + + assert.equal(V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH, '.bitcode/v44-economic-domain-model.json'); + assert.equal(report.artifactId, 'v44-economic-domain-model'); + assert.equal(report.schemaId, V44_ECONOMIC_DOMAIN_MODEL_SCHEMA_ID); + assert.equal(report.version, 'V44'); + assert.equal(report.currentTarget, 'V43'); + assert.equal(report.sourceSafetyVerdict, V44_ECONOMIC_DOMAIN_MODEL_SOURCE_SAFETY_VERDICT); + assert.ok(report.artifactRoot.startsWith('v44-economic-domain-model:')); + assert.deepEqual(report.economicObjectIds, [...V44_ECONOMIC_OBJECT_IDS]); + assert.deepEqual(report.receiptTaxonomyIds, [...V44_ECONOMIC_RECEIPT_TAXONOMY_IDS]); + assert.deepEqual(report.valueLabelIds, [...V44_ECONOMIC_VALUE_LABEL_IDS]); + assert.deepEqual(report.sourceSafeFieldIds, [...V44_ECONOMIC_SOURCE_SAFE_FIELD_IDS]); + assert.equal(report.domainRows.length, V44_ECONOMIC_DOMAIN_ROWS.length); + assert.equal(report.coverage.economicObjectsModeled, true); + assert.equal(report.coverage.receiptTaxonomyModeled, true); + assert.equal(report.coverage.valueLabelsComplete, true); + assert.equal(report.coverage.portfolioPositionCovered, true); + assert.equal(report.coverage.marketSignalsCovered, true); + assert.equal(report.coverage.quoteStatesCovered, true); + assert.equal(report.coverage.settlementStatesCovered, true); + assert.equal(report.coverage.compensationStatementsCovered, true); + assert.equal(report.coverage.governanceDecisionsCovered, true); + assert.equal(report.coverage.repairCasesCovered, true); + assert.equal(report.coverage.budgetPoliciesCovered, true); + assert.equal(report.coverage.supplyOpportunitiesCovered, true); + assert.equal(report.coverage.networkRehearsalCovered, true); + assert.equal(report.coverage.sourceSafeMetadataOnly, true); + assert.equal(report.coverage.protectedSourceVisible, false); + assert.equal(report.coverage.unpaidAssetPackSourceVisible, false); + assert.equal(report.coverage.rawPromptVisible, false); + assert.equal(report.coverage.interpolatedPromptVisible, false); + assert.equal(report.coverage.rawProviderResponseVisible, false); + assert.equal(report.coverage.credentialsSerialized, false); + assert.equal(report.coverage.walletPrivateMaterialVisible, false); + assert.equal(report.coverage.settlementPrivatePayloadVisible, false); + assert.equal(report.coverage.valueBearingMainnetAdmitted, false); +}); + +test('V44 economic domain rows do not serialize protected source or value-bearing mainnet admission', () => { + const report = buildV44EconomicDomainModel(); + + for (const row of report.domainRows) { + assert.equal(row.sourceSafeMetadataOnly, true); + assert.equal(row.protectedSourceVisible, false); + assert.equal(row.unpaidAssetPackSourceVisible, false); + assert.equal(row.valueBearingMainnetAdmitted, false); + assert.ok(Array.isArray(row.receiptTaxonomyIds)); + assert.ok(row.receiptTaxonomyIds.length > 0); + assert.ok(Array.isArray(row.valueLabelIds)); + assert.ok(row.valueLabelIds.length > 0); + assert.ok(Array.isArray(row.privateFieldsNeverSerialized)); + assert.ok(row.privateFieldsNeverSerialized.length > 0); + } +}); diff --git a/scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs b/scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs index 814fe77d..a5c8b634 100644 --- a/scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs +++ b/scripts/check-v44-gate1-scaled-economy-roadmap-opening.mjs @@ -139,7 +139,7 @@ function main() { } assertCheck(failures, roadmap.includes('Current active canonical pointer: `BITCODE_SPEC.txt` -> `V43`'), 'Roadmap must state V43 active pointer.'); - assertCheck(failures, roadmap.includes('Current working gate: V44 Gate 1'), 'Roadmap must state active V44 Gate 1 work.'); + assertCheck(failures, /Current working gate: V44 Gate (?:1|2|3|4|5|6|7|8|9|10)\b/u.test(roadmap), 'Roadmap must state active V44 gate progression.'); assertCheck(failures, roadmap.includes('| V44 | `BITCODE_SPEC_V44.md` | active draft target |'), 'Roadmap must list V44 as active draft target.'); assertCheck(failures, readme.includes('resolves to `V43`; V44 is the active draft target'), 'README must state V43 active / V44 draft posture.'); assertCheck(failures, protocolReadme.includes('V44 Gate 1') && protocolReadme.includes('V43` active, `V44` draft'), 'Protocol README must document V44 Gate 1 active/draft posture.'); diff --git a/scripts/check-v44-gate2-economic-domain-model.mjs b/scripts/check-v44-gate2-economic-domain-model.mjs new file mode 100644 index 00000000..9397d270 --- /dev/null +++ b/scripts/check-v44-gate2-economic-domain-model.mjs @@ -0,0 +1,172 @@ +#!/usr/bin/env node + +import { execFileSync } from 'node:child_process'; +import { existsSync, readFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { + V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH, + buildV44EconomicDomainModel, +} from '../packages/protocol/src/canonical/v44-economic-domain-model.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const defaultRepoRoot = path.resolve(__dirname, '..'); + +function read(root, relativePath) { + return readFileSync(path.join(root, relativePath), 'utf8'); +} + +function exists(root, relativePath) { + return existsSync(path.join(root, relativePath)); +} + +function git(root, args) { + return execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim(); +} + +function assertCheck(failures, condition, message) { + if (!condition) failures.push(message); +} + +function run(root, command, args) { + execFileSync(command, args, { cwd: root, stdio: 'pipe', encoding: 'utf8' }); +} + +function parseArgs(argv) { + const args = { repoRoot: defaultRepoRoot, skipBranchCheck: false, skipPackageTests: false }; + for (let index = 0; index < argv.length; index += 1) { + const arg = argv[index]; + if (arg === '--repo-root') args.repoRoot = path.resolve(argv[++index]); + else if (arg === '--skip-branch-check') args.skipBranchCheck = true; + else if (arg === '--skip-package-tests') args.skipPackageTests = true; + else if (arg === '--help' || arg === '-h') args.help = true; + else throw new Error(`Unknown argument ${arg}`); + } + return args; +} + +function printHelp() { + process.stdout.write( + [ + 'Usage: node scripts/check-v44-gate2-economic-domain-model.mjs [--skip-branch-check] [--skip-package-tests] [--repo-root ]', + '', + 'V44 Gate 2 economic domain model check: validates source-safe economic object contracts, receipt taxonomy, generated artifact freshness, package exports, documentation, workflow wiring, and focused tests.', + ].join('\n'), + ); + process.stdout.write('\n'); +} + +function main() { + const args = parseArgs(process.argv.slice(2)); + if (args.help) { + printHelp(); + return; + } + + const root = args.repoRoot; + const failures = []; + const pointer = read(root, 'BITCODE_SPEC.txt').trim(); + + assertCheck(failures, pointer === 'V43', `BITCODE_SPEC.txt must remain V43 during V44 gate work. Observed ${pointer || 'empty'}.`); + + if (!args.skipBranchCheck) { + const branch = git(root, ['branch', '--show-current']); + assertCheck( + failures, + branch === 'version/v44' || /^v44\/gate-\d+-[a-z0-9][a-z0-9-]*$/u.test(branch), + `V44 work must occur on version/v44 or v44/gate-N-* branches. Observed ${branch || 'detached HEAD'}.`, + ); + } + + for (const relativePath of [ + V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH, + 'packages/protocol/src/canonical/v44-economic-domain-model.js', + 'packages/protocol/test/v44-economic-domain-model.test.js', + 'scripts/generate-v44-economic-domain-model.mjs', + 'scripts/check-v44-gate2-economic-domain-model.mjs', + 'BITCODE_SPEC_V44.md', + 'BITCODE_SPEC_V44_DELTA.md', + 'BITCODE_SPEC_V44_NOTES.md', + 'BITCODE_SPEC_V44_PARITY_MATRIX.md', + 'SPECIFICATIONS_ROADMAP.md', + 'README.md', + 'packages/protocol/README.md', + '.github/workflows/bitcode-gate-quality.yml', + '.github/workflows/bitcode-canon-quality.yml', + 'package.json', + ]) { + assertCheck(failures, exists(root, relativePath), `Missing required V44 Gate 2 file: ${relativePath}`); + } + + const artifact = buildV44EconomicDomainModel({ repoRoot: root }); + assertCheck(failures, artifact.passed, `V44 economic domain predicates failed: ${artifact.coverage.failedPredicateIds.join(', ')}`); + assertCheck(failures, artifact.coverage.economicObjectsModeled === true, 'Economic objects must be modeled.'); + assertCheck(failures, artifact.coverage.receiptTaxonomyModeled === true, 'Receipt taxonomy must be modeled.'); + assertCheck(failures, artifact.coverage.valueLabelsComplete === true, 'Value labels must be complete.'); + assertCheck(failures, artifact.coverage.portfolioPositionCovered === true, 'Portfolio positions must be covered.'); + assertCheck(failures, artifact.coverage.marketSignalsCovered === true, 'Market signals must be covered.'); + assertCheck(failures, artifact.coverage.quoteStatesCovered === true, 'Quote states must be covered.'); + assertCheck(failures, artifact.coverage.settlementStatesCovered === true, 'Settlement states must be covered.'); + assertCheck(failures, artifact.coverage.compensationStatementsCovered === true, 'Compensation statements must be covered.'); + assertCheck(failures, artifact.coverage.governanceDecisionsCovered === true, 'Governance decisions must be covered.'); + assertCheck(failures, artifact.coverage.repairCasesCovered === true, 'Repair cases must be covered.'); + assertCheck(failures, artifact.coverage.sourceSafeMetadataOnly === true, 'Artifact must be source-safe metadata only.'); + assertCheck(failures, artifact.coverage.protectedSourceVisible === false, 'Artifact must not expose protected source.'); + assertCheck(failures, artifact.coverage.unpaidAssetPackSourceVisible === false, 'Artifact must not expose unpaid AssetPack source.'); + assertCheck(failures, artifact.coverage.rawPromptVisible === false, 'Artifact must not expose raw prompts.'); + assertCheck(failures, artifact.coverage.interpolatedPromptVisible === false, 'Artifact must not expose interpolated prompts.'); + assertCheck(failures, artifact.coverage.rawProviderResponseVisible === false, 'Artifact must not expose raw provider responses.'); + assertCheck(failures, artifact.coverage.credentialsSerialized === false, 'Artifact must not serialize credentials.'); + assertCheck(failures, artifact.coverage.walletPrivateMaterialVisible === false, 'Artifact must not expose wallet private material.'); + assertCheck(failures, artifact.coverage.settlementPrivatePayloadVisible === false, 'Artifact must not expose private settlement payloads.'); + assertCheck(failures, artifact.coverage.valueBearingMainnetAdmitted === false, 'Gate 2 must not admit value-bearing mainnet operation.'); + + const serialized = `${JSON.stringify(artifact, null, 2)}\n`; + assertCheck( + failures, + exists(root, V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH) && + read(root, V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH) === serialized, + `${V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH} must be generated and current.`, + ); + + const packageJson = read(root, 'package.json'); + const gateWorkflow = read(root, '.github/workflows/bitcode-gate-quality.yml'); + const canonWorkflow = read(root, '.github/workflows/bitcode-canon-quality.yml'); + assertCheck(failures, packageJson.includes('"generate:v44-economic-domain-model"'), 'package.json must expose generate:v44-economic-domain-model.'); + assertCheck(failures, packageJson.includes('"check:v44-economic-domain-model"'), 'package.json must expose check:v44-economic-domain-model.'); + assertCheck(failures, packageJson.includes('"check:v44-gate2"'), 'package.json must expose check:v44-gate2.'); + assertCheck(failures, gateWorkflow.includes('check-v44-gate2-economic-domain-model.mjs'), 'Gate workflow must run V44 Gate 2 checker.'); + assertCheck(failures, canonWorkflow.includes('check-v44-gate2-economic-domain-model.mjs'), 'Canon workflow must run V44 Gate 2 checker.'); + + try { + run(root, 'node', ['scripts/generate-v44-economic-domain-model.mjs', '--check']); + } catch { + failures.push('V44 economic domain model artifact must be fresh.'); + } + + if (!args.skipPackageTests) { + try { + run(root, 'pnpm', ['--dir', 'packages/protocol', 'exec', 'node', '--test', '--test-force-exit', 'test/v44-economic-domain-model.test.js']); + } catch { + failures.push('packages/protocol/test/v44-economic-domain-model.test.js must pass.'); + } + } + + if (failures.length > 0) { + process.stderr.write('V44 Gate 2 economic domain model check failed:\n'); + for (const failure of failures.filter(Boolean)) process.stderr.write(`- ${failure}\n`); + process.exitCode = 1; + return; + } + + process.stdout.write('V44 Gate 2 economic domain model check passed.\n'); +} + +try { + main(); +} catch (error) { + const detail = error instanceof Error ? error.message : String(error); + process.stderr.write(`${detail}\n`); + process.exitCode = 1; +} diff --git a/scripts/generate-v44-economic-domain-model.mjs b/scripts/generate-v44-economic-domain-model.mjs new file mode 100644 index 00000000..480bb3fe --- /dev/null +++ b/scripts/generate-v44-economic-domain-model.mjs @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { + V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH, + buildV44EconomicDomainModel, +} from '../packages/protocol/src/canonical/v44-economic-domain-model.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const repoRoot = path.resolve(__dirname, '..'); +const checkOnly = process.argv.includes('--check'); +const artifact = buildV44EconomicDomainModel({ repoRoot }); +const serialized = `${JSON.stringify(artifact, null, 2)}\n`; +const artifactPath = path.join(repoRoot, V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH); + +if (checkOnly) { + if (!existsSync(artifactPath) || readFileSync(artifactPath, 'utf8') !== serialized) { + process.stderr.write( + `${V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH} is stale. Run pnpm run generate:v44-economic-domain-model.\n`, + ); + process.exitCode = 1; + } +} else { + mkdirSync(path.dirname(artifactPath), { recursive: true }); + writeFileSync(artifactPath, serialized); + process.stdout.write(`wrote ${V44_ECONOMIC_DOMAIN_MODEL_ARTIFACT_PATH}\n`); +}