DL-13: Implement Axiom CRUD operations for world rules#95
Conversation
| \nTests not detected in this PR. Please add/confirm coverage where applicable. |
Co-authored-by: spuentesp <112034353+spuentesp@users.noreply.github.com>
…pet handling Co-authored-by: spuentesp <112034353+spuentesp@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements CRUD operations for Axiom nodes in Neo4j, enabling management of foundational world rules and constraints at the universe level. Axioms represent higher-order rules like "magic requires verbal components" or "vampires burn in sunlight" that differ from Facts by being universe-level constraints rather than instance-specific state.
Key changes:
- Five Neo4j operations (create, get, list, update, delete) with batched UNWIND for efficient multi-source edge creation
- New
AxiomDomainenum for categorizing rules (physics, magic, society, metaphysics) - Soft-delete via canon_level retconning preserves historical context while hard-delete option allows permanent removal
- Comprehensive test suite with 21 unit tests covering all CRUD operations, domain variations, and error cases
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/data-layer/src/monitor_data/schemas/axioms.py | Defines Pydantic schemas for Axiom CRUD operations including AxiomCreate, AxiomUpdate, AxiomResponse, and AxiomFilter with validation rules |
| packages/data-layer/src/monitor_data/schemas/base.py | Adds AxiomDomain enum with four domain classifications (physics, magic, society, metaphysics) for categorizing world rules |
| packages/data-layer/src/monitor_data/tools/neo4j_tools.py | Implements five Axiom operations with batched UNWIND edge creation, parameterized queries for safety, and soft/hard delete support |
| packages/data-layer/src/monitor_data/middleware/auth.py | Adds authorization entries restricting update and delete operations to CanonKeeper role |
| packages/data-layer/tests/test_tools/test_axiom_tools.py | Provides 21 unit tests covering all operations, domain variations, provenance chains, and error scenarios using mocked Neo4j client |
| .gitignore | Adds coverage.json to ignored files for test coverage tooling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| result = neo4j_create_axiom(params) | ||
|
|
||
| assert result.source_ids == [source_id] | ||
| assert result.snippet_ids == ["snippet_123"] |
There was a problem hiding this comment.
This test assertion does not reflect the actual behavior of the implementation. The neo4j_get_axiom function always returns an empty list for snippet_ids (see line 2497 in neo4j_tools.py), but this test passes because neo4j_get_axiom is mocked to return snippet_ids=["snippet_123"].
The test should either:
- Assert that
snippet_idsis an empty list to match the actual behavior, OR - If snippet_ids should be preserved, the implementation should be updated to store them as a node property
|
Closing to redo from scratch per project decision |
Adds Neo4j operations for managing Axioms—foundational world rules like "magic requires verbal components" or "vampires burn in sunlight." Axioms differ from Facts by being universe-level constraints rather than instance-specific state.
Implementation
Data Model
(:Axiom)node withdomainenum (physics, magic, society, metaphysics)(:Universe)-[:HAS_AXIOM]->(:Axiom)hierarchy(:Axiom)-[:SUPPORTED_BY]->(:Source)provenance chaincanon_level: retconnedpreserves historyOperations (Layer 1)
neo4j_create_axiom- validates universe, batches SUPPORTED_BY edges via UNWINDneo4j_get_axiom- returns with provenance chainneo4j_list_axioms- filters by universe/domain/confidenceneo4j_update_axiom- mutable fields only, early-returns on empty paramsneo4j_delete_axiom- soft by default,force=Truefor hardAuthority
Schemas (
monitor_data.schemas.axioms)Notes
snippet_idsstored as metadata only—they reference MongoDB documents, not Neo4j nodesOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.