| title | Issue #25 Completion Report: COP/Accounting Conformance Kernel | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| author | Jean Hugues Robert | |||||||||||
| affiliation | Institut Mariani / C.O.R.S.I.C.A. | |||||||||||
| license | CC BY-SA 4.0 | |||||||||||
| language | en | |||||||||||
| date | 2026-07-23 | |||||||||||
| last_modified_at | 2026-09-08 | |||||||||||
| status | stable | |||||||||||
| document_role | operational | |||||||||||
| document_kind | completion-report | |||||||||||
| visibility | public | |||||||||||
| lifecycle_state | active | |||||||||||
| update_policy | UP-DEFAULT-REVIEWED | |||||||||||
| canonical_url | https://github.com/JeanHuguesRobert/inseme/blob/main/ISSUE_25_COMPLETION_REPORT.md | |||||||||||
| related_issues | ||||||||||||
| provenance |
|
|||||||||||
| review |
|
packages/cop-core/src/accounting.ts(new) - TypeScript protocol typespackages/cop-core/src/index.ts(modified) - Export accounting modulepackages/cop-core/schemas/accounting/base.schema.json(new)packages/cop-core/schemas/accounting/event.budget.schema.json(new)packages/cop-core/schemas/accounting/event.reservation.schema.json(new)packages/cop-core/schemas/accounting/event.transaction.schema.json(new)packages/cop-core/schemas/accounting/event.reversal.schema.json(new)packages/cop-core/schemas/accounting/event.account.schema.json(new)
packages/cop-kernel/src/accounting/quantity.js(new) - Exact quantity arithmeticpackages/cop-kernel/src/accounting/validator.js(new) - Event validationpackages/cop-kernel/src/accounting/projector.js(new) - Deterministic projectionpackages/cop-kernel/src/accounting/index.js(new) - Kernel entry pointpackages/cop-kernel/src/index.js(modified) - Export accounting modulepackages/cop-kernel/test/accounting.test.js(new) - Conformance tests
# Build cop-core with new types
pnpm --filter @inseme/cop-core build
# Run cop-kernel tests (including new accounting conformance tests)
pnpm --filter @inseme/cop-kernel test- Total tests: 179
- Passed: 179
- Failed: 0
- Accounting conformance tests: 32 (all passing)
- Defined TypeScript types for all accounting events (Budget, Reservation, Transaction, Reversal, Account)
- ExactQuantity type using decimal coefficient + scale (no binary floating-point)
- GovernanceContext with actor/principal separation and mandate linkage
- Projection types (AccountBalance, BudgetStatus, ReservationStatus, PublicKudosProjection)
base.schema.json- Shared definitions (ExactQuantity, AccountIdentifier, Posting, etc.)event.budget.schema.json- Budget grant/amend/revokeevent.reservation.schema.json- Reservation with TTL and budget referenceevent.transaction.schema.json- Balanced transactions with postingsevent.reversal.schema.json- Full/partial/compensating reversalsevent.account.schema.json- Account lifecycle (create/modify/suspend/close)
- Event-specific validators for each accounting event type
- Balanced posting validation (debits = credits within unit/domain)
- Cross-unit rejection without explicit conversion_rate
- Mandate compliance checking (actor vs principal)
- Budget availability checking for reservations
- Idempotency enforcement via idempotency keys
- Account identifier validation (HTTPS URL, URN, local, kudos formats)
projectAccountBalances()- Derive account balances from transactions/reversalsprojectBudgetStatus()- Track budget granted/available/reserved/committed/spentprojectReservationStatus()- Track reservation lifecycleprojectPublicKudos()- Privacy-preserving public projection- Deterministic replay (sorted by timestamp)
- Idempotency (duplicate events skipped)
- No binary floating-point for authoritative quantities
compareQuantities(),addQuantities(),subtractQuantities()fromDecimal(),toDecimal()round-trip conversion- Scale-aware operations
All 12 required conformance tests pass:
- ✅ Balanced transaction accepted - Debits equal credits
- ✅ Unbalanced transaction rejected - Atomically rejected
- ✅ Cross-unit balancing rejected - Without explicit conversion_rate
- ✅ Duplicate delivery - Idempotency, one accounting effect
- ✅ Competing reservations - Cannot overspend budget
- ✅ Expired/revoked mandates rejected - Budget status checked
- ✅ Reversal neutralizes effect - Without deletion
- ✅ Unauthorized creation/destruction rejected - Source/sink requires mandate
- ✅ Deterministic replay - Identical state from events
- ✅ HTTPS account URL accepted -
https://jhn.baronsmariani.org/ - ✅ Public Kudos projection - Excludes private details
- ✅ Short lifecycle representation - No micro-events required
- Immutability - Events and Artifacts never modified; corrections via new events
- Topic-local ordering - Events ordered by timestamp for deterministic replay
- Idempotency - Duplicate delivery has one effect (via processedIdempotencyKeys tracking)
- Durability - All state derivable from Events
- Stateless agents - Projector is pure function over event stream
- Isolation via events - No hidden mutable state; projection is deterministic
- Schema versioning - All events carry schemaVersion: "1.0"
- Transparency - Evidence references, mandate links, disclosure classes explicit
-
Reversal of type "full" without compensating_postings - Currently only processes compensating reversals with explicit postings. Full reversals would require storing original transactions for lookup.
-
Account identifier format validation - Basic regex check (HTTPS URL, URN, local, kudos) but no full URL dereferencing or SEO metadata.
-
Conversion rate validation - Presence of conversion_rate checked but rate value validation not implemented.
-
Evidence artifact dereferencing - References stored but artifacts not fetched/verified.
-
Real-time enforcement - No atomic locking for concurrent reservations; relies on idempotency and re-verification.
-
Schema versioning - Need to define migration path when "1.0" → "1.1"
-
Cross-unit conversion - Authorized conversions need governance model (who authorizes, how)
-
Public projection semantics - May need refinement for edge cases (mixed domain transactions)
-
Performance - Large event streams may need checkpointing/snapshotting
- Add COP_ACCOUNTING.md specification document (referenced but not created)
- Implement checkpoint/resume for long-running projections
- Add integration tests with real COP Store backend
- Define governance workflow for conversion rate authorizations
- Add CLI tooling for accounting state queries
Agent: Claude (Opus 4.8) Principal: Jean Hugues Robert Mandate: inseme issue #25 (bounded implementation) Checks:
- All tests pass (179/179)
- No new durable primitives introduced (Events/Artifacts only)
- Projection is storage-independent
- TypeScript compiles without errors
Human validation needed: Yes - Please review:
- Schema completeness for your use cases
- Account identifier formats (
https://jhn.baronsmariani.org/) - Public projection privacy semantics
- Evidence reference model