caveat-lang 1.5.1__tar.gz
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.
- caveat_lang-1.5.1/LICENSE +21 -0
- caveat_lang-1.5.1/PKG-INFO +231 -0
- caveat_lang-1.5.1/README.md +195 -0
- caveat_lang-1.5.1/THIRD_PARTY_NOTICES.md +776 -0
- caveat_lang-1.5.1/caveat_lang/__init__.py +781 -0
- caveat_lang-1.5.1/caveat_lang/_display.py +68 -0
- caveat_lang-1.5.1/caveat_lang/_runtime.pyi +43 -0
- caveat_lang-1.5.1/caveat_lang/py.typed +0 -0
- caveat_lang-1.5.1/pyproject.toml +70 -0
- caveat_lang-1.5.1/python/Cargo.lock +369 -0
- caveat_lang-1.5.1/python/Cargo.toml +25 -0
- caveat_lang-1.5.1/python/LICENSE +21 -0
- caveat_lang-1.5.1/python/README.md +195 -0
- caveat_lang-1.5.1/python/THIRD_PARTY_NOTICES.md +776 -0
- caveat_lang-1.5.1/python/examples/claim_checker.py +95 -0
- caveat_lang-1.5.1/python/src/lib.rs +210 -0
- caveat_lang-1.5.1/python/tests/differential/trace.mjs +106 -0
- caveat_lang-1.5.1/python/tests/differential/trace.py +114 -0
- caveat_lang-1.5.1/python/tests/fixtures/agents.cav +19 -0
- caveat_lang-1.5.1/python/tests/fixtures/agents.scenarios.json +25 -0
- caveat_lang-1.5.1/python/tests/fixtures/assessment.cav +48 -0
- caveat_lang-1.5.1/python/tests/fixtures/module-bindings/collision-v1.4.1-initial.json +1 -0
- caveat_lang-1.5.1/python/tests/fixtures/module-bindings/collision.bundle +12 -0
- caveat_lang-1.5.1/python/tests/test_differential.py +93 -0
- caveat_lang-1.5.1/python/tests/test_session.py +364 -0
- caveat_lang-1.5.1/runtime/Cargo.lock +286 -0
- caveat_lang-1.5.1/runtime/Cargo.toml +58 -0
- caveat_lang-1.5.1/runtime/examples/canonical_001.rs +37 -0
- caveat_lang-1.5.1/runtime/examples/canonical_002.rs +33 -0
- caveat_lang-1.5.1/runtime/examples/canonical_003.rs +32 -0
- caveat_lang-1.5.1/runtime/examples/carmack_profile.rs +223 -0
- caveat_lang-1.5.1/runtime/examples/caveat_sweep.rs +162 -0
- caveat_lang-1.5.1/runtime/examples/collector_profile.rs +272 -0
- caveat_lang-1.5.1/runtime/examples/collector_release_memory.rs +152 -0
- caveat_lang-1.5.1/runtime/examples/event_phase_profile.rs +375 -0
- caveat_lang-1.5.1/runtime/examples/event_phase_support/origin_allocator.rs +663 -0
- caveat_lang-1.5.1/runtime/examples/lean_conformance.rs +242 -0
- caveat_lang-1.5.1/runtime/examples/outcome_sweep.rs +183 -0
- caveat_lang-1.5.1/runtime/examples/profile_dispatch.rs +79 -0
- caveat_lang-1.5.1/runtime/examples/renewal_removal_profile.rs +300 -0
- caveat_lang-1.5.1/runtime/examples/replay_save_sweep.rs +159 -0
- caveat_lang-1.5.1/runtime/examples/save_sweep.rs +181 -0
- caveat_lang-1.5.1/runtime/examples/view_delta_sweep.rs +279 -0
- caveat_lang-1.5.1/runtime/examples/withdrawal_extraction_profile.rs +289 -0
- caveat_lang-1.5.1/runtime/prelude.cav +14 -0
- caveat_lang-1.5.1/runtime/src/action_runtime.rs +339 -0
- caveat_lang-1.5.1/runtime/src/ast.rs +179 -0
- caveat_lang-1.5.1/runtime/src/bin/caveat-map.rs +113 -0
- caveat_lang-1.5.1/runtime/src/bin/caveat-reactive.rs +131 -0
- caveat_lang-1.5.1/runtime/src/bin/caveat-rs.rs +30 -0
- caveat_lang-1.5.1/runtime/src/bin/caveat.rs +354 -0
- caveat_lang-1.5.1/runtime/src/caveat_rs.rs +483 -0
- caveat_lang-1.5.1/runtime/src/chunked.rs +823 -0
- caveat_lang-1.5.1/runtime/src/eval.rs +493 -0
- caveat_lang-1.5.1/runtime/src/fast_hash.rs +84 -0
- caveat_lang-1.5.1/runtime/src/game_session.rs +541 -0
- caveat_lang-1.5.1/runtime/src/graphics.rs +586 -0
- caveat_lang-1.5.1/runtime/src/idmap.rs +1392 -0
- caveat_lang-1.5.1/runtime/src/lib.rs +298 -0
- caveat_lang-1.5.1/runtime/src/link.rs +1684 -0
- caveat_lang-1.5.1/runtime/src/load_diagnostics.rs +292 -0
- caveat_lang-1.5.1/runtime/src/map.rs +1470 -0
- caveat_lang-1.5.1/runtime/src/namemap.rs +249 -0
- caveat_lang-1.5.1/runtime/src/ordmap.rs +1105 -0
- caveat_lang-1.5.1/runtime/src/parser.rs +546 -0
- caveat_lang-1.5.1/runtime/src/presentation.rs +317 -0
- caveat_lang-1.5.1/runtime/src/reactive.rs +13846 -0
- caveat_lang-1.5.1/runtime/src/reactive_archive.rs +191 -0
- caveat_lang-1.5.1/runtime/src/reactive_check.rs +2195 -0
- caveat_lang-1.5.1/runtime/src/reactive_collector.rs +1620 -0
- caveat_lang-1.5.1/runtime/src/reactive_departure.rs +1390 -0
- caveat_lang-1.5.1/runtime/src/reactive_event_profile.rs +334 -0
- caveat_lang-1.5.1/runtime/src/reactive_expr.rs +7823 -0
- caveat_lang-1.5.1/runtime/src/reactive_identifiers.rs +100 -0
- caveat_lang-1.5.1/runtime/src/reactive_interface.rs +275 -0
- caveat_lang-1.5.1/runtime/src/reactive_outcome.rs +472 -0
- caveat_lang-1.5.1/runtime/src/reactive_reach.rs +2711 -0
- caveat_lang-1.5.1/runtime/src/reactive_reads.rs +255 -0
- caveat_lang-1.5.1/runtime/src/reactive_relations.rs +1199 -0
- caveat_lang-1.5.1/runtime/src/reactive_releases.rs +522 -0
- caveat_lang-1.5.1/runtime/src/reactive_renewal_profile.rs +513 -0
- caveat_lang-1.5.1/runtime/src/reactive_replay_save.rs +636 -0
- caveat_lang-1.5.1/runtime/src/reactive_save.rs +6206 -0
- caveat_lang-1.5.1/runtime/src/reactive_unchanged_tests.rs +270 -0
- caveat_lang-1.5.1/runtime/src/reactive_view2.rs +710 -0
- caveat_lang-1.5.1/runtime/src/reactive_view_patch.rs +3907 -0
- caveat_lang-1.5.1/runtime/src/reactive_write.rs +2777 -0
- caveat_lang-1.5.1/runtime/src/release_line.rs +35 -0
- caveat_lang-1.5.1/runtime/src/repeat.rs +1132 -0
- caveat_lang-1.5.1/runtime/src/session.rs +297 -0
- caveat_lang-1.5.1/runtime/src/source_library.rs +227 -0
- caveat_lang-1.5.1/runtime/src/web.rs +636 -0
- caveat_lang-1.5.1/runtime/src/web_games.rs +364 -0
- caveat_lang-1.5.1/runtime/src/web_source_library.rs +42 -0
- caveat_lang-1.5.1/runtime/src/world3d.rs +819 -0
- caveat_lang-1.5.1/runtime/tests/across_members.rs +214 -0
- caveat_lang-1.5.1/runtime/tests/across_name_compatibility.rs +144 -0
- caveat_lang-1.5.1/runtime/tests/action_plans.rs +144 -0
- caveat_lang-1.5.1/runtime/tests/agents.rs +216 -0
- caveat_lang-1.5.1/runtime/tests/atomic_refusal.rs +249 -0
- caveat_lang-1.5.1/runtime/tests/attention_invariants.rs +269 -0
- caveat_lang-1.5.1/runtime/tests/authoring_diagnostics.rs +151 -0
- caveat_lang-1.5.1/runtime/tests/authorship.rs +363 -0
- caveat_lang-1.5.1/runtime/tests/binding_explanations.rs +634 -0
- caveat_lang-1.5.1/runtime/tests/binding_pass_order.rs +156 -0
- caveat_lang-1.5.1/runtime/tests/carries_any.rs +323 -0
- caveat_lang-1.5.1/runtime/tests/carries_latest.rs +110 -0
- caveat_lang-1.5.1/runtime/tests/carries_read_once.rs +172 -0
- caveat_lang-1.5.1/runtime/tests/caveat_map.rs +124 -0
- caveat_lang-1.5.1/runtime/tests/caveat_rs.rs +42 -0
- caveat_lang-1.5.1/runtime/tests/caveated_selector_invariants.rs +348 -0
- caveat_lang-1.5.1/runtime/tests/changed_triggers.rs +247 -0
- caveat_lang-1.5.1/runtime/tests/check.rs +2757 -0
- caveat_lang-1.5.1/runtime/tests/citing.rs +233 -0
- caveat_lang-1.5.1/runtime/tests/citing_invariants.rs +323 -0
- caveat_lang-1.5.1/runtime/tests/collector_index_compaction.rs +204 -0
- caveat_lang-1.5.1/runtime/tests/compared_records.rs +62 -0
- caveat_lang-1.5.1/runtime/tests/consulted_qualifications.rs +174 -0
- caveat_lang-1.5.1/runtime/tests/consulted_renewals.rs +178 -0
- caveat_lang-1.5.1/runtime/tests/conway_1_4_invariants.rs +928 -0
- caveat_lang-1.5.1/runtime/tests/d021_journal_order.rs +119 -0
- caveat_lang-1.5.1/runtime/tests/d022_provenance_limit.rs +90 -0
- caveat_lang-1.5.1/runtime/tests/d023_evaluation_limit.rs +95 -0
- caveat_lang-1.5.1/runtime/tests/d024_reading_current_occurrence.rs +144 -0
- caveat_lang-1.5.1/runtime/tests/d025_text_limit.rs +104 -0
- caveat_lang-1.5.1/runtime/tests/d026_withdrawn_through_decision_predicates.rs +164 -0
- caveat_lang-1.5.1/runtime/tests/d034_nested_call_expansion.rs +118 -0
- caveat_lang-1.5.1/runtime/tests/d035_relation_on_agent_or_threshold.rs +68 -0
- caveat_lang-1.5.1/runtime/tests/d036_relation_from_cited_evidence.rs +115 -0
- caveat_lang-1.5.1/runtime/tests/d037_carries_past_provenance_limit.rs +155 -0
- caveat_lang-1.5.1/runtime/tests/d038_journal_witnesses_past_provenance_limit.rs +787 -0
- caveat_lang-1.5.1/runtime/tests/d039_journal_check_reads_the_graph_once.rs +111 -0
- caveat_lang-1.5.1/runtime/tests/d040_resolve_retires_a_journal_entry.rs +188 -0
- caveat_lang-1.5.1/runtime/tests/d041_outcome_lineage_compacts.rs +670 -0
- caveat_lang-1.5.1/runtime/tests/d042_negative_delay_refuses.rs +140 -0
- caveat_lang-1.5.1/runtime/tests/d043_declared_attention_restores.rs +250 -0
- caveat_lang-1.5.1/runtime/tests/d044_declared_commitment_commit_refuses.rs +68 -0
- caveat_lang-1.5.1/runtime/tests/d045_reopened_by_unobserved_evidence_refuses.rs +159 -0
- caveat_lang-1.5.1/runtime/tests/d046_declared_attention_forgeries_refused.rs +184 -0
- caveat_lang-1.5.1/runtime/tests/d047_outcome_lineage_vetoes_collection.rs +231 -0
- caveat_lang-1.5.1/runtime/tests/d048_skipped_set_keeps_its_guard.rs +243 -0
- caveat_lang-1.5.1/runtime/tests/d049_journal_entry_takes_its_grounds_markers.rs +213 -0
- caveat_lang-1.5.1/runtime/tests/d050_break_through_cites_a_retired_cause.rs +255 -0
- caveat_lang-1.5.1/runtime/tests/d051_declared_reopen_retired_unobserved_restores.rs +988 -0
- caveat_lang-1.5.1/runtime/tests/d052_observation_record_needs_an_observing_rule.rs +588 -0
- caveat_lang-1.5.1/runtime/tests/d053_last_event_examines_fit_spent_together.rs +447 -0
- caveat_lang-1.5.1/runtime/tests/d054_markers_no_rule_carries_refused.rs +6805 -0
- caveat_lang-1.5.1/runtime/tests/d055_deferred_cause_forgeries_refused.rs +253 -0
- caveat_lang-1.5.1/runtime/tests/d057_citations_carry_departed_markers.rs +371 -0
- caveat_lang-1.5.1/runtime/tests/d057_readers_carry_cited_markers.rs +325 -0
- caveat_lang-1.5.1/runtime/tests/d058_resolve_value_caveats_restore.rs +260 -0
- caveat_lang-1.5.1/runtime/tests/d059_a_history_named_journal.rs +301 -0
- caveat_lang-1.5.1/runtime/tests/d060_retirement_dates.rs +417 -0
- caveat_lang-1.5.1/runtime/tests/d061_windowless_names_bounded.rs +376 -0
- caveat_lang-1.5.1/runtime/tests/d062_hold_entries.rs +1097 -0
- caveat_lang-1.5.1/runtime/tests/d063_renewals_need_a_renewing_rule.rs +199 -0
- caveat_lang-1.5.1/runtime/tests/d064_observation_record_needs_its_stance.rs +234 -0
- caveat_lang-1.5.1/runtime/tests/d065_event_stance_needs_its_record.rs +134 -0
- caveat_lang-1.5.1/runtime/tests/d070_large_save_restores.rs +162 -0
- caveat_lang-1.5.1/runtime/tests/d071_retired_check_is_linear.rs +544 -0
- caveat_lang-1.5.1/runtime/tests/d074_a_history_named_journal_beside_journal_window.rs +601 -0
- caveat_lang-1.5.1/runtime/tests/d083_later_programs_parameter_grounds.rs +171 -0
- caveat_lang-1.5.1/runtime/tests/d086_across_text_in_evidence_source.rs +84 -0
- caveat_lang-1.5.1/runtime/tests/d088_module_names_older_releases_loaded.rs +622 -0
- caveat_lang-1.5.1/runtime/tests/d093_module_only_if_beside_a_program_only_if.rs +107 -0
- caveat_lang-1.5.1/runtime/tests/d098_citations_carry_kept_caveats.rs +365 -0
- caveat_lang-1.5.1/runtime/tests/d099_citations_pin_what_they_read.rs +1020 -0
- caveat_lang-1.5.1/runtime/tests/d100_value_reads_take_readings_as_taken.rs +1012 -0
- caveat_lang-1.5.1/runtime/tests/d101_stances_need_a_revealing_rule.rs +281 -0
- caveat_lang-1.5.1/runtime/tests/d102_declared_names_are_no_occurrences.rs +677 -0
- caveat_lang-1.5.1/runtime/tests/d103_renew_onto_a_declared_name_refuses.rs +274 -0
- caveat_lang-1.5.1/runtime/tests/d104_relations_listed_once.rs +431 -0
- caveat_lang-1.5.1/runtime/tests/d105_a_declared_name_spelled_like_a_journal_entry.rs +521 -0
- caveat_lang-1.5.1/runtime/tests/d116_a_true_ends_a_route.rs +758 -0
- caveat_lang-1.5.1/runtime/tests/decision_journal.rs +159 -0
- caveat_lang-1.5.1/runtime/tests/decision_series_invariants.rs +492 -0
- caveat_lang-1.5.1/runtime/tests/define.rs +175 -0
- caveat_lang-1.5.1/runtime/tests/departure.rs +921 -0
- caveat_lang-1.5.1/runtime/tests/departure_invariants.rs +586 -0
- caveat_lang-1.5.1/runtime/tests/departure_journal_restore.rs +160 -0
- caveat_lang-1.5.1/runtime/tests/departure_settles_records.rs +157 -0
- caveat_lang-1.5.1/runtime/tests/dispatch_outcomes.rs +1413 -0
- caveat_lang-1.5.1/runtime/tests/earlier_occurrence.rs +418 -0
- caveat_lang-1.5.1/runtime/tests/elapsed_clock.rs +433 -0
- caveat_lang-1.5.1/runtime/tests/epistemic_actions.rs +324 -0
- caveat_lang-1.5.1/runtime/tests/eval_errors.rs +171 -0
- caveat_lang-1.5.1/runtime/tests/expansion_equivalence.rs +285 -0
- caveat_lang-1.5.1/runtime/tests/explanation_invariants.rs +295 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/c006-round7-c2-cr16-first.cav +290 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/c006-round7-c2-cr16-fixed.cav +282 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/c006-round7-c3-cr16-first.cav +305 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/c006-round7-c3-cr16-fixed.cav +307 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/collector-baseline-f5ec829.json +36 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/collector-baseline-rc15.json +36 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/f268-rc11-wide-grounds.cav +26 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/f268-rc11-wide-grounds.save.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/interface/glowcap-c1.json +722 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/interface/ledger-identifiers.json +457 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/README.md +22 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision-v1.0.0-initial.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision-v1.0.0-state.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision-v1.4.1-initial.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision-v1.4.1-replay-1.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision-v1.4.1-replay-2.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision-v1.4.1-state.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/collision.bundle +12 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/legacy-only-v1.4.1-initial.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/legacy-only-v1.4.1-replay-1.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/legacy-only-v1.4.1-replay-2.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/legacy-only-v1.4.1-state.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/legacy-only.bundle +11 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/module-bindings/provenance.json +68 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/provenance.json +44 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-boolean.cav +12 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-boolean.expected.json +273 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-boolean.save.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-numeric.cav +12 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-numeric.expected.json +273 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-numeric.save.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-text.cav +12 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-text.expected.json +273 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.0.0-text.save.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.4.1-unused.cav +12 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.4.1-unused.expected.json +273 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/only-if-functions/v1.4.1-unused.save.json +1 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/rc2-thermostat.cav +45 -0
- caveat_lang-1.5.1/runtime/tests/fixtures/rc2-thermostat.save.json +1 -0
- caveat_lang-1.5.1/runtime/tests/foreclosure.rs +627 -0
- caveat_lang-1.5.1/runtime/tests/foreclosure_invariants.rs +614 -0
- caveat_lang-1.5.1/runtime/tests/function_form_compatibility.rs +149 -0
- caveat_lang-1.5.1/runtime/tests/function_limit.rs +47 -0
- caveat_lang-1.5.1/runtime/tests/game_cli.rs +200 -0
- caveat_lang-1.5.1/runtime/tests/game_session.rs +274 -0
- caveat_lang-1.5.1/runtime/tests/graph_storage.rs +82 -0
- caveat_lang-1.5.1/runtime/tests/grounds.rs +222 -0
- caveat_lang-1.5.1/runtime/tests/grounds_of.rs +359 -0
- caveat_lang-1.5.1/runtime/tests/grounds_restore.rs +160 -0
- caveat_lang-1.5.1/runtime/tests/history_computation.rs +338 -0
- caveat_lang-1.5.1/runtime/tests/holds.rs +332 -0
- caveat_lang-1.5.1/runtime/tests/holds_invariants.rs +512 -0
- caveat_lang-1.5.1/runtime/tests/identifiers.rs +511 -0
- caveat_lang-1.5.1/runtime/tests/identifiers_invariants.rs +350 -0
- caveat_lang-1.5.1/runtime/tests/in_basis.rs +174 -0
- caveat_lang-1.5.1/runtime/tests/integer_clock.rs +322 -0
- caveat_lang-1.5.1/runtime/tests/interface.rs +215 -0
- caveat_lang-1.5.1/runtime/tests/investigation_history.rs +103 -0
- caveat_lang-1.5.1/runtime/tests/journal_restore_validation.rs +364 -0
- caveat_lang-1.5.1/runtime/tests/late_caveat_gaps.rs +289 -0
- caveat_lang-1.5.1/runtime/tests/late_caveat_gaps_invariants.rs +384 -0
- caveat_lang-1.5.1/runtime/tests/late_caveat_reach.rs +81 -0
- caveat_lang-1.5.1/runtime/tests/late_qualification.rs +145 -0
- caveat_lang-1.5.1/runtime/tests/latest_invariants.rs +588 -0
- caveat_lang-1.5.1/runtime/tests/latest_qualify.rs +310 -0
- caveat_lang-1.5.1/runtime/tests/light_the_way.rs +994 -0
- caveat_lang-1.5.1/runtime/tests/light_the_way_input.rs +188 -0
- caveat_lang-1.5.1/runtime/tests/lineage_join_model.rs +577 -0
- caveat_lang-1.5.1/runtime/tests/load_cache.rs +99 -0
- caveat_lang-1.5.1/runtime/tests/module_binding_restore.rs +433 -0
- caveat_lang-1.5.1/runtime/tests/module_expansion_equivalence.rs +284 -0
- caveat_lang-1.5.1/runtime/tests/module_keyword_recovery.rs +346 -0
- caveat_lang-1.5.1/runtime/tests/modules.rs +1969 -0
- caveat_lang-1.5.1/runtime/tests/name_set_model.rs +264 -0
- caveat_lang-1.5.1/runtime/tests/nested_expansion_equivalence.rs +249 -0
- caveat_lang-1.5.1/runtime/tests/nested_repetition.rs +296 -0
- caveat_lang-1.5.1/runtime/tests/neutral_reveal.rs +490 -0
- caveat_lang-1.5.1/runtime/tests/neutral_sample.rs +263 -0
- caveat_lang-1.5.1/runtime/tests/observation_order.rs +222 -0
- caveat_lang-1.5.1/runtime/tests/only_if.rs +205 -0
- caveat_lang-1.5.1/runtime/tests/only_if_function_compatibility.rs +204 -0
- caveat_lang-1.5.1/runtime/tests/outcomes.rs +397 -0
- caveat_lang-1.5.1/runtime/tests/parameter_grounds.rs +193 -0
- caveat_lang-1.5.1/runtime/tests/parameter_lineage.rs +148 -0
- caveat_lang-1.5.1/runtime/tests/parser_text.rs +245 -0
- caveat_lang-1.5.1/runtime/tests/past_revisions.rs +230 -0
- caveat_lang-1.5.1/runtime/tests/past_revisions_invariants.rs +469 -0
- caveat_lang-1.5.1/runtime/tests/permission.rs +442 -0
- caveat_lang-1.5.1/runtime/tests/permission_invariants.rs +401 -0
- caveat_lang-1.5.1/runtime/tests/presentation.rs +170 -0
- caveat_lang-1.5.1/runtime/tests/procedure_invariants.rs +648 -0
- caveat_lang-1.5.1/runtime/tests/procedure_symbols.rs +388 -0
- caveat_lang-1.5.1/runtime/tests/provenance_sharing_invariants.rs +168 -0
- caveat_lang-1.5.1/runtime/tests/qualification_dependencies.rs +39 -0
- caveat_lang-1.5.1/runtime/tests/qualified_values.rs +666 -0
- caveat_lang-1.5.1/runtime/tests/reactive.rs +551 -0
- caveat_lang-1.5.1/runtime/tests/reactive_cli.rs +212 -0
- caveat_lang-1.5.1/runtime/tests/reactive_history.rs +444 -0
- caveat_lang-1.5.1/runtime/tests/reactive_procedures.rs +473 -0
- caveat_lang-1.5.1/runtime/tests/reactive_text.rs +196 -0
- caveat_lang-1.5.1/runtime/tests/reactive_view.rs +124 -0
- caveat_lang-1.5.1/runtime/tests/reading_caveats.rs +331 -0
- caveat_lang-1.5.1/runtime/tests/reading_index.rs +216 -0
- caveat_lang-1.5.1/runtime/tests/reading_index_invariants.rs +515 -0
- caveat_lang-1.5.1/runtime/tests/reading_notes.rs +198 -0
- caveat_lang-1.5.1/runtime/tests/reads_made_once_within_an_event.rs +102 -0
- caveat_lang-1.5.1/runtime/tests/reject.rs +78 -0
- caveat_lang-1.5.1/runtime/tests/renewal.rs +348 -0
- caveat_lang-1.5.1/runtime/tests/reopening_triggers.rs +462 -0
- caveat_lang-1.5.1/runtime/tests/repetition.rs +1580 -0
- caveat_lang-1.5.1/runtime/tests/replay_save.rs +326 -0
- caveat_lang-1.5.1/runtime/tests/restore_attention.rs +209 -0
- caveat_lang-1.5.1/runtime/tests/restore_capability.rs +226 -0
- caveat_lang-1.5.1/runtime/tests/restore_caveats.rs +229 -0
- caveat_lang-1.5.1/runtime/tests/restore_membership.rs +134 -0
- caveat_lang-1.5.1/runtime/tests/restore_reading_stance.rs +69 -0
- caveat_lang-1.5.1/runtime/tests/restore_tables.rs +213 -0
- caveat_lang-1.5.1/runtime/tests/retention_reasons.rs +227 -0
- caveat_lang-1.5.1/runtime/tests/retention_reasons_invariants.rs +349 -0
- caveat_lang-1.5.1/runtime/tests/reversible_foreclosure.rs +525 -0
- caveat_lang-1.5.1/runtime/tests/routed_expansion_equivalence.rs +235 -0
- caveat_lang-1.5.1/runtime/tests/routed_repetition.rs +1542 -0
- caveat_lang-1.5.1/runtime/tests/routed_skips_counted_at_once.rs +182 -0
- caveat_lang-1.5.1/runtime/tests/routed_work.rs +399 -0
- caveat_lang-1.5.1/runtime/tests/save_lockstep.rs +265 -0
- caveat_lang-1.5.1/runtime/tests/save_restore.rs +2659 -0
- caveat_lang-1.5.1/runtime/tests/scheduled_qualification_clock.rs +363 -0
- caveat_lang-1.5.1/runtime/tests/slime_glow_ability.rs +373 -0
- caveat_lang-1.5.1/runtime/tests/source_digest.rs +119 -0
- caveat_lang-1.5.1/runtime/tests/source_library.rs +302 -0
- caveat_lang-1.5.1/runtime/tests/source_motion.rs +361 -0
- caveat_lang-1.5.1/runtime/tests/squeeze_affordance.rs +335 -0
- caveat_lang-1.5.1/runtime/tests/state_caveats.rs +370 -0
- caveat_lang-1.5.1/runtime/tests/strict_irreversible.rs +211 -0
- caveat_lang-1.5.1/runtime/tests/take_back.rs +882 -0
- caveat_lang-1.5.1/runtime/tests/take_back_windows.rs +362 -0
- caveat_lang-1.5.1/runtime/tests/the_last_beacon.rs +494 -0
- caveat_lang-1.5.1/runtime/tests/thermostat_history.rs +141 -0
- caveat_lang-1.5.1/runtime/tests/thresholds.rs +221 -0
- caveat_lang-1.5.1/runtime/tests/trigger_invariants.rs +446 -0
- caveat_lang-1.5.1/runtime/tests/typed_parameters.rs +361 -0
- caveat_lang-1.5.1/runtime/tests/unset_name_compatibility.rs +264 -0
- caveat_lang-1.5.1/runtime/tests/unset_states.rs +290 -0
- caveat_lang-1.5.1/runtime/tests/untrusted_sources.rs +572 -0
- caveat_lang-1.5.1/runtime/tests/untrusted_sources_invariants.rs +370 -0
- caveat_lang-1.5.1/runtime/tests/ventilation_controller.rs +150 -0
- caveat_lang-1.5.1/runtime/tests/verification_outcomes.rs +91 -0
- caveat_lang-1.5.1/runtime/tests/view_delta_apply/mod.rs +205 -0
- caveat_lang-1.5.1/runtime/tests/view_v2.rs +476 -0
- caveat_lang-1.5.1/runtime/tests/what_if.rs +181 -0
- caveat_lang-1.5.1/runtime/tests/windows.rs +306 -0
- caveat_lang-1.5.1/runtime/tests/withdrawal.rs +694 -0
- caveat_lang-1.5.1/runtime/tests/withdrawal_batch_extraction.rs +351 -0
- caveat_lang-1.5.1/runtime/tests/withdrawal_capacity.rs +99 -0
- caveat_lang-1.5.1/runtime/tests/withdrawal_collection.rs +1091 -0
- caveat_lang-1.5.1/runtime/tests/withdrawal_invariants.rs +368 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Walter Sattazahn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: caveat-lang
|
|
3
|
+
Version: 1.5.1
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Operating System :: MacOS
|
|
7
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: Programming Language :: Rust
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
24
|
+
Summary: CAVEAT Language for Python: a decision ledger for agents that keeps an AI's reasons in a record you can check. Values carry their evidence and caveats, decisions keep the grounds they were made on, and withdrawn evidence reopens them.
|
|
25
|
+
Keywords: caveat,decision-ledger,provenance,evidence,audit-trail,agents,ai-agents
|
|
26
|
+
Author: OumuamuaWalt
|
|
27
|
+
License-Expression: MIT
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
30
|
+
Project-URL: Changelog, https://github.com/WSattazahn/caveat-lang/tree/main/docs/releases
|
|
31
|
+
Project-URL: Documentation, https://github.com/WSattazahn/caveat-lang/blob/main/python/README.md
|
|
32
|
+
Project-URL: Homepage, https://github.com/WSattazahn/caveat-lang/tree/main/python
|
|
33
|
+
Project-URL: Issues, https://github.com/WSattazahn/caveat-lang/issues
|
|
34
|
+
Project-URL: Source, https://github.com/WSattazahn/caveat-lang
|
|
35
|
+
|
|
36
|
+
# CAVEAT Language for Python
|
|
37
|
+
|
|
38
|
+
A decision ledger for agents: Caveat keeps an AI's reasons in a record you can check. A Caveat program records what each decision
|
|
39
|
+
rests on: values carry their evidence and caveats, a decision keeps the
|
|
40
|
+
grounds it was made on, and when evidence is withdrawn, the decisions that
|
|
41
|
+
rested on it reopen, with their original grounds still on record.
|
|
42
|
+
|
|
43
|
+
This package runs the same Rust runtime as the
|
|
44
|
+
[`caveat-lang`](https://www.npmjs.com/package/caveat-lang) npm package,
|
|
45
|
+
compiled for Python instead of WebAssembly. It returns the same bytes: every
|
|
46
|
+
outcome, snapshot, view and save matches the npm kit on the repository's
|
|
47
|
+
whole scenario corpus (see [Same bytes as the npm kit](#same-bytes-as-the-npm-kit)).
|
|
48
|
+
It has no Python dependencies.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import caveat_lang as caveat
|
|
52
|
+
|
|
53
|
+
with open("assessment.cav", encoding="utf-8") as file:
|
|
54
|
+
source = file.read()
|
|
55
|
+
|
|
56
|
+
with caveat.open(source) as session:
|
|
57
|
+
session.dispatch("observe", {"confidence": 85}) # a tool observation
|
|
58
|
+
outcome = session.dispatch("assess") # a decision that rests on it
|
|
59
|
+
print(isinstance(outcome, caveat.Accepted)) # True
|
|
60
|
+
|
|
61
|
+
session.dispatch("retract") # the observation was wrong
|
|
62
|
+
for revision in caveat.decision_history(session.snapshot(), "assessment"):
|
|
63
|
+
print(revision["revision"], revision["status"], revision["committed"]["because"])
|
|
64
|
+
# assessment@1 reopened ['observations@1']
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The language itself is documented with the npm kit:
|
|
68
|
+
[Caveat on one page](https://github.com/WSattazahn/caveat-lang/blob/main/kit/docs/REFERENCE.md) and the
|
|
69
|
+
[worked example](https://github.com/WSattazahn/caveat-lang/blob/main/kit/docs/WORKED_EXAMPLE.md).
|
|
70
|
+
|
|
71
|
+
## Install
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
pip install caveat-lang
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Python 3.9 or later. Wheels cover Linux x86_64 and aarch64 (glibc 2.28 or
|
|
78
|
+
later), macOS (arm64 and x86_64) and Windows x86_64. Elsewhere pip builds the
|
|
79
|
+
source distribution, which needs a Rust toolchain and takes a few minutes.
|
|
80
|
+
Each release has the npm package's version and carries the same runtime.
|
|
81
|
+
|
|
82
|
+
From a clone of the repository, with a Rust toolchain:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
pip install ./python
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
This builds the native module once (a few minutes).
|
|
89
|
+
|
|
90
|
+
## The API
|
|
91
|
+
|
|
92
|
+
`caveat.open(source)` loads a program and returns a `Session`;
|
|
93
|
+
`caveat.restore(source, save)` resumes one from `Session.save()` text, with
|
|
94
|
+
the exact source it came from. A session is a context manager. Restore takes a
|
|
95
|
+
state save of any size, and a save is not signed: bound the size of a save you
|
|
96
|
+
did not write, and keep saves where only your application writes them. A save
|
|
97
|
+
that a release up to 1.4.1 wrote of a bundle whose modules use `hold` or
|
|
98
|
+
`release` can need its reading named: pass `module_bindings="scoped"` or
|
|
99
|
+
`"legacy-hold-capture"` ([Save 0.1](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-save-0.1.md#module-binding-interpretation)).
|
|
100
|
+
|
|
101
|
+
`session.dispatch(event, payload)` sends one event. The payload holds exactly
|
|
102
|
+
the parameters the program declares for that event (`event observe
|
|
103
|
+
confidence ...;` takes `{"confidence": 85}`), and an event without parameters
|
|
104
|
+
takes none; anything else is rejected as `input/payload_invalid`. It returns:
|
|
105
|
+
|
|
106
|
+
- `Accepted`, with `.snapshot`, the session's state after the event, or
|
|
107
|
+
- `Rejected`, with `.origin`, `.code` and `.message`. The session is
|
|
108
|
+
unchanged. Origins and codes are those of
|
|
109
|
+
[Dispatch 0.1](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-dispatch-0.1.md).
|
|
110
|
+
|
|
111
|
+
Tell them apart with `isinstance(outcome, caveat.Rejected)`, which every type
|
|
112
|
+
checker understands; then `.code` and `.message`, or `.snapshot`, are typed.
|
|
113
|
+
In Python 3.10 and later, `match outcome:` with
|
|
114
|
+
`case caveat.Rejected(code=code):` reads the same. Each also has `.accepted`
|
|
115
|
+
(`True` or `False`), for printing and logging.
|
|
116
|
+
|
|
117
|
+
| Method | Returns |
|
|
118
|
+
| --- | --- |
|
|
119
|
+
| `dispatch(event, payload=None, *, agent=None)` | `Accepted` (snapshot) or `Rejected` |
|
|
120
|
+
| `dispatch_view(event, payload=None, *, fields=None, agent=None)` | `AcceptedView` (View 0.1, optionally only `fields`) or `Rejected` |
|
|
121
|
+
| `dispatch_view_delta(event, payload=None, *, agent=None)` | `AcceptedDelta` (View 0.2 delta) or `Rejected` |
|
|
122
|
+
| `snapshot()`, `snapshot_text()` | the state, as a dict or the runtime's text |
|
|
123
|
+
| `view(schema="0.1")`, `view_text(schema="0.1")` | the per-event view, 0.1 or 0.2 |
|
|
124
|
+
| `save(*, compact=False, positional=False)` | JSON text to store |
|
|
125
|
+
| `drain_archive()`, `undrained` | departed records ([departure](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-departure-0.1.md)) |
|
|
126
|
+
| `close()` | nothing; the session is closed |
|
|
127
|
+
| `state` | "open", "closed" or "fatal" |
|
|
128
|
+
|
|
129
|
+
Module functions: `check(source, *, unused=False, records=False, save=None)`
|
|
130
|
+
returns the advisory report, `interface(source)` the program's events and
|
|
131
|
+
names, and `decision_history(snapshot_or_view, decision)` every revision of a
|
|
132
|
+
decision series with what it was committed on and what reopened it.
|
|
133
|
+
|
|
134
|
+
Errors are `CaveatError` subclasses: `LoadError` (the program does not load),
|
|
135
|
+
`RestoreError` (the save does not restore with this source), `PayloadError`
|
|
136
|
+
(the payload cannot be sent as JSON; nothing changed), `FatalError` (the
|
|
137
|
+
session failed and cannot be used again), `ClosedError`, and `ThreadError`
|
|
138
|
+
(the session was used from another thread; nothing changed). A rejected event
|
|
139
|
+
is never an error.
|
|
140
|
+
|
|
141
|
+
The package is typed (`py.typed`) and checks clean under `mypy --strict` and
|
|
142
|
+
pyright. A session belongs to the thread that made it: open one session in
|
|
143
|
+
each thread that needs one. Free-threaded Python builds keep the GIL on while
|
|
144
|
+
the package is loaded.
|
|
145
|
+
|
|
146
|
+
### Agents
|
|
147
|
+
|
|
148
|
+
When a main agent and a sub-agent send events to one program, the program can
|
|
149
|
+
say which agent may send which event
|
|
150
|
+
([Agents 0.1](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-agents-0.1.md)),
|
|
151
|
+
and `agent=` says who sent each one:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
session.dispatch("sub_report", {"n": 3}, agent="sub")
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
An event from an agent the program does not allow is rejected as
|
|
158
|
+
`input/wrong_agent`, and an accepted event's records carry its agent.
|
|
159
|
+
|
|
160
|
+
### Payloads
|
|
161
|
+
|
|
162
|
+
A payload is a dict (or any mapping) of JSON values: None, bools, strings,
|
|
163
|
+
ints, floats, lists, tuples and mappings with string keys. Integer types such
|
|
164
|
+
as `numpy.int64` count as ints, and `numpy.float64` is a float. Numbers mean
|
|
165
|
+
what they mean to the npm kit: `1.0` is sent as `1`, as JavaScript sends it.
|
|
166
|
+
An int beyond 2\*\*53, a float that is not finite, a string with a lone
|
|
167
|
+
surrogate, and anything else raise `PayloadError`.
|
|
168
|
+
|
|
169
|
+
### In a notebook
|
|
170
|
+
|
|
171
|
+
An `Accepted` outcome and an open `Session` show as tables in Jupyter: the
|
|
172
|
+
program's bindings, and each decision with its status, what it rests on, its
|
|
173
|
+
caveats and what reopened it.
|
|
174
|
+
|
|
175
|
+
## An agent that records its decisions
|
|
176
|
+
|
|
177
|
+
[`examples/claim_checker.py`](https://github.com/WSattazahn/caveat-lang/blob/main/python/examples/claim_checker.py) is an agent that
|
|
178
|
+
checks a claim against a file with a tool, records the observation, and
|
|
179
|
+
approves the claim. The file then changes; the agent reads it again and
|
|
180
|
+
withdraws its observation, and Caveat reopens the approval while keeping what
|
|
181
|
+
it was made on:
|
|
182
|
+
|
|
183
|
+
```text
|
|
184
|
+
$ python examples/claim_checker.py --claude
|
|
185
|
+
First reading: the notes support the claim at 95.
|
|
186
|
+
observe: accepted
|
|
187
|
+
assess: accepted
|
|
188
|
+
verdict: approved
|
|
189
|
+
Second reading: the notes support the claim at 2.
|
|
190
|
+
retract: accepted
|
|
191
|
+
verdict: reopened
|
|
192
|
+
Decision log:
|
|
193
|
+
assessment@1 is reopened: committed at event 2 on observations@1; reopened at event 3 because of recheck
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`--claude` has Claude judge through the `claude` command; without it, a
|
|
197
|
+
keyword judge runs anywhere.
|
|
198
|
+
|
|
199
|
+
## Same bytes as the npm kit
|
|
200
|
+
|
|
201
|
+
`tests/test_differential.py` replays every scenario file in the repository
|
|
202
|
+
through the npm kit's WebAssembly runtime and through this package, and
|
|
203
|
+
requires identical output at every step: each dispatch outcome (turning
|
|
204
|
+
through the three dispatch forms), the final snapshot, both views, all three
|
|
205
|
+
saves and their restores, the archive, `check` and `interface`. It also
|
|
206
|
+
compares payload number text with JavaScript's on 8,000 values.
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
npm run build # the WebAssembly runtime, dist/pkg-reactive
|
|
210
|
+
pip install ./python
|
|
211
|
+
python -m unittest discover -s python/tests -v
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Without Node or the WebAssembly build, the differential tests skip; set
|
|
215
|
+
`CAVEAT_DIFFERENTIAL=1` to make that a failure.
|
|
216
|
+
|
|
217
|
+
## Supply chain
|
|
218
|
+
|
|
219
|
+
- No Python dependencies. The native module compiles the runtime crate
|
|
220
|
+
(`runtime/`) with the locked crate versions the WebAssembly build uses
|
|
221
|
+
(`python/Cargo.lock` adds only PyO3 and what it needs).
|
|
222
|
+
- Each wheel carries a CycloneDX bill of materials for the Rust crates in it,
|
|
223
|
+
at `caveat_lang-VERSION.dist-info/sboms/` (PEP 770).
|
|
224
|
+
- The crates' license notices are in
|
|
225
|
+
[THIRD_PARTY_NOTICES.md](https://github.com/WSattazahn/caveat-lang/blob/main/python/THIRD_PARTY_NOTICES.md), generated by
|
|
226
|
+
`node scripts/third-party-notices.mjs --python`.
|
|
227
|
+
- One wheel per platform serves every CPython from 3.9 on (the stable ABI,
|
|
228
|
+
abi3). The source distribution carries the runtime's source and builds
|
|
229
|
+
alone with maturin and a Rust toolchain, as conda-forge's Rust packages
|
|
230
|
+
do, and its tests run from it.
|
|
231
|
+
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# CAVEAT Language for Python
|
|
2
|
+
|
|
3
|
+
A decision ledger for agents: Caveat keeps an AI's reasons in a record you can check. A Caveat program records what each decision
|
|
4
|
+
rests on: values carry their evidence and caveats, a decision keeps the
|
|
5
|
+
grounds it was made on, and when evidence is withdrawn, the decisions that
|
|
6
|
+
rested on it reopen, with their original grounds still on record.
|
|
7
|
+
|
|
8
|
+
This package runs the same Rust runtime as the
|
|
9
|
+
[`caveat-lang`](https://www.npmjs.com/package/caveat-lang) npm package,
|
|
10
|
+
compiled for Python instead of WebAssembly. It returns the same bytes: every
|
|
11
|
+
outcome, snapshot, view and save matches the npm kit on the repository's
|
|
12
|
+
whole scenario corpus (see [Same bytes as the npm kit](#same-bytes-as-the-npm-kit)).
|
|
13
|
+
It has no Python dependencies.
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import caveat_lang as caveat
|
|
17
|
+
|
|
18
|
+
with open("assessment.cav", encoding="utf-8") as file:
|
|
19
|
+
source = file.read()
|
|
20
|
+
|
|
21
|
+
with caveat.open(source) as session:
|
|
22
|
+
session.dispatch("observe", {"confidence": 85}) # a tool observation
|
|
23
|
+
outcome = session.dispatch("assess") # a decision that rests on it
|
|
24
|
+
print(isinstance(outcome, caveat.Accepted)) # True
|
|
25
|
+
|
|
26
|
+
session.dispatch("retract") # the observation was wrong
|
|
27
|
+
for revision in caveat.decision_history(session.snapshot(), "assessment"):
|
|
28
|
+
print(revision["revision"], revision["status"], revision["committed"]["because"])
|
|
29
|
+
# assessment@1 reopened ['observations@1']
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The language itself is documented with the npm kit:
|
|
33
|
+
[Caveat on one page](https://github.com/WSattazahn/caveat-lang/blob/main/kit/docs/REFERENCE.md) and the
|
|
34
|
+
[worked example](https://github.com/WSattazahn/caveat-lang/blob/main/kit/docs/WORKED_EXAMPLE.md).
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
pip install caveat-lang
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Python 3.9 or later. Wheels cover Linux x86_64 and aarch64 (glibc 2.28 or
|
|
43
|
+
later), macOS (arm64 and x86_64) and Windows x86_64. Elsewhere pip builds the
|
|
44
|
+
source distribution, which needs a Rust toolchain and takes a few minutes.
|
|
45
|
+
Each release has the npm package's version and carries the same runtime.
|
|
46
|
+
|
|
47
|
+
From a clone of the repository, with a Rust toolchain:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
pip install ./python
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This builds the native module once (a few minutes).
|
|
54
|
+
|
|
55
|
+
## The API
|
|
56
|
+
|
|
57
|
+
`caveat.open(source)` loads a program and returns a `Session`;
|
|
58
|
+
`caveat.restore(source, save)` resumes one from `Session.save()` text, with
|
|
59
|
+
the exact source it came from. A session is a context manager. Restore takes a
|
|
60
|
+
state save of any size, and a save is not signed: bound the size of a save you
|
|
61
|
+
did not write, and keep saves where only your application writes them. A save
|
|
62
|
+
that a release up to 1.4.1 wrote of a bundle whose modules use `hold` or
|
|
63
|
+
`release` can need its reading named: pass `module_bindings="scoped"` or
|
|
64
|
+
`"legacy-hold-capture"` ([Save 0.1](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-save-0.1.md#module-binding-interpretation)).
|
|
65
|
+
|
|
66
|
+
`session.dispatch(event, payload)` sends one event. The payload holds exactly
|
|
67
|
+
the parameters the program declares for that event (`event observe
|
|
68
|
+
confidence ...;` takes `{"confidence": 85}`), and an event without parameters
|
|
69
|
+
takes none; anything else is rejected as `input/payload_invalid`. It returns:
|
|
70
|
+
|
|
71
|
+
- `Accepted`, with `.snapshot`, the session's state after the event, or
|
|
72
|
+
- `Rejected`, with `.origin`, `.code` and `.message`. The session is
|
|
73
|
+
unchanged. Origins and codes are those of
|
|
74
|
+
[Dispatch 0.1](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-dispatch-0.1.md).
|
|
75
|
+
|
|
76
|
+
Tell them apart with `isinstance(outcome, caveat.Rejected)`, which every type
|
|
77
|
+
checker understands; then `.code` and `.message`, or `.snapshot`, are typed.
|
|
78
|
+
In Python 3.10 and later, `match outcome:` with
|
|
79
|
+
`case caveat.Rejected(code=code):` reads the same. Each also has `.accepted`
|
|
80
|
+
(`True` or `False`), for printing and logging.
|
|
81
|
+
|
|
82
|
+
| Method | Returns |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `dispatch(event, payload=None, *, agent=None)` | `Accepted` (snapshot) or `Rejected` |
|
|
85
|
+
| `dispatch_view(event, payload=None, *, fields=None, agent=None)` | `AcceptedView` (View 0.1, optionally only `fields`) or `Rejected` |
|
|
86
|
+
| `dispatch_view_delta(event, payload=None, *, agent=None)` | `AcceptedDelta` (View 0.2 delta) or `Rejected` |
|
|
87
|
+
| `snapshot()`, `snapshot_text()` | the state, as a dict or the runtime's text |
|
|
88
|
+
| `view(schema="0.1")`, `view_text(schema="0.1")` | the per-event view, 0.1 or 0.2 |
|
|
89
|
+
| `save(*, compact=False, positional=False)` | JSON text to store |
|
|
90
|
+
| `drain_archive()`, `undrained` | departed records ([departure](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-departure-0.1.md)) |
|
|
91
|
+
| `close()` | nothing; the session is closed |
|
|
92
|
+
| `state` | "open", "closed" or "fatal" |
|
|
93
|
+
|
|
94
|
+
Module functions: `check(source, *, unused=False, records=False, save=None)`
|
|
95
|
+
returns the advisory report, `interface(source)` the program's events and
|
|
96
|
+
names, and `decision_history(snapshot_or_view, decision)` every revision of a
|
|
97
|
+
decision series with what it was committed on and what reopened it.
|
|
98
|
+
|
|
99
|
+
Errors are `CaveatError` subclasses: `LoadError` (the program does not load),
|
|
100
|
+
`RestoreError` (the save does not restore with this source), `PayloadError`
|
|
101
|
+
(the payload cannot be sent as JSON; nothing changed), `FatalError` (the
|
|
102
|
+
session failed and cannot be used again), `ClosedError`, and `ThreadError`
|
|
103
|
+
(the session was used from another thread; nothing changed). A rejected event
|
|
104
|
+
is never an error.
|
|
105
|
+
|
|
106
|
+
The package is typed (`py.typed`) and checks clean under `mypy --strict` and
|
|
107
|
+
pyright. A session belongs to the thread that made it: open one session in
|
|
108
|
+
each thread that needs one. Free-threaded Python builds keep the GIL on while
|
|
109
|
+
the package is loaded.
|
|
110
|
+
|
|
111
|
+
### Agents
|
|
112
|
+
|
|
113
|
+
When a main agent and a sub-agent send events to one program, the program can
|
|
114
|
+
say which agent may send which event
|
|
115
|
+
([Agents 0.1](https://github.com/WSattazahn/caveat-lang/blob/main/spec/caveat-agents-0.1.md)),
|
|
116
|
+
and `agent=` says who sent each one:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
session.dispatch("sub_report", {"n": 3}, agent="sub")
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
An event from an agent the program does not allow is rejected as
|
|
123
|
+
`input/wrong_agent`, and an accepted event's records carry its agent.
|
|
124
|
+
|
|
125
|
+
### Payloads
|
|
126
|
+
|
|
127
|
+
A payload is a dict (or any mapping) of JSON values: None, bools, strings,
|
|
128
|
+
ints, floats, lists, tuples and mappings with string keys. Integer types such
|
|
129
|
+
as `numpy.int64` count as ints, and `numpy.float64` is a float. Numbers mean
|
|
130
|
+
what they mean to the npm kit: `1.0` is sent as `1`, as JavaScript sends it.
|
|
131
|
+
An int beyond 2\*\*53, a float that is not finite, a string with a lone
|
|
132
|
+
surrogate, and anything else raise `PayloadError`.
|
|
133
|
+
|
|
134
|
+
### In a notebook
|
|
135
|
+
|
|
136
|
+
An `Accepted` outcome and an open `Session` show as tables in Jupyter: the
|
|
137
|
+
program's bindings, and each decision with its status, what it rests on, its
|
|
138
|
+
caveats and what reopened it.
|
|
139
|
+
|
|
140
|
+
## An agent that records its decisions
|
|
141
|
+
|
|
142
|
+
[`examples/claim_checker.py`](https://github.com/WSattazahn/caveat-lang/blob/main/python/examples/claim_checker.py) is an agent that
|
|
143
|
+
checks a claim against a file with a tool, records the observation, and
|
|
144
|
+
approves the claim. The file then changes; the agent reads it again and
|
|
145
|
+
withdraws its observation, and Caveat reopens the approval while keeping what
|
|
146
|
+
it was made on:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
$ python examples/claim_checker.py --claude
|
|
150
|
+
First reading: the notes support the claim at 95.
|
|
151
|
+
observe: accepted
|
|
152
|
+
assess: accepted
|
|
153
|
+
verdict: approved
|
|
154
|
+
Second reading: the notes support the claim at 2.
|
|
155
|
+
retract: accepted
|
|
156
|
+
verdict: reopened
|
|
157
|
+
Decision log:
|
|
158
|
+
assessment@1 is reopened: committed at event 2 on observations@1; reopened at event 3 because of recheck
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`--claude` has Claude judge through the `claude` command; without it, a
|
|
162
|
+
keyword judge runs anywhere.
|
|
163
|
+
|
|
164
|
+
## Same bytes as the npm kit
|
|
165
|
+
|
|
166
|
+
`tests/test_differential.py` replays every scenario file in the repository
|
|
167
|
+
through the npm kit's WebAssembly runtime and through this package, and
|
|
168
|
+
requires identical output at every step: each dispatch outcome (turning
|
|
169
|
+
through the three dispatch forms), the final snapshot, both views, all three
|
|
170
|
+
saves and their restores, the archive, `check` and `interface`. It also
|
|
171
|
+
compares payload number text with JavaScript's on 8,000 values.
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
npm run build # the WebAssembly runtime, dist/pkg-reactive
|
|
175
|
+
pip install ./python
|
|
176
|
+
python -m unittest discover -s python/tests -v
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Without Node or the WebAssembly build, the differential tests skip; set
|
|
180
|
+
`CAVEAT_DIFFERENTIAL=1` to make that a failure.
|
|
181
|
+
|
|
182
|
+
## Supply chain
|
|
183
|
+
|
|
184
|
+
- No Python dependencies. The native module compiles the runtime crate
|
|
185
|
+
(`runtime/`) with the locked crate versions the WebAssembly build uses
|
|
186
|
+
(`python/Cargo.lock` adds only PyO3 and what it needs).
|
|
187
|
+
- Each wheel carries a CycloneDX bill of materials for the Rust crates in it,
|
|
188
|
+
at `caveat_lang-VERSION.dist-info/sboms/` (PEP 770).
|
|
189
|
+
- The crates' license notices are in
|
|
190
|
+
[THIRD_PARTY_NOTICES.md](https://github.com/WSattazahn/caveat-lang/blob/main/python/THIRD_PARTY_NOTICES.md), generated by
|
|
191
|
+
`node scripts/third-party-notices.mjs --python`.
|
|
192
|
+
- One wheel per platform serves every CPython from 3.9 on (the stable ABI,
|
|
193
|
+
abi3). The source distribution carries the runtime's source and builds
|
|
194
|
+
alone with maturin and a Rust toolchain, as conda-forge's Rust packages
|
|
195
|
+
do, and its tests run from it.
|