stemedb/applications/aphoria/examples/import-template.toml
jml 7facac08a2 feat(aphoria): add enhanced bulk claim import with validation and reporting
Replaces tedious shell scripts with TOML-based bulk import:
- 340 lines bash → 200 lines TOML → 1 command
- 15 minutes → <1 second execution time
- 0% → 100% error detection before writes

Features:
- Pre-import validation (ID format, tiers, required fields, duplicates)
- Detailed reporting (table and JSON formats)
- Template generation (--template)
- Validation-only mode (--validate-only)
- Merge strategies (skip_existing, overwrite, fail_on_duplicate)

Documentation:
- Comprehensive guide: docs/guides/bulk-claim-import.md
- Updated README with quick start
- Example files with inline documentation

Validation catches:
- Invalid claim IDs (must be kebab-case)
- Unknown authority tiers
- Empty required fields
- Duplicate IDs within import file
- Duplicate concept paths (warnings)

Error reporting:
- Shows ALL errors before any writes (not just first failure)
- Clear context: claim index, ID, field, and error message
- Warnings for non-blocking issues

Testing:
- All clippy checks pass
- Production build succeeds
- Validated template generation, validation-only, dry-run, import, merge strategies

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 05:31:04 +00:00

125 lines
5.0 KiB
TOML

# Aphoria Claims Import Template
#
# This file demonstrates the TOML format for bulk claim import.
# Generate this template: aphoria claims import --template > my-claims.toml
#
# Import commands:
# aphoria claims import my-claims.toml --validate-only # Validate format
# aphoria claims import my-claims.toml --dry-run # Preview changes
# aphoria claims import my-claims.toml # Import for real
#
# Merge strategies:
# --merge skip_existing (default) Skip claims with duplicate IDs
# --merge overwrite Replace existing claims with same ID
# --merge fail_on_duplicate Exit with error if any ID exists
#
# Output formats:
# --format table (default) Human-readable with symbols
# --format json Machine-readable for tooling
# ============================================================================
# Example 1: Architecture Decision
# ============================================================================
[[claim]]
id = "myapp-core-no-tokio-001"
concept_path = "myapp/core/imports/tokio"
predicate = "imported"
value = false
comparison = "absent"
provenance = "Architecture decision by tech lead 2024-12-15"
invariant = "Core modules MUST remain sync-only"
consequence = "Importing tokio makes core async-only, breaking sync library users"
authority_tier = "expert"
evidence = ["ADR-003", "design review notes"]
category = "architecture"
status = "active"
created_by = "tech-lead"
created_at = "2024-12-15T10:00:00Z"
# ============================================================================
# Example 2: Security Requirement
# ============================================================================
[[claim]]
id = "myapp-http-tls-cert-validation-001"
concept_path = "myapp/httpclient/tls/certificate_validation"
predicate = "enabled"
value = true
comparison = "equals"
provenance = "OWASP A02:2021 - Cryptographic Failures"
invariant = "HTTP clients MUST validate TLS certificates"
consequence = "Disabled validation exposes MITM attacks"
authority_tier = "regulatory"
evidence = ["OWASP Top 10", "CWE-295"]
category = "security"
status = "active"
created_by = "security-team"
created_at = "2024-12-15T10:00:00Z"
# ============================================================================
# Example 3: Safety Invariant
# ============================================================================
[[claim]]
id = "myapp-pool-max-size-001"
concept_path = "myapp/pool/config/max_size"
predicate = "max_value"
value = 50
comparison = "equals"
provenance = "Load testing results 2024-12-10"
invariant = "Connection pool size MUST NOT exceed 50"
consequence = "Larger pools cause OOM under sustained load"
authority_tier = "expert"
evidence = ["tests/pool_tests.rs load test"]
category = "safety"
status = "active"
created_by = "sre-team"
created_at = "2024-12-15T10:00:00Z"
# ============================================================================
# Field Reference
# ============================================================================
#
# Required fields:
# id - Unique kebab-case identifier (e.g., "myapp-feature-001")
# concept_path - Hierarchical path to concept (e.g., "myapp/module/feature")
# predicate - Property being claimed (e.g., "enabled", "max_version")
# value - Expected value (bool, number, or "text")
# comparison - How to compare: equals, not_equals, present, absent, contains, not_contains
# provenance - Where this rule came from
# invariant - What MUST remain true
# consequence - What breaks if violated
# authority_tier - regulatory, clinical, observational, expert, community, anecdotal
# category - safety, architecture, security, imports, constants, derives, etc.
# created_by - Author name
# created_at - ISO 8601 timestamp
#
# Optional fields:
# evidence - Array of supporting references (default: [])
# status - active (default), deprecated, superseded
# supersedes - ID of claim this replaces
# updated_at - ISO 8601 timestamp of last update
#
# ============================================================================
# Comparison Modes
# ============================================================================
#
# equals - Value must exactly match
# not_equals - Value must differ
# present - Value must exist
# absent - Value must not exist
# contains - Value must contain substring/element
# not_contains - Value must not contain substring/element
#
# ============================================================================
# Authority Tiers (strongest to weakest)
# ============================================================================
#
# 1. regulatory - Legal/regulatory mandate (FDA, GDPR)
# 2. clinical - Peer-reviewed clinical evidence
# 3. observational - Real-world data, case studies
# 4. expert - Senior engineer/architect decision
# 5. community - Team consensus, convention
# 6. anecdotal - Individual experience, suggestion