Skip to content

Implement Axiom CRUD operations for Neo4j canonical layer#64

Closed
Copilot wants to merge 4 commits into
masterfrom
copilot/manage-axiom-nodes
Closed

Implement Axiom CRUD operations for Neo4j canonical layer#64
Copilot wants to merge 4 commits into
masterfrom
copilot/manage-axiom-nodes

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 28, 2025

Adds support for managing Axiom nodes representing foundational world rules (e.g., "magic requires verbal components", "FTL travel impossible"). Axioms enable rules engines and GM assistants to validate narrative consistency against universe constraints.

Changes

Schema (packages/data-layer/src/monitor_data/schemas/axioms.py)

  • AxiomDomain enum: physics, magic, society, metaphysics
  • AxiomCreate/Update/Response/Filter models with provenance support
  • Confidence range filtering for probabilistic world rules

Operations (packages/data-layer/src/monitor_data/tools/neo4j_tools.py)

  • neo4j_create_axiom: Creates axiom with HAS_AXIOM and SUPPORTED_BY edges
  • neo4j_get_axiom: Retrieves with optional provenance chain
  • neo4j_list_axioms: Filters by universe, domain, confidence range
  • neo4j_update_axiom: Updates statement, confidence, canon_level
  • neo4j_delete_axiom: Soft-delete via canon_level='retconned'

Authority (packages/data-layer/src/monitor_data/middleware/auth.py)

  • Write operations: CanonKeeper only
  • Read operations: All agents

Example

# Create axiom with source provenance
axiom = neo4j_create_axiom(AxiomCreate(
    universe_id=uuid,
    statement="Magic requires verbal components",
    domain=AxiomDomain.MAGIC,
    confidence=0.95,
    source_ids=[rulebook_id]  # Links to authoritative sources
))

# Query axioms by domain with confidence threshold
axioms = neo4j_list_axioms(AxiomFilter(
    universe_id=uuid,
    domain=AxiomDomain.PHYSICS,
    confidence_min=0.8
))

Coverage

16 tests covering CRUD lifecycle, provenance chains, domain variants, and error cases. 97.8% line coverage on axiom operations.

Original prompt

This section details on the original issue you should resolve

<issue_title>DL-13: Manage Axioms</issue_title>
<issue_description>Category: data-layer | Epic: 0 | Priority: medium

Summary

Implement CRUD operations for Axiom nodes in Neo4j. Axioms are foundational
world rules and constraints tied to universes (e.g., "magic requires verbal
components", "vampires burn in sunlight"). Supports provenance via SUPPORTED_BY
edges to sources/snippets.

Acceptance Criteria

  • neo4j_create_axiom creates Axiom node linked to universe
  • neo4j_create_axiom validates universe_id exists
  • neo4j_create_axiom supports domain enum (physics, magic, society, metaphysics)
  • neo4j_create_axiom creates SUPPORTED_BY edges to sources/snippets
  • neo4j_get_axiom returns axiom with provenance chain
  • neo4j_list_axioms supports filtering by universe_id, domain, confidence
  • neo4j_update_axiom allows updating statement, confidence, canon_level
  • neo4j_delete_axiom removes axiom (soft-delete via canon_level='retconned')
  • All operations enforce CanonKeeper authority for writes
  • Unit tests achieve >= 80% coverage

Dependencies

This use case depends on:

  • DL-1
  • DL-8

Blocks

This use case blocks:

  • RS-1
  • CF-3

Implementation

Layer: 1

Files to create:

  • packages/data-layer/src/monitor_data/schemas/axioms.py
  • packages/data-layer/tests/test_tools/test_axiom_tools.py
    Files to modify:
  • packages/data-layer/src/monitor_data/tools/neo4j_tools.py
  • packages/data-layer/src/monitor_data/middleware/auth.py

NEO4J Operations:

  • neo4j_create_axiom (authority: CanonKeeper)
  • neo4j_get_axiom (authority: *)
  • neo4j_list_axioms (authority: *)
  • neo4j_update_axiom (authority: CanonKeeper)
  • neo4j_delete_axiom (authority: CanonKeeper)

Notes:

  • Axioms are world-building fundamentals (not specific facts)
  • Used by rules engine for consistency checking
  • Consider hierarchy (universal vs local axioms)
  • Retconned axioms remain for history but marked inactive

Testing Requirements

Minimum coverage: 80%

Unit tests:

  • test_create_axiom_success: valid params → Axiom node
  • test_create_axiom_with_provenance: source_ids → SUPPORTED_BY edges
  • test_create_axiom_domain: each domain value works
  • test_get_axiom_with_provenance: returns full chain
  • test_list_axioms_by_domain: domain filter works
  • ... and 3 more

Integration tests:

  • test_axiom_lifecycle: create → update → soft-delete
  • test_axiom_provenance: create with sources → verify chain

References

Documentation:


Generated from /home/sebas/monitor2/docs/use-cases/data-layer/DL-13.yml</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions github-actions Bot added the needs-tests No tests touched label Dec 28, 2025
@github-actions
Copy link
Copy Markdown

\nTests not detected in this PR. Please add/confirm coverage where applicable.

Copilot AI and others added 3 commits December 28, 2025 18:37
Co-authored-by: spuentesp <112034353+spuentesp@users.noreply.github.com>
Co-authored-by: spuentesp <112034353+spuentesp@users.noreply.github.com>
Co-authored-by: spuentesp <112034353+spuentesp@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement CRUD operations for Axiom nodes in Neo4j Implement Axiom CRUD operations for Neo4j canonical layer Dec 28, 2025
Copilot AI requested a review from spuentesp December 28, 2025 18:44
@spuentesp
Copy link
Copy Markdown
Owner

Closing stale draft PR - conflicts with current master. Will regenerate from current state when ready to implement.

@spuentesp spuentesp closed this Dec 29, 2025
@spuentesp spuentesp deleted the copilot/manage-axiom-nodes branch April 25, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-tests No tests touched

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DL-13: Manage Axioms

2 participants