저장, revision, lineage
구현 저장소: BackwardLabs/daejang-db @ 26904fb
PostgreSQL DDL, migration, 공개 Go client가 구현되어 있다. revision, lineage, outcome과 실패 상태를 덮어쓰지 않고 보존한다.
저장 영역
| 영역 | 내용 |
|---|---|
| Artifact | content-addressed artifact와 reference·pin metadata |
| JIT | run, command queue, candidate outcome, inclusion revision, execution cache, outbox |
| Subject evidence | evidence fragment, observation, disposition |
| Chain·source evidence | evidence bundle과 lineage, revision |
| Ledger | assertion, hypothesis, interpreted event, event revision |
| Posting | leg, posting, valuation, reconciliation |
| Lot | lot run, allocation, basis, current pointer, outbox |
공개 Go package
| Package | 범위 |
|---|---|
artifactstore | content-addressed artifact와 pinning |
evidencestore | chain·source evidence bundle, lineage, revision |
jitstore | JIT run, command queue, candidate outcome, execution cache |
ledgerstore | assertion, hypothesis, interpreted event, posting, valuation |
lotstore | lot run, allocation, basis, current pointer |
저장과 계산은 다르다
ledgerstore와 lotstore가 있다는 사실은 Event 엔진이나 lot 계산 엔진이 있다는 뜻이 아니다.
DB는 경제적 Event, Posting, valuation, 취득가액을 저장할 수 있다. 그중 어느 것도 계산하지 않는다. 그 값을 만들어낼 runtime은 계획이다. Event, Posting, Valuation과 세무 원가와 리포트를 참고하라.
이 구분은 ledger와 lot package를 설명할 때도 그대로 적용한다.
Content addressing
artifact는 내용의 SHA-256으로 주소를 갖는다. 공개 execution artifact는 provider 실행 증거만 담으며 subjectId, account ID, ownership window를 포함해서는 안 된다. 이 규칙이 있어야 같은 execution artifact를 여러 사용자의 account가 공유하면서도 그 관계를 노출하지 않는다. 보안과 개인정보를 참고하라.
Revision과 lineage
revision은 결과가 바뀐 이유를 남긴다.
- Inclusion revision은 이전 inclusion을 대체하지 않고 reorg 이력을 기록한다.
- Evidence bundle lineage는 bundle이 무엇을 대체하는지와 그 이유를 연결한다.
- Outcome 저장은 실패를 포함한 terminal state를 저장하므로, coverage를 낙관적으로 재계산하지 않고 저장된 outcome에서 유도한다.
- Outbox table은 JIT와 lot 경로에서 dual-write 불일치 없이 신뢰할 수 있는 downstream 전달을 지원한다.
이들이 함께 기술 개요에 서술한 revision integrity 원칙을 뒷받침한다. 입력, 정책, 판단이 바뀌면 이전 결과를 덮어쓰지 않고 변경 원인을 기록한 새 revision을 만든다.
검증
기본 브랜치에서 make check, go test ./..., go vet ./..., go build ./...가 통과한다.
PostgreSQL integration test는 환경에 DAEJANG_DB_TEST_POSTGRES_URL 또는 ledger 전용 URL이 있을 때만 실행된다. 위 통과 결과만으로는 live PostgreSQL integration을 확인할 수 없다.
JIT → schema 검증 → PostgreSQL 저장의 재현 가능한 시연은 현재 제약에 필요한 증빙으로 정리했다.