@feltdb/core 0.13.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-runtime.d.ts +64 -2
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +121 -11
- package/dist/agent-state.d.ts +68 -0
- package/dist/agent-state.d.ts.map +1 -1
- package/dist/agent-state.js +210 -12
- package/dist/agent.d.ts +10 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +10 -1
- package/dist/build-identity.json +12 -4
- package/dist/cli/commands.js +214 -10
- package/dist/cli/publish-engine.js +116 -16
- package/dist/collection.d.ts +3 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +33 -8
- package/dist/create/build-identity.json +12 -4
- package/dist/create/cli.js +1 -1
- package/dist/create/create.js +4 -6
- package/dist/create/managed-account.js +93 -35
- package/dist/create/package-versions.js +1 -1
- package/dist/create/server-source/Cargo.lock +8 -511
- package/dist/create/server-source/Cargo.toml +2 -13
- package/dist/create/server-source/crates/feltdb-client/Cargo.toml +1 -1
- package/dist/create/server-source/crates/feltdb-server/Cargo.toml +1 -1
- package/dist/create/server-source/crates/feltdb-server/README.md +6 -1
- package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +9 -1
- package/dist/create/server-source/crates/feltdb-server/src/auth.rs +85 -25
- package/dist/create/server-source/crates/feltdb-server/src/backup.rs +4 -0
- package/dist/create/server-source/crates/feltdb-server/src/console_accounts.rs +1009 -0
- package/dist/create/server-source/crates/feltdb-server/src/control_authorization.rs +441 -0
- package/dist/create/server-source/crates/feltdb-server/src/identity.rs +68 -6
- package/dist/create/server-source/crates/feltdb-server/src/key_management.rs +355 -23
- package/dist/create/server-source/crates/feltdb-server/src/lib.rs +3 -0
- package/dist/create/server-source/crates/feltdb-server/src/main.rs +1134 -96
- package/dist/create/server-source/crates/feltdb-server/src/redaction.rs +208 -0
- package/dist/create/server-source/crates/feltdb-server/src/tenancy.rs +198 -19
- package/dist/create/server-source/crates/feltdb-server/tests/transaction_precondition_contract.rs +403 -0
- package/dist/create/server-source/crates/feltdb-wasm/Cargo.toml +1 -1
- package/dist/db.d.ts +75 -10
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +168 -29
- package/dist/deployment.d.ts +19 -0
- package/dist/deployment.d.ts.map +1 -1
- package/dist/deployment.js +38 -2
- package/dist/embedded-query.d.ts.map +1 -1
- package/dist/embedded-query.js +5 -4
- package/dist/embedded-transaction.d.ts +8 -4
- package/dist/embedded-transaction.d.ts.map +1 -1
- package/dist/embedded-transaction.js +55 -19
- package/dist/error-codes.d.ts +36 -2
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +50 -3
- package/dist/feltdb.d.ts +7 -0
- package/dist/feltdb.d.ts.map +1 -1
- package/dist/file-db.d.ts +27 -0
- package/dist/file-db.d.ts.map +1 -1
- package/dist/file-db.js +145 -7
- package/dist/http-client.d.ts +11 -3
- package/dist/http-client.d.ts.map +1 -1
- package/dist/http-client.js +27 -14
- package/dist/http-db.d.ts +43 -1
- package/dist/http-db.d.ts.map +1 -1
- package/dist/http-db.js +287 -59
- package/dist/index.js +1 -1
- package/dist/local-state-lock.d.ts +34 -0
- package/dist/local-state-lock.d.ts.map +1 -0
- package/dist/local-state-lock.js +225 -0
- package/dist/managed-recovery.d.ts +6 -0
- package/dist/managed-recovery.d.ts.map +1 -1
- package/dist/managed-recovery.js +9 -0
- package/dist/reactive-graph.d.ts +0 -3
- package/dist/reactive-graph.d.ts.map +1 -1
- package/dist/reactive-graph.js +11 -1
- package/dist/runtime-registry.d.ts +7 -2
- package/dist/runtime-registry.d.ts.map +1 -1
- package/dist/runtime-registry.js +2 -2
- package/dist/studio/components/index.js +1 -1
- package/dist/studio/{components-BSGmHfif.js → components-CJmzntBi.js} +2 -1
- package/dist/studio/index.js +1 -1
- package/dist/studio-app/assets/{feltdb_wasm-3hDngl1h.js → feltdb_wasm-DtybUY0q.js} +1 -1
- package/dist/studio-app/assets/feltdb_wasm_bg-DsgIUwaB.wasm +0 -0
- package/dist/studio-app/assets/index-C4OffsZl.js +37 -0
- package/dist/studio-app/index.html +1 -1
- package/dist/transaction.d.ts +27 -11
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +20 -14
- package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
- package/dist/wasm/package.json +1 -1
- package/dist/workload.d.ts +86 -6
- package/dist/workload.d.ts.map +1 -1
- package/dist/workload.js +51 -3
- package/dist/workspace/workspace-connection.d.ts.map +1 -1
- package/dist/workspace/workspace-connection.js +14 -3
- package/package.json +1 -1
- package/dist/create/server-source/crates/feltdb/Cargo.lock +0 -175
- package/dist/create/server-source/crates/feltdb/Cargo.toml +0 -102
- package/dist/create/server-source/crates/feltdb/LICENSE +0 -21
- package/dist/create/server-source/crates/feltdb/README.md +0 -75
- package/dist/create/server-source/crates/feltdb/benches/baselines/gate-13-redux.json +0 -370
- package/dist/create/server-source/crates/feltdb/benches/gate13_baseline.rs +0 -589
- package/dist/create/server-source/crates/feltdb/benches/gate13_phase_7_1_release_economics.rs +0 -247
- package/dist/create/server-source/crates/feltdb/benches/gate_13_redux.rs +0 -440
- package/dist/create/server-source/crates/feltdb/benches/gate_13_regression_runner.rs +0 -275
- package/dist/create/server-source/crates/feltdb/benches/gate_14a_concurrent_writer_scaling.rs +0 -381
- package/dist/create/server-source/crates/feltdb/benches/gate_14a_production_admission_revalidation.rs +0 -467
- package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc2_admission_contract.rs +0 -489
- package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc_root_cause.rs +0 -281
- package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync1_queued_prototype.rs +0 -606
- package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync_economics.rs +0 -531
- package/dist/create/server-source/crates/feltdb/benches/gate_14b_causal_backlog_scaling.rs +0 -462
- package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_contract_test.rs +0 -505
- package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_scaling.rs +0 -484
- package/dist/create/server-source/crates/feltdb/benches/gate_14d_combined_dimension_scaling.rs +0 -758
- package/dist/create/server-source/crates/feltdb/benches/phase_7_1_2_optimization_benchmark.rs +0 -421
- package/dist/create/server-source/crates/feltdb/benches/phase_7_1_3_crossover_analysis.rs +0 -329
- package/dist/create/server-source/crates/feltdb/src/acceptance_tests.rs +0 -1705
- package/dist/create/server-source/crates/feltdb/src/acquisition.rs +0 -286
- package/dist/create/server-source/crates/feltdb/src/admission.rs +0 -185
- package/dist/create/server-source/crates/feltdb/src/admission_contract_tests.rs +0 -507
- package/dist/create/server-source/crates/feltdb/src/adversarial_transport.rs +0 -539
- package/dist/create/server-source/crates/feltdb/src/agent_state.rs +0 -320
- package/dist/create/server-source/crates/feltdb/src/agent_transition_contract.rs +0 -1545
- package/dist/create/server-source/crates/feltdb/src/analytics.rs +0 -521
- package/dist/create/server-source/crates/feltdb/src/application.rs +0 -2674
- package/dist/create/server-source/crates/feltdb/src/application_runtime.rs +0 -1070
- package/dist/create/server-source/crates/feltdb/src/authority.rs +0 -479
- package/dist/create/server-source/crates/feltdb/src/authority_failover.rs +0 -847
- package/dist/create/server-source/crates/feltdb/src/authorization.rs +0 -1030
- package/dist/create/server-source/crates/feltdb/src/authorization_security_tests.rs +0 -1122
- package/dist/create/server-source/crates/feltdb/src/bin/feltdb-authority-client.rs +0 -32
- package/dist/create/server-source/crates/feltdb/src/bin/feltdb-authority.rs +0 -19
- package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +0 -1474
- package/dist/create/server-source/crates/feltdb/src/capabilities/mod.rs +0 -8
- package/dist/create/server-source/crates/feltdb/src/capabilities/search.rs +0 -418
- package/dist/create/server-source/crates/feltdb/src/capabilities/vector.rs +0 -482
- package/dist/create/server-source/crates/feltdb/src/capability.rs +0 -903
- package/dist/create/server-source/crates/feltdb/src/cardinality_diagnostics.rs +0 -263
- package/dist/create/server-source/crates/feltdb/src/cardinality_endpoint.rs +0 -77
- package/dist/create/server-source/crates/feltdb/src/causal_backlog_bound.rs +0 -496
- package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier.rs +0 -2574
- package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier_phase_7_1.rs +0 -212
- package/dist/create/server-source/crates/feltdb/src/concurrency_fuzzing.rs +0 -422
- package/dist/create/server-source/crates/feltdb/src/consistency_contract.rs +0 -445
- package/dist/create/server-source/crates/feltdb/src/content_distribution.rs +0 -465
- package/dist/create/server-source/crates/feltdb/src/convergence.rs +0 -634
- package/dist/create/server-source/crates/feltdb/src/crash_atomic_boundary.rs +0 -427
- package/dist/create/server-source/crates/feltdb/src/crash_injection.rs +0 -376
- package/dist/create/server-source/crates/feltdb/src/crash_recovery_tests.rs +0 -365
- package/dist/create/server-source/crates/feltdb/src/cron.rs +0 -294
- package/dist/create/server-source/crates/feltdb/src/dedup_bound_investigation.rs +0 -483
- package/dist/create/server-source/crates/feltdb/src/distributed_indexing.rs +0 -477
- package/dist/create/server-source/crates/feltdb/src/distributed_tests.rs +0 -1003
- package/dist/create/server-source/crates/feltdb/src/distributed_transactions.rs +0 -1334
- package/dist/create/server-source/crates/feltdb/src/durability_guarantees.rs +0 -368
- package/dist/create/server-source/crates/feltdb/src/durable_dedup_set.rs +0 -231
- package/dist/create/server-source/crates/feltdb/src/durable_operation_identity.rs +0 -482
- package/dist/create/server-source/crates/feltdb/src/durable_operation_log.rs +0 -203
- package/dist/create/server-source/crates/feltdb/src/durable_sync.rs +0 -317
- package/dist/create/server-source/crates/feltdb/src/equality_index.rs +0 -595
- package/dist/create/server-source/crates/feltdb/src/execution.rs +0 -426
- package/dist/create/server-source/crates/feltdb/src/in_process_transport.rs +0 -214
- package/dist/create/server-source/crates/feltdb/src/indexing.rs +0 -776
- package/dist/create/server-source/crates/feltdb/src/lib.rs +0 -7274
- package/dist/create/server-source/crates/feltdb/src/managed_cas_tests.rs +0 -234
- package/dist/create/server-source/crates/feltdb/src/materialization.rs +0 -184
- package/dist/create/server-source/crates/feltdb/src/metrics.rs +0 -266
- package/dist/create/server-source/crates/feltdb/src/multi_node_convergence.rs +0 -310
- package/dist/create/server-source/crates/feltdb/src/multi_operation_transaction.rs +0 -736
- package/dist/create/server-source/crates/feltdb/src/observability.rs +0 -379
- package/dist/create/server-source/crates/feltdb/src/operation.rs +0 -290
- package/dist/create/server-source/crates/feltdb/src/operation_algebra.rs +0 -439
- package/dist/create/server-source/crates/feltdb/src/operation_log.rs +0 -349
- package/dist/create/server-source/crates/feltdb/src/p1_application_atomicity.rs +0 -332
- package/dist/create/server-source/crates/feltdb/src/p1_atomicity_acceptance.rs +0 -718
- package/dist/create/server-source/crates/feltdb/src/partition_reconciliation.rs +0 -487
- package/dist/create/server-source/crates/feltdb/src/peer_registry.rs +0 -166
- package/dist/create/server-source/crates/feltdb/src/permutation_scheduler.rs +0 -289
- package/dist/create/server-source/crates/feltdb/src/persistence_reality.rs +0 -566
- package/dist/create/server-source/crates/feltdb/src/phase1b_acceptance.rs +0 -3391
- package/dist/create/server-source/crates/feltdb/src/phase1c1_acceptance.rs +0 -203
- package/dist/create/server-source/crates/feltdb/src/phase1c2_acceptance.rs +0 -261
- package/dist/create/server-source/crates/feltdb/src/phase1c3_acceptance.rs +0 -502
- package/dist/create/server-source/crates/feltdb/src/phase1c_atomicity_proof.rs +0 -216
- package/dist/create/server-source/crates/feltdb/src/phase5_integration.rs +0 -303
- package/dist/create/server-source/crates/feltdb/src/phase5_scenarios.rs +0 -323
- package/dist/create/server-source/crates/feltdb/src/phase6_adversarial_scenarios.rs +0 -531
- package/dist/create/server-source/crates/feltdb/src/phase6_convergence_validator.rs +0 -406
- package/dist/create/server-source/crates/feltdb/src/phase6_persistence.rs +0 -436
- package/dist/create/server-source/crates/feltdb/src/phase_1c_real_tcp.rs +0 -387
- package/dist/create/server-source/crates/feltdb/src/phase_2a_failures.rs +0 -378
- package/dist/create/server-source/crates/feltdb/src/phase_2b_network.rs +0 -359
- package/dist/create/server-source/crates/feltdb/src/phase_2c_cascading.rs +0 -372
- package/dist/create/server-source/crates/feltdb/src/phase_3_durability.rs +0 -404
- package/dist/create/server-source/crates/feltdb/src/phase_4_baseline.rs +0 -376
- package/dist/create/server-source/crates/feltdb/src/phase_5_soak.rs +0 -461
- package/dist/create/server-source/crates/feltdb/src/policy_evaluation.rs +0 -2125
- package/dist/create/server-source/crates/feltdb/src/production_api.rs +0 -418
- package/dist/create/server-source/crates/feltdb/src/provenance.rs +0 -207
- package/dist/create/server-source/crates/feltdb/src/query_execution_diagnostics.rs +0 -126
- package/dist/create/server-source/crates/feltdb/src/query_performance.rs +0 -218
- package/dist/create/server-source/crates/feltdb/src/read_basis.rs +0 -257
- package/dist/create/server-source/crates/feltdb/src/references.rs +0 -404
- package/dist/create/server-source/crates/feltdb/src/replay_fuzzing.rs +0 -401
- package/dist/create/server-source/crates/feltdb/src/replica_acknowledgements.rs +0 -501
- package/dist/create/server-source/crates/feltdb/src/replica_membership.rs +0 -680
- package/dist/create/server-source/crates/feltdb/src/replication_manager.rs +0 -163
- package/dist/create/server-source/crates/feltdb/src/replication_protocol.rs +0 -133
- package/dist/create/server-source/crates/feltdb/src/routing.rs +0 -409
- package/dist/create/server-source/crates/feltdb/src/semantic_decision.rs +0 -2029
- package/dist/create/server-source/crates/feltdb/src/semantic_query.rs +0 -599
- package/dist/create/server-source/crates/feltdb/src/sharding.rs +0 -549
- package/dist/create/server-source/crates/feltdb/src/state_conflict_contract.rs +0 -516
- package/dist/create/server-source/crates/feltdb/src/state_contract.rs +0 -5894
- package/dist/create/server-source/crates/feltdb/src/state_diff_contract.rs +0 -222
- package/dist/create/server-source/crates/feltdb/src/state_facade.rs +0 -320
- package/dist/create/server-source/crates/feltdb/src/state_hash.rs +0 -291
- package/dist/create/server-source/crates/feltdb/src/state_model.rs +0 -4158
- package/dist/create/server-source/crates/feltdb/src/state_transition_store.rs +0 -379
- package/dist/create/server-source/crates/feltdb/src/state_trigger.rs +0 -673
- package/dist/create/server-source/crates/feltdb/src/storage.rs +0 -273
- package/dist/create/server-source/crates/feltdb/src/submission.rs +0 -471
- package/dist/create/server-source/crates/feltdb/src/sync.rs +0 -495
- package/dist/create/server-source/crates/feltdb/src/sync_contract.rs +0 -822
- package/dist/create/server-source/crates/feltdb/src/tcp_transport.rs +0 -433
- package/dist/create/server-source/crates/feltdb/src/transaction_api.rs +0 -462
- package/dist/create/server-source/crates/feltdb/src/transaction_invariants.rs +0 -965
- package/dist/create/server-source/crates/feltdb/src/transaction_preconditions.rs +0 -1120
- package/dist/create/server-source/crates/feltdb/src/transactions.rs +0 -643
- package/dist/create/server-source/crates/feltdb/src/trigger.rs +0 -390
- package/dist/create/server-source/crates/feltdb/src/trigger_contract.rs +0 -749
- package/dist/create/server-source/crates/feltdb/src/versioned_object_substrate.rs +0 -708
- package/dist/create/server-source/crates/feltdb/src/worker_mesh.rs +0 -1133
- package/dist/create/server-source/crates/feltdb/src/workflow.rs +0 -713
- package/dist/create/server-source/crates/feltdb/src/workflow_acceptance_tests.rs +0 -510
- package/dist/create/server-source/crates/feltdb/src/workflow_integration.rs +0 -354
- package/dist/create/server-source/crates/feltdb/src/workflow_runtime.rs +0 -594
- package/dist/create/server-source/crates/feltdb/src/workload.rs +0 -2886
- package/dist/create/server-source/crates/feltdb/src/workload_diagnostics.rs +0 -456
- package/dist/create/server-source/crates/feltdb/tests/agent_state_native.rs +0 -1188
- package/dist/create/server-source/crates/feltdb/tests/agent_transition_contract_conformance.rs +0 -2884
- package/dist/create/server-source/crates/feltdb/tests/authority_process.rs +0 -297
- package/dist/create/server-source/crates/feltdb/tests/authority_transaction_identity.rs +0 -534
- package/dist/create/server-source/crates/feltdb/tests/bounded_read_contract.rs +0 -132
- package/dist/create/server-source/crates/feltdb/tests/branching_evidence.rs +0 -299
- package/dist/create/server-source/crates/feltdb/tests/common/mod.rs +0 -96
- package/dist/create/server-source/crates/feltdb/tests/compaction_stall_contract.rs +0 -272
- package/dist/create/server-source/crates/feltdb/tests/crash_durability_contract.rs +0 -467
- package/dist/create/server-source/crates/feltdb/tests/current_revision_authority_evidence.rs +0 -309
- package/dist/create/server-source/crates/feltdb/tests/durable_backup_contract.rs +0 -445
- package/dist/create/server-source/crates/feltdb/tests/durable_corruption_contract.rs +0 -518
- package/dist/create/server-source/crates/feltdb/tests/durable_format_compatibility.rs +0 -392
- package/dist/create/server-source/crates/feltdb/tests/feltdb_state_boundary_tests.rs +0 -850
- package/dist/create/server-source/crates/feltdb/tests/fixtures/agent_transition_corpus.json +0 -23340
- package/dist/create/server-source/crates/feltdb/tests/fixtures/state_conflict_contract_corpus.json +0 -1916
- package/dist/create/server-source/crates/feltdb/tests/fixtures/state_diff_contract_corpus.json +0 -1878
- package/dist/create/server-source/crates/feltdb/tests/fixtures/trigger_contract_corpus.json +0 -1862
- package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_evidence.rs +0 -123
- package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +0 -299
- package/dist/create/server-source/crates/feltdb/tests/local_process_ownership.rs +0 -69
- package/dist/create/server-source/crates/feltdb/tests/managed_incident_regression.rs +0 -191
- package/dist/create/server-source/crates/feltdb/tests/operational_health_contract.rs +0 -278
- package/dist/create/server-source/crates/feltdb/tests/pr34_query_collection.rs +0 -234
- package/dist/create/server-source/crates/feltdb/tests/pr35_equality_index.rs +0 -947
- package/dist/create/server-source/crates/feltdb/tests/pr7_self_authorization_proof.rs +0 -404
- package/dist/create/server-source/crates/feltdb/tests/pr8_vocabulary_assessment.rs +0 -916
- package/dist/create/server-source/crates/feltdb/tests/pr9_phase2_boundary_tests.rs +0 -1045
- package/dist/create/server-source/crates/feltdb/tests/pr9_phase3a_path_a_tests.rs +0 -347
- package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_authorized_mutations.rs +0 -361
- package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_role_based_authorization.rs +0 -330
- package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_simple_auth_delete.rs +0 -93
- package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_team_delete_role_authorization.rs +0 -622
- package/dist/create/server-source/crates/feltdb/tests/pr9_teams_role_based_access.rs +0 -517
- package/dist/create/server-source/crates/feltdb/tests/production_certification.rs +0 -1153
- package/dist/create/server-source/crates/feltdb/tests/production_contract.rs +0 -771
- package/dist/create/server-source/crates/feltdb/tests/production_readiness_contract.rs +0 -1383
- package/dist/create/server-source/crates/feltdb/tests/reconciliation_application.rs +0 -868
- package/dist/create/server-source/crates/feltdb/tests/reconciliation_wire_format_evidence.rs +0 -221
- package/dist/create/server-source/crates/feltdb/tests/replicated_history_contract.rs +0 -417
- package/dist/create/server-source/crates/feltdb/tests/resource_scoped_revisions.rs +0 -338
- package/dist/create/server-source/crates/feltdb/tests/revision_identity_contract.rs +0 -1039
- package/dist/create/server-source/crates/feltdb/tests/revision_model_decision.rs +0 -739
- package/dist/create/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +0 -452
- package/dist/create/server-source/crates/feltdb/tests/saas_authorization_integration.rs +0 -81
- package/dist/create/server-source/crates/feltdb/tests/saas_invitation_lifecycle.rs +0 -438
- package/dist/create/server-source/crates/feltdb/tests/semantic_decision.rs +0 -1165
- package/dist/create/server-source/crates/feltdb/tests/semantic_query.rs +0 -767
- package/dist/create/server-source/crates/feltdb/tests/semantic_query_contract.rs +0 -363
- package/dist/create/server-source/crates/feltdb/tests/state_conflict_contract_conformance.rs +0 -1799
- package/dist/create/server-source/crates/feltdb/tests/state_diff_contract_conformance.rs +0 -1316
- package/dist/create/server-source/crates/feltdb/tests/state_model_integration.rs +0 -358
- package/dist/create/server-source/crates/feltdb/tests/state_persistence_integration.rs +0 -365
- package/dist/create/server-source/crates/feltdb/tests/state_ref_authority.rs +0 -918
- package/dist/create/server-source/crates/feltdb/tests/state_store_boundary_evidence.rs +0 -299
- package/dist/create/server-source/crates/feltdb/tests/storage_independent_versioned_object_substrate.rs +0 -328
- package/dist/create/server-source/crates/feltdb/tests/sync_divergence_evidence.rs +0 -255
- package/dist/create/server-source/crates/feltdb/tests/three_way_input_boundary_evidence.rs +0 -249
- package/dist/create/server-source/crates/feltdb/tests/trigger_contract_conformance.rs +0 -994
- package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +0 -484
- package/dist/studio-app/assets/feltdb_wasm_bg-CFQT4gCy.wasm +0 -0
- package/dist/studio-app/assets/index-Dql1hS5m.js +0 -30
|
@@ -1,718 +0,0 @@
|
|
|
1
|
-
//! Production Gate P1 — Multi-Operation Atomicity Acceptance
|
|
2
|
-
//!
|
|
3
|
-
//! The gate asserts one property, adversarially:
|
|
4
|
-
//!
|
|
5
|
-
//! ```text
|
|
6
|
-
//! COMMIT -> A + B + C all visible
|
|
7
|
-
//! FAIL or CRASH -> A + B + C none visible
|
|
8
|
-
//! never -> A visible, B visible, C missing
|
|
9
|
-
//! ```
|
|
10
|
-
//!
|
|
11
|
-
//! Every test here restarts a node from its durable log and inspects what
|
|
12
|
-
//! recovery produced. Nothing asserts on in-memory state that survived a
|
|
13
|
-
//! simulated crash, because in a real crash it would not have.
|
|
14
|
-
|
|
15
|
-
#[cfg(test)]
|
|
16
|
-
mod tests {
|
|
17
|
-
use crate::multi_operation_transaction::*;
|
|
18
|
-
use serde_json::json;
|
|
19
|
-
use std::collections::HashSet;
|
|
20
|
-
use tempfile::TempDir;
|
|
21
|
-
|
|
22
|
-
/// A three-operation transaction: the canonical A + B + C.
|
|
23
|
-
fn abc(transaction_id: &str) -> Vec<TransactionOperation> {
|
|
24
|
-
vec![
|
|
25
|
-
TransactionOperation::set("accounts", "A", json!({ "balance": 100 })),
|
|
26
|
-
TransactionOperation::set("accounts", "B", json!({ "balance": 200 })),
|
|
27
|
-
TransactionOperation::set("accounts", "C", json!({ "balance": 300 })),
|
|
28
|
-
]
|
|
29
|
-
.into_iter()
|
|
30
|
-
.map(|mut operation| {
|
|
31
|
-
operation.record_id = format!("{}-{}", operation.record_id, transaction_id);
|
|
32
|
-
operation
|
|
33
|
-
})
|
|
34
|
-
.collect()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/// How many of a transaction's records are present after recovery.
|
|
38
|
-
fn visible(node: &TransactionalNode, record: &TransactionRecord) -> usize {
|
|
39
|
-
node.executor().visible_operations(record)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/// The gate's core assertion: all of them, or none of them.
|
|
43
|
-
fn assert_atomic(node: &TransactionalNode, record: &TransactionRecord, context: &str) -> bool {
|
|
44
|
-
let seen = visible(node, record);
|
|
45
|
-
let total = record.operations.len();
|
|
46
|
-
assert!(
|
|
47
|
-
seen == 0 || seen == total,
|
|
48
|
-
"{}: transaction was partially visible ({} of {} operations)",
|
|
49
|
-
context,
|
|
50
|
-
seen,
|
|
51
|
-
total
|
|
52
|
-
);
|
|
53
|
-
seen == total
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ---------------------------------------------------------------- normal
|
|
57
|
-
|
|
58
|
-
#[test]
|
|
59
|
-
fn commit_makes_every_operation_visible() -> Result<(), Box<dyn std::error::Error>> {
|
|
60
|
-
let dir = TempDir::new()?;
|
|
61
|
-
let (mut node, _) = TransactionalNode::open(dir.path().join("tx.log"), "node1")?;
|
|
62
|
-
|
|
63
|
-
let record = node.build("tx1", abc("tx1"));
|
|
64
|
-
assert_eq!(node.commit(&record)?, ApplyOutcome::Applied);
|
|
65
|
-
|
|
66
|
-
assert_eq!(visible(&node, &record), 3);
|
|
67
|
-
assert!(assert_atomic(&node, &record, "after commit"));
|
|
68
|
-
Ok(())
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
#[test]
|
|
72
|
-
fn a_rejected_transaction_leaves_no_trace() -> Result<(), Box<dyn std::error::Error>> {
|
|
73
|
-
let dir = TempDir::new()?;
|
|
74
|
-
let path = dir.path().join("tx.log");
|
|
75
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
76
|
-
|
|
77
|
-
// The middle operation cannot succeed: the record does not exist.
|
|
78
|
-
let operations = vec![
|
|
79
|
-
TransactionOperation::set("accounts", "A", json!({ "balance": 1 })),
|
|
80
|
-
TransactionOperation::set("accounts", "B", json!({ "balance": 2 }))
|
|
81
|
-
.requiring(Precondition::MustExist),
|
|
82
|
-
TransactionOperation::set("accounts", "C", json!({ "balance": 3 })),
|
|
83
|
-
];
|
|
84
|
-
let record = node.build("tx-reject", operations);
|
|
85
|
-
|
|
86
|
-
match node.commit(&record)? {
|
|
87
|
-
ApplyOutcome::Rejected(RejectionReason::PreconditionFailed {
|
|
88
|
-
operation_index, ..
|
|
89
|
-
}) => {
|
|
90
|
-
assert_eq!(operation_index, 1);
|
|
91
|
-
}
|
|
92
|
-
other => panic!("expected a precondition rejection, got {:?}", other),
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// A rejected transaction must leave nothing behind, including the
|
|
96
|
-
// operations that were legal on their own.
|
|
97
|
-
assert_eq!(visible(&node, &record), 0, "no operation may be visible");
|
|
98
|
-
assert!(
|
|
99
|
-
node.state().get_record("accounts", "A").is_none(),
|
|
100
|
-
"A must not be applied"
|
|
101
|
-
);
|
|
102
|
-
assert!(
|
|
103
|
-
node.state().get_record("accounts", "C").is_none(),
|
|
104
|
-
"C must not be applied"
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
drop(node);
|
|
108
|
-
let (restarted, report) = TransactionalNode::open(&path, "node1")?;
|
|
109
|
-
assert!(
|
|
110
|
-
report.committed.is_empty(),
|
|
111
|
-
"a rejected transaction must never be logged"
|
|
112
|
-
);
|
|
113
|
-
assert!(restarted.state().get_record("accounts", "A").is_none());
|
|
114
|
-
Ok(())
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
#[test]
|
|
118
|
-
fn a_transaction_writing_one_record_twice_is_refused() -> Result<(), Box<dyn std::error::Error>>
|
|
119
|
-
{
|
|
120
|
-
let dir = TempDir::new()?;
|
|
121
|
-
let (mut node, _) = TransactionalNode::open(dir.path().join("tx.log"), "node1")?;
|
|
122
|
-
|
|
123
|
-
let record = node.build(
|
|
124
|
-
"tx-conflict",
|
|
125
|
-
vec![
|
|
126
|
-
TransactionOperation::set("accounts", "A", json!({ "balance": 1 })),
|
|
127
|
-
TransactionOperation::set("accounts", "A", json!({ "balance": 2 })),
|
|
128
|
-
],
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
assert!(matches!(
|
|
132
|
-
node.commit(&record)?,
|
|
133
|
-
ApplyOutcome::Rejected(RejectionReason::ConflictingWritesWithinTransaction { .. })
|
|
134
|
-
));
|
|
135
|
-
Ok(())
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ----------------------------------------------------------------- crash
|
|
139
|
-
|
|
140
|
-
/// Every crash point, on a fresh node, recovered from disk.
|
|
141
|
-
///
|
|
142
|
-
/// This is the heart of the gate.
|
|
143
|
-
#[test]
|
|
144
|
-
fn every_crash_point_leaves_the_transaction_atomic() -> Result<(), Box<dyn std::error::Error>> {
|
|
145
|
-
let crash_points = vec![
|
|
146
|
-
CrashPoint::BeforeWrite,
|
|
147
|
-
CrashPoint::DuringWrite { keep_percent: 10 },
|
|
148
|
-
CrashPoint::DuringWrite { keep_percent: 50 },
|
|
149
|
-
CrashPoint::DuringWrite { keep_percent: 90 },
|
|
150
|
-
CrashPoint::AfterWriteBeforeFsync,
|
|
151
|
-
CrashPoint::AfterFsyncBeforeApply,
|
|
152
|
-
CrashPoint::DuringApply {
|
|
153
|
-
after_operations: 1,
|
|
154
|
-
},
|
|
155
|
-
CrashPoint::DuringApply {
|
|
156
|
-
after_operations: 2,
|
|
157
|
-
},
|
|
158
|
-
CrashPoint::AfterApply,
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
for crash in crash_points {
|
|
162
|
-
let dir = TempDir::new()?;
|
|
163
|
-
let path = dir.path().join("tx.log");
|
|
164
|
-
|
|
165
|
-
let record = {
|
|
166
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
167
|
-
let record = node.build("tx-crash", abc("tx-crash"));
|
|
168
|
-
node.commit_with_crash(&record, &crash)?;
|
|
169
|
-
record
|
|
170
|
-
// The node is dropped here: the process died.
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
let (recovered, report) = TransactionalNode::open(&path, "node1")?;
|
|
174
|
-
let context = format!("crash at {:?}", crash);
|
|
175
|
-
let fully_visible = assert_atomic(&recovered, &record, &context);
|
|
176
|
-
|
|
177
|
-
match &crash {
|
|
178
|
-
// Nothing durable was written, so nothing may be visible.
|
|
179
|
-
CrashPoint::BeforeWrite | CrashPoint::DuringWrite { .. } => {
|
|
180
|
-
assert!(!fully_visible, "{}: nothing should have committed", context);
|
|
181
|
-
assert!(
|
|
182
|
-
report.committed.is_empty(),
|
|
183
|
-
"{}: log must hold no record",
|
|
184
|
-
context
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
// The record was fsynced, so recovery must replay all of it —
|
|
188
|
-
// including when the crash happened part-way through applying.
|
|
189
|
-
CrashPoint::AfterFsyncBeforeApply
|
|
190
|
-
| CrashPoint::DuringApply { .. }
|
|
191
|
-
| CrashPoint::AfterApply => {
|
|
192
|
-
assert!(
|
|
193
|
-
fully_visible,
|
|
194
|
-
"{}: a committed transaction must fully recover",
|
|
195
|
-
context
|
|
196
|
-
);
|
|
197
|
-
assert_eq!(report.committed.len(), 1, "{}", context);
|
|
198
|
-
}
|
|
199
|
-
// Written but not fsynced: the operating system decides. Either
|
|
200
|
-
// outcome is correct; a partial one is not, and assert_atomic
|
|
201
|
-
// already ruled that out.
|
|
202
|
-
CrashPoint::AfterWriteBeforeFsync => {}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
Ok(())
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
#[test]
|
|
209
|
-
fn a_torn_final_record_is_discarded_and_the_log_stays_writable(
|
|
210
|
-
) -> Result<(), Box<dyn std::error::Error>> {
|
|
211
|
-
let dir = TempDir::new()?;
|
|
212
|
-
let path = dir.path().join("tx.log");
|
|
213
|
-
|
|
214
|
-
// One good transaction, then a crash mid-write on the next.
|
|
215
|
-
let first = {
|
|
216
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
217
|
-
let first = node.build("tx1", abc("tx1"));
|
|
218
|
-
node.commit(&first)?;
|
|
219
|
-
let second = node.build("tx2", abc("tx2"));
|
|
220
|
-
node.commit_with_crash(&second, &CrashPoint::DuringWrite { keep_percent: 60 })?;
|
|
221
|
-
first
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// Recovery keeps the committed transaction and discards the torn one.
|
|
225
|
-
let (mut node, report) = TransactionalNode::open(&path, "node1")?;
|
|
226
|
-
assert_eq!(report.committed.len(), 1);
|
|
227
|
-
assert!(matches!(
|
|
228
|
-
report.discarded_tail,
|
|
229
|
-
Some(LogDefect::TornTail { .. })
|
|
230
|
-
));
|
|
231
|
-
assert_eq!(visible(&node, &first), 3);
|
|
232
|
-
|
|
233
|
-
// The torn bytes were truncated, so a later write cannot splice onto
|
|
234
|
-
// them and turn a recoverable tail into interior corruption.
|
|
235
|
-
let third = node.build("tx3", abc("tx3"));
|
|
236
|
-
node.commit(&third)?;
|
|
237
|
-
drop(node);
|
|
238
|
-
|
|
239
|
-
let (again, report) = TransactionalNode::open(&path, "node1")?;
|
|
240
|
-
assert!(
|
|
241
|
-
report.discarded_tail.is_none(),
|
|
242
|
-
"the log must be clean after truncation"
|
|
243
|
-
);
|
|
244
|
-
assert_eq!(report.committed.len(), 2);
|
|
245
|
-
assert_eq!(visible(&again, &first), 3);
|
|
246
|
-
assert_eq!(visible(&again, &third), 3);
|
|
247
|
-
Ok(())
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
#[test]
|
|
251
|
-
fn interior_corruption_is_refused_rather_than_guessed() -> Result<(), Box<dyn std::error::Error>>
|
|
252
|
-
{
|
|
253
|
-
let dir = TempDir::new()?;
|
|
254
|
-
let path = dir.path().join("tx.log");
|
|
255
|
-
|
|
256
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
257
|
-
let first = node.build("tx1", abc("tx1"));
|
|
258
|
-
node.commit(&first)?;
|
|
259
|
-
let second = node.build("tx2", abc("tx2"));
|
|
260
|
-
node.commit(&second)?;
|
|
261
|
-
|
|
262
|
-
// Damage a byte inside the first record. It is not the final entry, so
|
|
263
|
-
// this is corruption, not an interrupted write.
|
|
264
|
-
node.log().corrupt_at(20, b"X")?;
|
|
265
|
-
drop(node);
|
|
266
|
-
|
|
267
|
-
let outcome = TransactionalNode::open(&path, "node1");
|
|
268
|
-
assert!(
|
|
269
|
-
outcome.is_err(),
|
|
270
|
-
"recovery must refuse a corrupted interior record"
|
|
271
|
-
);
|
|
272
|
-
let message = outcome
|
|
273
|
-
.err()
|
|
274
|
-
.map(|error| error.to_string())
|
|
275
|
-
.unwrap_or_default();
|
|
276
|
-
assert!(
|
|
277
|
-
message.contains("corrupted"),
|
|
278
|
-
"unexpected error: {}",
|
|
279
|
-
message
|
|
280
|
-
);
|
|
281
|
-
Ok(())
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
#[test]
|
|
285
|
-
fn a_checksum_mismatch_is_not_treated_as_committed() -> Result<(), Box<dyn std::error::Error>> {
|
|
286
|
-
let mut record = TransactionRecord::new("tx1", "node1", 1, abc("tx1"));
|
|
287
|
-
assert!(record.verify_checksum());
|
|
288
|
-
|
|
289
|
-
// Alter the body without recomputing the checksum, as a partial write
|
|
290
|
-
// or a bit flip would.
|
|
291
|
-
record.operations.push(TransactionOperation::set(
|
|
292
|
-
"accounts",
|
|
293
|
-
"D",
|
|
294
|
-
json!({ "balance": 9 }),
|
|
295
|
-
));
|
|
296
|
-
assert!(
|
|
297
|
-
!record.verify_checksum(),
|
|
298
|
-
"a mutated record must fail its integrity check"
|
|
299
|
-
);
|
|
300
|
-
Ok(())
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ---------------------------------------------------------------- replay
|
|
304
|
-
|
|
305
|
-
#[test]
|
|
306
|
-
fn replaying_a_committed_transaction_changes_nothing() -> Result<(), Box<dyn std::error::Error>>
|
|
307
|
-
{
|
|
308
|
-
let dir = TempDir::new()?;
|
|
309
|
-
let (mut node, _) = TransactionalNode::open(dir.path().join("tx.log"), "node1")?;
|
|
310
|
-
|
|
311
|
-
let record = node.build("tx1", abc("tx1"));
|
|
312
|
-
node.commit(&record)?;
|
|
313
|
-
let hash_after_first = node.state().hash().as_hex().to_string();
|
|
314
|
-
|
|
315
|
-
// Deliver the same transaction repeatedly.
|
|
316
|
-
for _ in 0..5 {
|
|
317
|
-
assert_eq!(
|
|
318
|
-
node.accept_replicated(&record)?,
|
|
319
|
-
ApplyOutcome::AlreadyApplied
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
assert_eq!(
|
|
324
|
-
node.state().hash().as_hex(),
|
|
325
|
-
hash_after_first,
|
|
326
|
-
"replay must not change state"
|
|
327
|
-
);
|
|
328
|
-
Ok(())
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
#[test]
|
|
332
|
-
fn recovery_is_idempotent_across_repeated_restarts() -> Result<(), Box<dyn std::error::Error>> {
|
|
333
|
-
let dir = TempDir::new()?;
|
|
334
|
-
let path = dir.path().join("tx.log");
|
|
335
|
-
|
|
336
|
-
{
|
|
337
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
338
|
-
for index in 1..=4 {
|
|
339
|
-
let record = node.build(&format!("tx{}", index), abc(&format!("tx{}", index)));
|
|
340
|
-
node.commit(&record)?;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
let mut hashes = Vec::new();
|
|
345
|
-
for _ in 0..4 {
|
|
346
|
-
let (node, report) = TransactionalNode::open(&path, "node1")?;
|
|
347
|
-
assert_eq!(report.committed.len(), 4);
|
|
348
|
-
hashes.push(node.state().hash().as_hex().to_string());
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
assert!(
|
|
352
|
-
hashes.windows(2).all(|pair| pair[0] == pair[1]),
|
|
353
|
-
"every restart must recover identical state"
|
|
354
|
-
);
|
|
355
|
-
Ok(())
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
#[test]
|
|
359
|
-
fn a_crash_during_recovery_still_recovers() -> Result<(), Box<dyn std::error::Error>> {
|
|
360
|
-
let dir = TempDir::new()?;
|
|
361
|
-
let path = dir.path().join("tx.log");
|
|
362
|
-
|
|
363
|
-
{
|
|
364
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
365
|
-
for index in 1..=3 {
|
|
366
|
-
let record = node.build(&format!("tx{}", index), abc(&format!("tx{}", index)));
|
|
367
|
-
node.commit(&record)?;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Abandon recovery part-way, repeatedly, then complete it.
|
|
372
|
-
for _ in 0..3 {
|
|
373
|
-
let (partial, _) = TransactionalNode::open(&path, "node1")?;
|
|
374
|
-
drop(partial);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
let (node, report) = TransactionalNode::open(&path, "node1")?;
|
|
378
|
-
assert_eq!(report.committed.len(), 3);
|
|
379
|
-
for index in 1..=3 {
|
|
380
|
-
let key = format!("A-tx{}", index);
|
|
381
|
-
assert!(
|
|
382
|
-
node.state().get_record("accounts", &key).is_some(),
|
|
383
|
-
"tx{} lost",
|
|
384
|
-
index
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
Ok(())
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// ----------------------------------------------------------- concurrency
|
|
391
|
-
|
|
392
|
-
#[test]
|
|
393
|
-
fn concurrent_transactions_never_interleave() -> Result<(), Box<dyn std::error::Error>> {
|
|
394
|
-
let dir = TempDir::new()?;
|
|
395
|
-
let path = dir.path().join("tx.log");
|
|
396
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
397
|
-
|
|
398
|
-
// Three writers each commit a three-operation transaction against the
|
|
399
|
-
// same node. Commits are serialized, so no transaction may be split by
|
|
400
|
-
// another.
|
|
401
|
-
let mut records = Vec::new();
|
|
402
|
-
for writer in 0..3 {
|
|
403
|
-
let id = format!("writer{}", writer);
|
|
404
|
-
let record = node.build(&id, abc(&id));
|
|
405
|
-
assert_eq!(node.commit(&record)?, ApplyOutcome::Applied);
|
|
406
|
-
records.push(record);
|
|
407
|
-
}
|
|
408
|
-
drop(node);
|
|
409
|
-
|
|
410
|
-
let (recovered, report) = TransactionalNode::open(&path, "node1")?;
|
|
411
|
-
assert_eq!(report.committed.len(), 3);
|
|
412
|
-
for record in &records {
|
|
413
|
-
assert_atomic(&recovered, record, "concurrent writers");
|
|
414
|
-
assert_eq!(visible(&recovered, record), 3);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// Sequences are unique and ordered, so the log defines one history.
|
|
418
|
-
let sequences: Vec<u64> = report
|
|
419
|
-
.committed
|
|
420
|
-
.iter()
|
|
421
|
-
.map(|record| record.sequence)
|
|
422
|
-
.collect();
|
|
423
|
-
let unique: HashSet<u64> = sequences.iter().copied().collect();
|
|
424
|
-
assert_eq!(unique.len(), sequences.len(), "sequences must be unique");
|
|
425
|
-
assert!(
|
|
426
|
-
sequences.windows(2).all(|pair| pair[0] < pair[1]),
|
|
427
|
-
"log must be ordered"
|
|
428
|
-
);
|
|
429
|
-
Ok(())
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
#[test]
|
|
433
|
-
fn a_losing_writer_is_rejected_without_partial_effect() -> Result<(), Box<dyn std::error::Error>>
|
|
434
|
-
{
|
|
435
|
-
let dir = TempDir::new()?;
|
|
436
|
-
let path = dir.path().join("tx.log");
|
|
437
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
438
|
-
|
|
439
|
-
// Two writers race to create the same record. Both transactions also
|
|
440
|
-
// touch a record of their own.
|
|
441
|
-
let first = node.build(
|
|
442
|
-
"writer-a",
|
|
443
|
-
vec![
|
|
444
|
-
TransactionOperation::set("accounts", "shared", json!({ "owner": "a" }))
|
|
445
|
-
.requiring(Precondition::MustNotExist),
|
|
446
|
-
TransactionOperation::set("accounts", "only-a", json!({ "balance": 1 })),
|
|
447
|
-
],
|
|
448
|
-
);
|
|
449
|
-
let second = node.build(
|
|
450
|
-
"writer-b",
|
|
451
|
-
vec![
|
|
452
|
-
TransactionOperation::set("accounts", "shared", json!({ "owner": "b" }))
|
|
453
|
-
.requiring(Precondition::MustNotExist),
|
|
454
|
-
TransactionOperation::set("accounts", "only-b", json!({ "balance": 2 })),
|
|
455
|
-
],
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
assert_eq!(node.commit(&first)?, ApplyOutcome::Applied);
|
|
459
|
-
assert!(matches!(node.commit(&second)?, ApplyOutcome::Rejected(_)));
|
|
460
|
-
|
|
461
|
-
// The loser must leave nothing behind, including its uncontended write.
|
|
462
|
-
assert!(
|
|
463
|
-
node.state().get_record("accounts", "only-b").is_none(),
|
|
464
|
-
"a rejected transaction must not apply its other operations"
|
|
465
|
-
);
|
|
466
|
-
assert_eq!(
|
|
467
|
-
node.state().get_record("accounts", "shared"),
|
|
468
|
-
Some(&json!({ "owner": "a" }))
|
|
469
|
-
);
|
|
470
|
-
drop(node);
|
|
471
|
-
|
|
472
|
-
let (recovered, report) = TransactionalNode::open(&path, "node1")?;
|
|
473
|
-
assert_eq!(report.committed.len(), 1, "only the winner may be durable");
|
|
474
|
-
assert!(recovered.state().get_record("accounts", "only-b").is_none());
|
|
475
|
-
Ok(())
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// ---------------------------------------------------------- replication
|
|
479
|
-
|
|
480
|
-
#[test]
|
|
481
|
-
fn a_transaction_stays_atomic_across_replication() -> Result<(), Box<dyn std::error::Error>> {
|
|
482
|
-
let dir = TempDir::new()?;
|
|
483
|
-
let (mut leader, _) = TransactionalNode::open(dir.path().join("a.log"), "nodeA")?;
|
|
484
|
-
let (mut follower_b, _) = TransactionalNode::open(dir.path().join("b.log"), "nodeB")?;
|
|
485
|
-
let (mut follower_c, _) = TransactionalNode::open(dir.path().join("c.log"), "nodeC")?;
|
|
486
|
-
|
|
487
|
-
let record = leader.build("tx1", abc("tx1"));
|
|
488
|
-
assert_eq!(leader.commit(&record)?, ApplyOutcome::Applied);
|
|
489
|
-
|
|
490
|
-
assert_eq!(
|
|
491
|
-
follower_b.accept_replicated(&record)?,
|
|
492
|
-
ApplyOutcome::Applied
|
|
493
|
-
);
|
|
494
|
-
assert_eq!(
|
|
495
|
-
follower_c.accept_replicated(&record)?,
|
|
496
|
-
ApplyOutcome::Applied
|
|
497
|
-
);
|
|
498
|
-
|
|
499
|
-
// Duplicate delivery is safe.
|
|
500
|
-
assert_eq!(
|
|
501
|
-
follower_b.accept_replicated(&record)?,
|
|
502
|
-
ApplyOutcome::AlreadyApplied
|
|
503
|
-
);
|
|
504
|
-
assert_eq!(
|
|
505
|
-
follower_c.accept_replicated(&record)?,
|
|
506
|
-
ApplyOutcome::AlreadyApplied
|
|
507
|
-
);
|
|
508
|
-
|
|
509
|
-
let leader_hash = leader.state().hash().as_hex().to_string();
|
|
510
|
-
assert_eq!(
|
|
511
|
-
follower_b.state().hash().as_hex(),
|
|
512
|
-
leader_hash,
|
|
513
|
-
"B diverged"
|
|
514
|
-
);
|
|
515
|
-
assert_eq!(
|
|
516
|
-
follower_c.state().hash().as_hex(),
|
|
517
|
-
leader_hash,
|
|
518
|
-
"C diverged"
|
|
519
|
-
);
|
|
520
|
-
|
|
521
|
-
for node in [&follower_b, &follower_c] {
|
|
522
|
-
assert_atomic(node, &record, "replicated follower");
|
|
523
|
-
}
|
|
524
|
-
Ok(())
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
#[test]
|
|
528
|
-
fn a_follower_that_crashes_mid_replication_recovers_atomically(
|
|
529
|
-
) -> Result<(), Box<dyn std::error::Error>> {
|
|
530
|
-
let dir = TempDir::new()?;
|
|
531
|
-
let leader_path = dir.path().join("a.log");
|
|
532
|
-
let follower_path = dir.path().join("b.log");
|
|
533
|
-
|
|
534
|
-
let record = {
|
|
535
|
-
let (mut leader, _) = TransactionalNode::open(&leader_path, "nodeA")?;
|
|
536
|
-
let record = leader.build("tx1", abc("tx1"));
|
|
537
|
-
leader.commit(&record)?;
|
|
538
|
-
record
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
// The follower dies while writing the replicated record.
|
|
542
|
-
{
|
|
543
|
-
let (mut follower, _) = TransactionalNode::open(&follower_path, "nodeB")?;
|
|
544
|
-
follower.commit_with_crash(&record, &CrashPoint::DuringWrite { keep_percent: 40 })?;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
let (mut follower, report) = TransactionalNode::open(&follower_path, "nodeB")?;
|
|
548
|
-
assert!(
|
|
549
|
-
report.committed.is_empty(),
|
|
550
|
-
"a torn replicated record must not commit"
|
|
551
|
-
);
|
|
552
|
-
assert_atomic(&follower, &record, "follower after torn write");
|
|
553
|
-
assert_eq!(follower.executor().visible_operations(&record), 0);
|
|
554
|
-
|
|
555
|
-
// Retransmission after recovery succeeds and converges.
|
|
556
|
-
assert_eq!(follower.accept_replicated(&record)?, ApplyOutcome::Applied);
|
|
557
|
-
let (leader, _) = TransactionalNode::open(&leader_path, "nodeA")?;
|
|
558
|
-
assert_eq!(
|
|
559
|
-
follower.state().hash().as_hex(),
|
|
560
|
-
leader.state().hash().as_hex()
|
|
561
|
-
);
|
|
562
|
-
Ok(())
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
#[test]
|
|
566
|
-
fn a_replicated_record_that_fails_integrity_is_refused(
|
|
567
|
-
) -> Result<(), Box<dyn std::error::Error>> {
|
|
568
|
-
let dir = TempDir::new()?;
|
|
569
|
-
let (mut follower, _) = TransactionalNode::open(dir.path().join("b.log"), "nodeB")?;
|
|
570
|
-
|
|
571
|
-
let mut record = TransactionRecord::new("tx1", "nodeA", 1, abc("tx1"));
|
|
572
|
-
record.operations[0].record_id = "tampered".to_string();
|
|
573
|
-
|
|
574
|
-
assert!(matches!(
|
|
575
|
-
follower.accept_replicated(&record)?,
|
|
576
|
-
ApplyOutcome::Rejected(_)
|
|
577
|
-
));
|
|
578
|
-
assert!(
|
|
579
|
-
follower.state().records.is_empty(),
|
|
580
|
-
"a tampered record must not apply"
|
|
581
|
-
);
|
|
582
|
-
Ok(())
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// -------------------------------------------------------------- identity
|
|
586
|
-
|
|
587
|
-
#[test]
|
|
588
|
-
fn durable_transaction_identity_survives_restart() -> Result<(), Box<dyn std::error::Error>> {
|
|
589
|
-
let dir = TempDir::new()?;
|
|
590
|
-
let path = dir.path().join("tx.log");
|
|
591
|
-
|
|
592
|
-
let record = {
|
|
593
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
594
|
-
let record = node.build("stable-id", abc("stable-id"));
|
|
595
|
-
node.commit(&record)?;
|
|
596
|
-
record
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
let (mut node, report) = TransactionalNode::open(&path, "node1")?;
|
|
600
|
-
assert_eq!(report.committed[0].transaction_id, "stable-id");
|
|
601
|
-
assert!(
|
|
602
|
-
node.executor().applied_transactions().contains("stable-id"),
|
|
603
|
-
"identity must be restored so replay stays idempotent"
|
|
604
|
-
);
|
|
605
|
-
|
|
606
|
-
// Redelivery after restart is still a no-op.
|
|
607
|
-
assert_eq!(
|
|
608
|
-
node.accept_replicated(&record)?,
|
|
609
|
-
ApplyOutcome::AlreadyApplied
|
|
610
|
-
);
|
|
611
|
-
Ok(())
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
#[test]
|
|
615
|
-
fn deletes_are_atomic_with_writes() -> Result<(), Box<dyn std::error::Error>> {
|
|
616
|
-
let dir = TempDir::new()?;
|
|
617
|
-
let path = dir.path().join("tx.log");
|
|
618
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
619
|
-
|
|
620
|
-
let seed = node.build(
|
|
621
|
-
"seed",
|
|
622
|
-
vec![
|
|
623
|
-
TransactionOperation::set("accounts", "old", json!({ "balance": 5 })),
|
|
624
|
-
TransactionOperation::set("accounts", "keep", json!({ "balance": 6 })),
|
|
625
|
-
],
|
|
626
|
-
);
|
|
627
|
-
node.commit(&seed)?;
|
|
628
|
-
|
|
629
|
-
// Move: delete one record and create another, atomically.
|
|
630
|
-
let moved = node.build(
|
|
631
|
-
"move",
|
|
632
|
-
vec![
|
|
633
|
-
TransactionOperation::delete("accounts", "old").requiring(Precondition::MustExist),
|
|
634
|
-
TransactionOperation::set("accounts", "new", json!({ "balance": 5 }))
|
|
635
|
-
.requiring(Precondition::MustNotExist),
|
|
636
|
-
],
|
|
637
|
-
);
|
|
638
|
-
assert_eq!(node.commit(&moved)?, ApplyOutcome::Applied);
|
|
639
|
-
drop(node);
|
|
640
|
-
|
|
641
|
-
let (recovered, _) = TransactionalNode::open(&path, "node1")?;
|
|
642
|
-
assert!(
|
|
643
|
-
recovered.state().get_record("accounts", "old").is_none(),
|
|
644
|
-
"delete must persist"
|
|
645
|
-
);
|
|
646
|
-
assert!(
|
|
647
|
-
recovered.state().get_record("accounts", "new").is_some(),
|
|
648
|
-
"insert must persist"
|
|
649
|
-
);
|
|
650
|
-
assert!(
|
|
651
|
-
recovered.state().get_record("accounts", "keep").is_some(),
|
|
652
|
-
"untouched record kept"
|
|
653
|
-
);
|
|
654
|
-
Ok(())
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
/// A long mixed history under repeated crashes: no transaction may ever be
|
|
658
|
-
/// partially visible, at any point, under any interleaving.
|
|
659
|
-
#[test]
|
|
660
|
-
fn a_long_crash_ridden_history_never_exposes_a_partial_transaction(
|
|
661
|
-
) -> Result<(), Box<dyn std::error::Error>> {
|
|
662
|
-
let dir = TempDir::new()?;
|
|
663
|
-
let path = dir.path().join("tx.log");
|
|
664
|
-
let crashes = [
|
|
665
|
-
CrashPoint::AfterApply,
|
|
666
|
-
CrashPoint::DuringWrite { keep_percent: 30 },
|
|
667
|
-
CrashPoint::DuringApply {
|
|
668
|
-
after_operations: 2,
|
|
669
|
-
},
|
|
670
|
-
CrashPoint::BeforeWrite,
|
|
671
|
-
CrashPoint::AfterFsyncBeforeApply,
|
|
672
|
-
CrashPoint::DuringWrite { keep_percent: 80 },
|
|
673
|
-
];
|
|
674
|
-
|
|
675
|
-
let mut issued = Vec::new();
|
|
676
|
-
for (index, crash) in crashes.iter().enumerate() {
|
|
677
|
-
let (mut node, _) = TransactionalNode::open(&path, "node1")?;
|
|
678
|
-
let id = format!("tx{}", index);
|
|
679
|
-
let record = node.build(&id, abc(&id));
|
|
680
|
-
node.commit_with_crash(&record, crash)?;
|
|
681
|
-
issued.push(record);
|
|
682
|
-
|
|
683
|
-
// Restart after every crash and check the whole history.
|
|
684
|
-
drop(node);
|
|
685
|
-
let (recovered, _) = TransactionalNode::open(&path, "node1")?;
|
|
686
|
-
for previous in &issued {
|
|
687
|
-
assert_atomic(&recovered, previous, &format!("after crash {}", index));
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
// Final state: every transaction is wholly present or wholly absent,
|
|
692
|
-
// and the committed count matches what the log actually holds.
|
|
693
|
-
let (recovered, report) = TransactionalNode::open(&path, "node1")?;
|
|
694
|
-
let committed_ids: HashSet<String> = report
|
|
695
|
-
.committed
|
|
696
|
-
.iter()
|
|
697
|
-
.map(|record| record.transaction_id.clone())
|
|
698
|
-
.collect();
|
|
699
|
-
for record in &issued {
|
|
700
|
-
let seen = recovered.executor().visible_operations(record);
|
|
701
|
-
if committed_ids.contains(&record.transaction_id) {
|
|
702
|
-
assert_eq!(
|
|
703
|
-
seen,
|
|
704
|
-
record.operations.len(),
|
|
705
|
-
"{} committed but not whole",
|
|
706
|
-
record.transaction_id
|
|
707
|
-
);
|
|
708
|
-
} else {
|
|
709
|
-
assert_eq!(
|
|
710
|
-
seen, 0,
|
|
711
|
-
"{} not committed but visible",
|
|
712
|
-
record.transaction_id
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
Ok(())
|
|
717
|
-
}
|
|
718
|
-
}
|