Skip to content

feat: Trust Model v2 — 4-state unification (v0.2.0)#1

Merged
typelicious merged 4 commits into
mainfrom
feat/cap-009-trust-unification
May 24, 2026
Merged

feat: Trust Model v2 — 4-state unification (v0.2.0)#1
typelicious merged 4 commits into
mainfrom
feat/cap-009-trust-unification

Conversation

@typelicious

Copy link
Copy Markdown
Contributor

Summary

  • Trust Model v2: Unified from 6 states to 4 (discovered → audited → verified → signed)
  • Legacy Mapping: LEGACY_STATE_MAP with normalize_legacy_state() for backward compat (indexed→audited, claimed→verified)
  • TrustMachine: State machine with transition(), promote(), demote(), reason tracking
  • Search Fix: min_trust_state filter normalizes legacy states and includes aliases in SQL IN clause

Test plan

  • 64 tests passing, 0 failures
  • Verify legacy state normalization in Exchange integration
  • Verify search filter with mixed legacy/v2 trust states in DB

André Lange added 4 commits May 24, 2026 12:41
CAP-009: Replace 5-state trust model with cleaner 4-state progression.
  - Remove indexed/claimed states, add signed state
  - Add normalize_legacy_state() for backward compatibility
  - Update entry criteria: audited requires canonical_name+description,
    signed requires fingerprint+signature
  - Expand test coverage for new state transitions
Update trust.py to 4-state model (discovered→audited→verified→signed).
Add normalize_legacy_state() as both module function and TrustMachine method.
Fix test assertion for removed indexed_at behavior.
All 55 tests pass.
Search with min_trust_state now handles legacy states (indexed→audited,
claimed→verified) and includes legacy aliases in the IN clause so rows
with legacy state values still match.
New CHANGELOG.md documenting trust model v2 (4-state unification),
legacy state normalization, TrustMachine, and search filter fix.
Version bump from 0.1.0 to 0.2.0.
@typelicious typelicious merged commit 2a5b95d into main May 24, 2026
3 checks passed
typelicious pushed a commit that referenced this pull request Jun 3, 2026
Closes the "17 pre-existing TrustState.AUDITED failures" technical debt
flagged in launch-prd.md §10 risk register. Tests now align with the
v2 5-state model from PR #1 (Trust Model v2 — 4-state unification).

Changes:
- TrustState.AUDITED → TrustState.PENDING_REVIEW (19 references)
- "audited" string literals → "pending_review" (10 references)
- ordering test: len 4 → 5, last item SIGNED → DEPRECATED
- Method renames for clarity:
  test_transition_discovered_to_audited
    → test_transition_discovered_to_pending_review
  test_transition_audited_to_verified_(requires|with)_publisher
    → test_transition_pending_review_to_verified_*
  test_downgrade_verified_to_audited
    → test_downgrade_verified_to_pending_review
  test_downgrade_audited_to_discovered
    → test_downgrade_pending_review_to_discovered
  test_entry_criteria_audited → test_entry_criteria_pending_review
- normalize_legacy_state tests updated to reflect actual mapping:
  "indexed" → "pending_review" (was incorrectly expecting "audited")
  passthrough test uses "pending_review" (since "audited" is now
  a mapped legacy state, not a passthrough)

Verified: PYTHONPATH=src pytest tests/test_models.py → 55 passed (was
collecting 0 with errors). One legacy docstring at line 223 still
references "audited" as historical context — intentional.

Side-finding (not in this PR): src/capacium_models/models.py has 5
datetime.utcnow() calls; FIX-G-004 missed them. Will be tracked in
separate cleanup issue.
typelicious added a commit that referenced this pull request Jun 3, 2026
#2)

* fix(stream-f): centralize trust badges + 5-state vocab (FIX-F-001, FIX-F-002)

- Add TRUST_BADGES dict with 5-state v2 canonical labels:
  discovered, pending_review, verified, signed, deprecated
- Add get_trust_badge() helper with legacy state normalization
  (audited → pending_review, claimed → verified)
- Re-export from package __init__ for downstream consumers
  (capacium-exchange, capacium-mcp, capacium-bridge)

Single source of truth prevents vocabulary drift across surfaces.
Required by FIX-F-001 (centralize trust badges in capacium-models).

* test: migrate test_models.py from v1 4-state to v2 5-state vocabulary

Closes the "17 pre-existing TrustState.AUDITED failures" technical debt
flagged in launch-prd.md §10 risk register. Tests now align with the
v2 5-state model from PR #1 (Trust Model v2 — 4-state unification).

Changes:
- TrustState.AUDITED → TrustState.PENDING_REVIEW (19 references)
- "audited" string literals → "pending_review" (10 references)
- ordering test: len 4 → 5, last item SIGNED → DEPRECATED
- Method renames for clarity:
  test_transition_discovered_to_audited
    → test_transition_discovered_to_pending_review
  test_transition_audited_to_verified_(requires|with)_publisher
    → test_transition_pending_review_to_verified_*
  test_downgrade_verified_to_audited
    → test_downgrade_verified_to_pending_review
  test_downgrade_audited_to_discovered
    → test_downgrade_pending_review_to_discovered
  test_entry_criteria_audited → test_entry_criteria_pending_review
- normalize_legacy_state tests updated to reflect actual mapping:
  "indexed" → "pending_review" (was incorrectly expecting "audited")
  passthrough test uses "pending_review" (since "audited" is now
  a mapped legacy state, not a passthrough)

Verified: PYTHONPATH=src pytest tests/test_models.py → 55 passed (was
collecting 0 with errors). One legacy docstring at line 223 still
references "audited" as historical context — intentional.

Side-finding (not in this PR): src/capacium_models/models.py has 5
datetime.utcnow() calls; FIX-G-004 missed them. Will be tracked in
separate cleanup issue.

---------

Co-authored-by: André Lange <andre.lange@typelicious.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant