{
  "schemaVersion": "0.5.0",
  "type": "RuntimeLedgerSpec",
  "status": "active",
  "deliverableId": "runtime-ledger",
  "ledgerEnabledAfterDeployment": true,
  "eventSchema": "https://gautierdorval.com/runtime-ledger-event.schema.json",
  "metricsContract": "https://gautierdorval.com/runtime-ledger-metrics.json",
  "dataPolicy": "https://gautierdorval.com/runtime-data-policy.json",
  "transportAdr": "data/runtime/adr/runtime-ledger-transport.json",
  "resourceInventory": {
    "status": "production-schema-0002-gate1-snapshot",
    "temporalScope": "historical_gate1_snapshot",
    "currentDeploymentExcluded": true,
    "authorizedHead": "b08192249fc34e9b77c1d2e8656404c3ce635cbc",
    "capturedAt": null,
    "captureTimeState": "not_attributable_from_preserved_evidence",
    "preview": {
      "observedAt": "2026-07-24T18:25:58Z",
      "observationTimeState": "resource_specific_observation",
      "d1": {
        "name": "gautierdorval-runtime-ledger-preview",
        "databaseId": "492a5c86-56f3-4915-be7b-1cc01c72e7b8",
        "createdAt": "2026-07-16T00:33:38.883Z"
      },
      "queue": {
        "name": "gautierdorval-runtime-ledger-preview",
        "resourceId": "0d8878d3d2034e1f8170b993aa41c2c6",
        "createdAt": "2026-07-16T00:32:47.337409Z",
        "observedMessageRetentionSeconds": 28800,
        "targetMessageRetentionSeconds": 28800,
        "retentionCompliant": true
      },
      "deadLetterQueue": {
        "name": "gautierdorval-runtime-ledger-preview-dlq",
        "resourceId": "70ed3c89f940412e9602990f2bd231be",
        "createdAt": "2026-07-16T00:33:29.965657Z",
        "observedMessageRetentionSeconds": 28800,
        "targetMessageRetentionSeconds": 28800,
        "retentionCompliant": true
      },
      "schemaState": {
        "appliedMigrations": [
          "0001_runtime_ledger_aggregate_only",
          "0002_runtime_ledger_idempotency_integrity"
        ],
        "eventFingerprintColumnPresent": true,
        "temporaryIngestHealthTablePresent": false,
        "runtimeSchemaMeta0002Present": true,
        "d1Migrations0002Present": true,
        "state": "applied_complete"
      },
      "observedState": {
        "runtimeTableCount": 5,
        "d1MigrationsTablePresent": true,
        "appliedMigrationCount": 2,
        "queueProducers": 1,
        "queueConsumers": 1,
        "deadLetterQueueProducers": 0,
        "deadLetterQueueConsumers": 0,
        "resolverWorkerExists": true,
        "resolverDeploymentId": "04a133fb-cb4a-4c0f-898b-58c348dbf29c",
        "resolverVersionId": "ba54f4e9-d1a0-4412-b5f9-a76b2cf1dfb2",
        "resolverSourceCommit": "54aa659bccc09dcf3f2078a87418e428badec15f",
        "resolverLedgerEnabled": false,
        "writerWorkerExists": true,
        "writerDeploymentId": "e5a414af-0007-4e42-bba4-de53bf3decf5",
        "writerVersionId": "189572a1-1d5f-4173-b25f-1f1d8652936b",
        "writerSourceCommit": "54aa659bccc09dcf3f2078a87418e428badec15f",
        "writerEnabled": false,
        "writerSecretCount": 0,
        "writerCronCount": 0,
        "writerRouteCount": 0,
        "writerWorkersDevEnabled": false,
        "writerPreviewUrlsEnabled": false
      }
    },
    "production": {
      "observedAt": null,
      "observationTimeState": "not_attributable_from_preserved_evidence",
      "d1": {
        "name": "gautierdorval-runtime-ledger",
        "databaseId": "7c25c670-bbfc-46bb-906c-84648a5e5ced",
        "createdAt": "2026-07-16T00:34:05.122Z"
      },
      "queue": {
        "name": "gautierdorval-runtime-ledger",
        "resourceId": "cba730b328ee4512af2d805df624b445",
        "createdAt": "2026-07-16T00:33:47.779263Z",
        "observedMessageRetentionSeconds": 28800,
        "targetMessageRetentionSeconds": 28800,
        "retentionCompliant": true
      },
      "deadLetterQueue": {
        "name": "gautierdorval-runtime-ledger-dlq",
        "resourceId": "cfc4df86fb4d4266b8ba9eb7673375da",
        "createdAt": "2026-07-16T00:33:56.247779Z",
        "observedMessageRetentionSeconds": 28800,
        "targetMessageRetentionSeconds": 28800,
        "retentionCompliant": true
      },
      "schemaState": {
        "appliedMigrations": [
          "0001_runtime_ledger_aggregate_only",
          "0002_runtime_ledger_idempotency_integrity"
        ],
        "eventFingerprintColumnPresent": true,
        "temporaryIngestHealthTablePresent": false,
        "runtimeSchemaMeta0002Present": true,
        "d1Migrations0002Present": true,
        "state": "applied_complete"
      },
      "observedState": {
        "runtimeTableCount": 5,
        "d1MigrationsTablePresent": true,
        "appliedMigrationCount": 2,
        "queueProducers": 1,
        "queueConsumers": 1,
        "deadLetterQueueProducers": 0,
        "deadLetterQueueConsumers": 0,
        "resolverWorkerExists": true,
        "resolverDeploymentId": "5044405a-5cf8-4b3f-a561-37e19bfbc98b",
        "resolverVersionId": "00aaabd1-4f72-4758-92b2-be37a0cf3adf",
        "resolverSourceCommit": "140d75e6b9a76587a15465c906ba6fdaef3a81b6",
        "resolverLedgerEnabled": true,
        "writerWorkerExists": true,
        "writerDeploymentId": "2feb656c-e405-4101-b024-cf85bf894146",
        "writerVersionId": "26f0318b-aa76-40e2-a1f1-994230e25821",
        "writerSourceCommit": "978c9fd6e788b4cc45aaf7a094cc08e88fdec5ed",
        "writerEnabled": true,
        "writerSecretCount": 2,
        "writerCronCount": 1,
        "writerRouteCount": 0,
        "writerWorkersDevEnabled": false,
        "writerPreviewUrlsEnabled": false
      }
    }
  },
  "components": {
    "producer": {
      "componentId": "runtime-resolver",
      "binding": "RUNTIME_LEDGER_QUEUE",
      "activationBinding": "RUNTIME_LEDGER_ENABLED",
      "activationValue": "true",
      "defaultActivationState": "disabled",
      "schedulingPrimitive": "ctx.waitUntil",
      "failureEffect": "preserve_primary_runtime_response",
      "persistentBindings": []
    },
    "writer": {
      "componentId": "runtime-ledger-writer",
      "implementationPath": "runtime-ledger-worker/",
      "publicExposure": "internal-only",
      "queueConsumerBinding": "RUNTIME_LEDGER_QUEUE",
      "activationBinding": "RUNTIME_LEDGER_WRITER_ENABLED",
      "activationValue": "true",
      "defaultActivationState": "disabled",
      "disabledMessageEffect": "ack_without_persistence",
      "databaseBinding": "D1_RUNTIME_LEDGER",
      "outboundEmailProvider": "Resend"
    }
  },
  "persistence": {
    "databaseKind": "dedicated_cloudflare_d1",
    "rawEventJournal": false,
    "dailyAggregateRetentionDays": 400,
    "opaqueDedupeRetentionDays": 2,
    "opaqueDedupeRetentionHours": 48,
    "eventFingerprint": {
      "column": "event_fingerprint",
      "canonicalFormat": "sha-256:<64_lowercase_hex>",
      "acceptedStoredValues": "canonical_fingerprint_or_legacy_marker",
      "legacyMarker": "legacy-unfingerprinted",
      "retentionDays": 2,
      "legacyPayloadReconstructed": false
    },
    "deliveryStateRetentionDays": 45,
    "timeZone": "UTC"
  },
  "migration": {
    "file": "runtime-ledger-worker/migrations/0001_runtime_ledger_aggregate_only.sql",
    "sha256": "28f1b90892520244dd29d72648da29ce7eb271219acdc4aaa70491bb44a130e2",
    "schemaVersion": "0001_runtime_ledger_aggregate_only",
    "databaseBinding": "D1_RUNTIME_LEDGER"
  },
  "migrationHistory": [
    {
      "file": "runtime-ledger-worker/migrations/0001_runtime_ledger_aggregate_only.sql",
      "sha256": "28f1b90892520244dd29d72648da29ce7eb271219acdc4aaa70491bb44a130e2",
      "schemaVersion": "0001_runtime_ledger_aggregate_only",
      "databaseBinding": "D1_RUNTIME_LEDGER",
      "state": "applied_preview_and_production"
    },
    {
      "file": "runtime-ledger-worker/migrations/0002_runtime_ledger_idempotency_integrity.sql",
      "sha256": "bd25c0c2461d7746e8db133d919096d9af14e2554b01777ed1bbdecd32d71789",
      "schemaVersion": "0002_runtime_ledger_idempotency_integrity",
      "databaseBinding": "D1_RUNTIME_LEDGER",
      "state": "applied_preview_and_production"
    }
  ],
  "schemaReconciliation": {
    "record": "data/runtime/activation/runtime-ledger-idempotency-migration-record.json",
    "recordSha256": "3dd6ba389c994d9daa3594c2dd1a15869d9b2bcf52d48a4a5e4ab1634b7f7ebe",
    "recordStatus": "schema_applied_candidate_pending",
    "temporalScope": "historical_gate1_record",
    "followedByPromotionRecord": "data/runtime/activation/runtime-ledger-idempotency-promotion-record.json",
    "baselineActivationRecordPreserved": true,
    "historical0001Preserved": true,
    "declarativeStateOnly": true,
    "requiresExactVersionedGoForPromotion": true
  },
  "gate1CandidateSnapshot": {
    "temporalScope": "historical_gate1_snapshot",
    "followedByPromotionRecord": "data/runtime/activation/runtime-ledger-idempotency-promotion-record.json",
    "workerName": "gautierdorval-runtime-ledger",
    "versionId": "5f81e447-580b-4c1b-beb7-8150a75f26b8",
    "versionNumber": 7,
    "createdAt": "2026-07-24T19:22:08.126903Z",
    "sourceCommit": "b08192249fc34e9b77c1d2e8656404c3ce635cbc",
    "sourceTree": "7af9407e0a400fe320c08f2970550bad68895904",
    "writerEnabled": true,
    "databaseId": "7c25c670-bbfc-46bb-906c-84648a5e5ced",
    "status": "uploaded_not_deployed",
    "receivesTraffic": false,
    "gate1EvidenceManifestSha256": "82fcb9a7b6e93af876a2edc0f8f0e44a3c21519032a5f3aa2f377b3d58524167"
  },
  "deploymentReconciliation": {
    "record": "data/runtime/activation/runtime-ledger-idempotency-promotion-record.json",
    "recordSha256": "35a0b73deb510839c8c46e4e45f102060e668d770a1245018d3a0bcd22810a18",
    "recordStatus": "deployed_active",
    "observedAt": "2026-07-25T22:51:28.8944126Z",
    "historicalGate1RecordPreserved": true,
    "declarativeStateOnly": true,
    "standingAuthorizationForFutureMutation": false
  },
  "currentDeployment": {
    "workerName": "gautierdorval-runtime-ledger",
    "deploymentId": "ee9f10fb-f455-4d61-9455-03119f5f8b57",
    "deployedAt": "2026-07-24T21:23:51.294766Z",
    "versionId": "5f81e447-580b-4c1b-beb7-8150a75f26b8",
    "versionNumber": 7,
    "versionCreatedAt": "2026-07-24T19:22:08.126903Z",
    "sourceCommit": "b08192249fc34e9b77c1d2e8656404c3ce635cbc",
    "sourceTree": "7af9407e0a400fe320c08f2970550bad68895904",
    "writerEnabled": true,
    "databaseId": "7c25c670-bbfc-46bb-906c-84648a5e5ced",
    "activePercentage": 100,
    "status": "deployed_active",
    "receivesTraffic": true,
    "observationMethod": "cloudflare_control_plane_read_only",
    "observedAt": "2026-07-25T22:51:28.8944126Z"
  },
  "functionalOutcomeObservation": {
    "record": "data/runtime/ledger/runtime-ledger-functional-outcome-observation.json",
    "recordSha256": "71155478587ea37a7828c215126d24282983f692c3c209eafba2a3186473b645",
    "recordStatus": "candidate_pending_independent_audit",
    "capturedAt": "2026-08-07T16:52:28Z",
    "captureMethod": "cloudflare_d1_remote_select_only",
    "acceptedPath": {
      "windowStart": "2026-07-25",
      "windowEndInclusive": "2026-08-06",
      "windowBasis": "complete_utc_dates_only",
      "verificationSqlState": "bounded_query_not_executed_in_original_capture",
      "excludedPartialCaptureDate": "2026-08-07",
      "excludedPartialCaptureDateState": "retained_in_daily_snapshot_only_not_in_bounded_parity_window",
      "acceptedHits": 1091,
      "rollupHits": 1091,
      "delta": 0,
      "observedDays": 13,
      "mismatchDays": 0,
      "observationState": "accepted_path_aggregate_parity_observed",
      "replayLimitation": "future_reruns_can_verify_current_aggregate_parity_for_the_literal_window_but_cannot_reconstruct_capture_time_state_if_historical_aggregates_are_rewritten"
    },
    "reportDelivery": {
      "reportRows": 20,
      "sentRows": 20,
      "failedRows": 0,
      "providerErrorRows": 0,
      "throughReportDate": "2026-08-06",
      "observationState": "sent_only_delivery_state_observed"
    },
    "closedOutcomeBoundary": {
      "accepted": "observed",
      "duplicate": "historical_pre_0002_only",
      "duplicateUnverifiableLegacy": "not_observed_after_0002",
      "conflictingEventId": "not_observed_after_0002",
      "invalidEvent": "not_observed_after_0002"
    },
    "historicalSkewPreserved": true,
    "independentAuditStatus": "pending",
    "declarativeStateOnly": true,
    "standingAuthorizationForFutureMutation": false
  },
  "delivery": {
    "queueGuarantee": "at_least_once",
    "idempotency": "event_id_plus_payload_fingerprint",
    "activeWriterSemantics": "event_id_plus_payload_fingerprint",
    "activeWriterAtomicity": "dedupe_rollup_ingest_health_single_d1_batch",
    "classificationExerciseState": "accepted_and_report_paths_observed_strict_outcomes_not_observed_after_0002",
    "mainQueueRetentionHours": 8,
    "deadLetterQueueRetentionHours": 8,
    "maximumRedrives": 1,
    "maximumTransportResidenceHours": 24,
    "maximumAcceptedEventAgeHours": 24,
    "consumerBatchMaximum": 20,
    "consumerRetryMaximum": 5,
    "deadLetterQueueRequired": true
  },
  "report": {
    "scheduleUtc": "15 11 * * *",
    "range": "previous_utc_day",
    "retainedTrendDays": 30,
    "recipientBinding": "REPORT_TO",
    "emailSecret": "RESEND_API_KEY",
    "html": true,
    "plainText": true,
    "aggregateJsonAttachment": true,
    "rawEventAttachment": false
  },
  "activationGate": {
    "implementationPresent": true,
    "explicitProducerKillSwitch": true,
    "producerKillSwitchDefault": "disabled",
    "explicitWriterKillSwitch": true,
    "writerKillSwitchDefault": "disabled",
    "shutdownOrder": "producer_off_queue_drained_writer_off",
    "resourceIdentifiersPinned": true,
    "d1MigrationPresent": true,
    "productionActivationState": "active",
    "activationRecord": "data/runtime/activation/runtime-ledger-production-activation-record.json",
    "activationRecordSha256": "69a1a6637c6a0df2a2821b4b97d2624f763a3c73a1a1d524f40485108efaa7d9",
    "declarativeStateOnly": true,
    "requiresExactVersionedGo": true
  },
  "nonGuarantees": [
    "The ledger measures runtime HTTP distribution events only.",
    "The ledger does not prove model training, retrieval, citation, recommendation or response use.",
    "The ledger does not establish the identity of a human requester.",
    "A deployed classification capability does not prove that every closed outcome has been observed in production."
  ]
}
