Skip to content
Closed
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
318 commits
Select commit Hold shift + click to select a range
31e251d
docs(prd): separate API cancellation from planned CLI
seonghobae Aug 9, 2026
7d66406
test(docs): require foundational product ADRs
seonghobae Aug 9, 2026
53f32be
docs(adr): record PostgreSQL durable authority
seonghobae Aug 9, 2026
87df20b
docs(adr): record provider HTTP trust boundary
seonghobae Aug 9, 2026
9cdf269
docs(adr): record standalone composition boundary
seonghobae Aug 9, 2026
d16020a
docs(adr): record lifecycle observation authority
seonghobae Aug 9, 2026
e502665
docs(adr): index foundational product decisions
seonghobae Aug 9, 2026
cfcb149
docs(fitness): record foundational ADR coverage
seonghobae Aug 9, 2026
0a0ebc0
test(docs): require review evidence separation ADR
seonghobae Aug 9, 2026
bff15e3
docs(adr): separate review and infrastructure evidence
seonghobae Aug 9, 2026
ba5e697
docs(adr): index review evidence separation
seonghobae Aug 9, 2026
d316b0f
docs(traceability): map review evidence separation
seonghobae Aug 9, 2026
cc52d8e
fix(docs): align ADR status contract
seonghobae Aug 9, 2026
6eda0a4
test(docs): bind evidence separation to fitness matrix
seonghobae Aug 9, 2026
6e845ce
docs(fitness): track review evidence separation
seonghobae Aug 9, 2026
86291e7
test(docs): require acquisition licensing authority
seonghobae Aug 9, 2026
69f9b2a
docs: add acquisition licensing and IP authority
seonghobae Aug 9, 2026
973d99f
test(docs): bind licensing authority to existing release evidence
seonghobae Aug 9, 2026
8383a66
docs: classify licensing and IP acquisition authority
seonghobae Aug 9, 2026
6386dd5
docs: trace licensing and IP acquisition evidence
seonghobae Aug 9, 2026
d6a67b5
docs: make legal-review boundary machine-checkable
seonghobae Aug 9, 2026
e09668d
test(docs): reject permissive-only notice overclaim
seonghobae Aug 9, 2026
f68003a
docs: remove permissive-only dependency overclaim
seonghobae Aug 9, 2026
1fb05be
test(docs): require psycopg binary license boundary
seonghobae Aug 9, 2026
815bca8
docs: expose psycopg binary dependency boundary
seonghobae Aug 9, 2026
0672191
test(docs): require licensing release rejection gate
seonghobae Aug 9, 2026
a792549
docs: make licensing a release rejection gate
seonghobae Aug 9, 2026
fd0e93c
test(docs): require licensing diligence changelog
seonghobae Aug 9, 2026
236bf40
docs: record acquisition licensing diligence
seonghobae Aug 9, 2026
762d7a6
test(docs): require canonical data governance authority
seonghobae Aug 9, 2026
77c9e26
docs: establish data governance and privacy authority
seonghobae Aug 9, 2026
9e56ef4
docs: index data governance authority
seonghobae Aug 9, 2026
9afbf47
docs: classify data governance authority
seonghobae Aug 9, 2026
2bad839
docs: trace data governance authority
seonghobae Aug 9, 2026
231f749
docs: gate release on data governance
seonghobae Aug 9, 2026
fba2663
docs: record data governance authority
seonghobae Aug 9, 2026
485dbbb
test(docs): bind product requirements to data governance
seonghobae Aug 9, 2026
9799ff5
docs(prd): bind product data-governance authority
seonghobae Aug 9, 2026
be1f435
docs(trd): bind technical data-governance authority
seonghobae Aug 9, 2026
b2e951e
test(docs): require protected-main operational acceptance ADR
seonghobae Aug 9, 2026
6f93123
docs: define protected-main operational acceptance
seonghobae Aug 9, 2026
86fa40b
docs: index operational acceptance decision
seonghobae Aug 9, 2026
825f17d
docs: trace protected-main acceptance authority
seonghobae Aug 9, 2026
7c368f6
docs: bind release to post-merge operational proof
seonghobae Aug 9, 2026
e95aacb
docs: normalize operational ADR status label
seonghobae Aug 9, 2026
ddf871c
docs: record protected-main acceptance governance
seonghobae Aug 9, 2026
255e724
docs: include protected-main acceptance in fitness matrix
seonghobae Aug 9, 2026
66f0624
test(docs): bind operational proof after protected integration
seonghobae Aug 9, 2026
bb3e654
docs: order operational acceptance after protected integration
seonghobae Aug 9, 2026
ca52e88
docs: preserve protected-main post-check terminology
seonghobae Aug 9, 2026
c0b35fc
test(docs): keep provider-error redaction active-pr scoped
seonghobae Aug 9, 2026
dbb7b9a
docs(data): scope provider-error confidentiality to active PR
seonghobae Aug 9, 2026
0a6999c
docs(traceability): classify provider-error confidentiality overlay
seonghobae Aug 9, 2026
5e86635
docs(fitness): track provider-error confidentiality overlay
seonghobae Aug 9, 2026
cf23598
test(docs): reject universal provider compatibility claim
seonghobae Aug 10, 2026
329e279
docs: qualify provider compatibility claims
seonghobae Aug 10, 2026
dc6de5c
test(docs): define scheduler failure recovery contract
seonghobae Aug 10, 2026
6ac4f93
docs(adr): define scheduler failure recovery
seonghobae Aug 10, 2026
7f28460
docs(adr): index scheduler failure recovery
seonghobae Aug 10, 2026
bc8e778
docs(operability): add scheduler recovery runbook
seonghobae Aug 10, 2026
ad19f46
docs(traceability): bind scheduler failure recovery
seonghobae Aug 10, 2026
b4c6a47
docs(fitness): classify scheduler failure recovery
seonghobae Aug 10, 2026
26ed248
docs(changelog): record scheduler recovery governance
seonghobae Aug 10, 2026
1747209
fix(docs): preserve review-evidence ADR trace
seonghobae Aug 10, 2026
9ce0a98
test(docs): require scheduler recovery UML
seonghobae Aug 10, 2026
fc4d3ba
docs(uml): model scheduler failure recovery
seonghobae Aug 10, 2026
b57fd33
docs(architecture): index control-plane authority
seonghobae Aug 10, 2026
f5deae2
test(docs): capture current security overlay drift
seonghobae Aug 10, 2026
6f22328
docs(trd): capture current active security overlays
seonghobae Aug 10, 2026
bec7e0d
docs(security): bind active overlay trust boundaries
seonghobae Aug 10, 2026
b032800
docs(data): capture provider and secret overlay privacy
seonghobae Aug 10, 2026
84a3072
docs(ops): bind readiness and compose overlay controls
seonghobae Aug 10, 2026
935f6b5
test(docs): require review-governance hold alignment
seonghobae Aug 10, 2026
6331095
docs(governance): preserve solo-maintainer review hold
seonghobae Aug 10, 2026
6863cf4
docs(release): align review gates with live governance
seonghobae Aug 10, 2026
74223fc
docs(fitness): track code-owner review hold
seonghobae Aug 10, 2026
4a3e66a
docs(traceability): bind code-owner review hold
seonghobae Aug 10, 2026
25d1af9
test(docs): require no-shell health container authority
seonghobae Aug 10, 2026
adb242c
docs(trd): bind no-shell readiness container authority
seonghobae Aug 10, 2026
c6bf9fd
docs(ops): record exec-form readiness deployment boundary
seonghobae Aug 10, 2026
72bd6dd
docs(threat): capture no-shell readiness command boundary
seonghobae Aug 10, 2026
9f1e322
test(docs): require exact gateway authority overlay
seonghobae Aug 10, 2026
db8e46c
docs(security): distinguish gateway normalization authority
seonghobae Aug 10, 2026
5d596d5
docs(threat): bind exact gateway input target
seonghobae Aug 10, 2026
82c2dfa
test(docs): require current security overlay fitness
seonghobae Aug 10, 2026
c728b1f
docs: refresh active security overlay fitness
seonghobae Aug 10, 2026
91b9618
test(docs): bind bootstrap authority overlay
seonghobae Aug 10, 2026
42c440f
docs(bootstrap): capture exact authority inputs
seonghobae Aug 10, 2026
9d707cb
test(docs): require bootstrap threat authority
seonghobae Aug 10, 2026
8c74fdf
docs(bootstrap): capture threat authority boundary
seonghobae Aug 10, 2026
be6e02c
test(docs): require current product gaps in canonical graph
seonghobae Aug 10, 2026
c31021d
docs(product): track current commercial gap queue
seonghobae Aug 10, 2026
0fe4cb4
docs(technical): bind retired SQL and current gap boundaries
seonghobae Aug 10, 2026
c445f3c
docs(fitness): classify current security and operability gaps
seonghobae Aug 10, 2026
9e56a16
docs(traceability): bind current gap owners to evidence
seonghobae Aug 10, 2026
76c381e
docs(product): name component container reproducibility target
seonghobae Aug 10, 2026
5028bb8
test(docs): require operability and threat boundaries for SQL retirement
seonghobae Aug 10, 2026
9af8b6e
docs(architecture): bind provider retrieval transition
seonghobae Aug 10, 2026
c5763b5
docs(security): model retired SQL provider authority
seonghobae Aug 10, 2026
30be094
docs(ops): define provider retrieval transition
seonghobae Aug 10, 2026
aff92dc
test(docs): require legacy retrieval retirement overlay
seonghobae Aug 10, 2026
984b392
docs(readme): label legacy SQL retrieval as active retirement
seonghobae Aug 10, 2026
4c2dde2
docs(fitness): track staged SQL extension runtime retirement
seonghobae Aug 10, 2026
8ca5fc4
docs(adr): index SQL retrieval retirement and follow-ups
seonghobae Aug 10, 2026
8d7610f
test(docs): align fresh extension retirement wording
seonghobae Aug 10, 2026
77f27d5
docs(api): classify BatchRequest runtime boundary
seonghobae Aug 10, 2026
bc8fadf
test(docs): require legacy extension retirement target
seonghobae Aug 10, 2026
13a1f64
docs(adr): define legacy extension retirement boundary
seonghobae Aug 10, 2026
521ad13
docs(adr): index legacy extension retirement decision
seonghobae Aug 10, 2026
de8a84c
test(docs): bind legacy extension retirement ADR
seonghobae Aug 10, 2026
bea405f
test(docs): require extension retirement architecture overlay
seonghobae Aug 10, 2026
fe51e64
docs(architecture): model extension retirement migration
seonghobae Aug 10, 2026
37c3e54
test(docs): require extension retirement traceability
seonghobae Aug 10, 2026
de1684d
docs: trace legacy extension retirement
seonghobae Aug 10, 2026
a35cc67
test(docs): require BatchRequest fitness owner
seonghobae Aug 10, 2026
6c05936
docs: classify active BatchRequest hardening
seonghobae Aug 10, 2026
cd30f7e
test(docs): require non-silent scheduler recovery
seonghobae Aug 10, 2026
e24ea7b
docs: reject silent scheduler recovery
seonghobae Aug 10, 2026
9bdc1f7
docs: make scheduler recovery non-silent
seonghobae Aug 10, 2026
fa2f18c
docs: model non-silent scheduler recovery
seonghobae Aug 10, 2026
6c89a85
docs: trace non-silent scheduler recovery
seonghobae Aug 10, 2026
dd44f80
docs: classify silent completion as control drift
seonghobae Aug 10, 2026
fb2e1ca
docs: record non-silent scheduler recovery
seonghobae Aug 10, 2026
c19147b
test(docs): require structured error evidence authority
seonghobae Aug 10, 2026
6c68db0
docs: classify structured exception snapshots
seonghobae Aug 10, 2026
2dadfa0
docs: govern structured exception evidence
seonghobae Aug 10, 2026
9e145da
docs: trace active public error boundaries
seonghobae Aug 10, 2026
b4cb2eb
docs: classify structured error evidence overlay
seonghobae Aug 10, 2026
8b14223
test(docs): require technical error-evidence boundaries
seonghobae Aug 10, 2026
c108ca3
docs: define structured exception evidence boundary
seonghobae Aug 10, 2026
d3a5cc5
docs: model caller-owned error evidence drift
seonghobae Aug 10, 2026
fd4fe49
test(docs): require compact hourly writer prompt
seonghobae Aug 10, 2026
a4b6249
docs: add compact hourly writer prompt
seonghobae Aug 10, 2026
f415a2d
test(docs): require prompt source discoverability
seonghobae Aug 10, 2026
f99e770
docs: compact hourly writer prompt
seonghobae Aug 10, 2026
cef867a
docs: index compact hourly writer prompt
seonghobae Aug 10, 2026
dd73ced
docs: trace compact hourly writer prompt
seonghobae Aug 10, 2026
e8c1ce8
docs: assess compact hourly writer prompt
seonghobae Aug 10, 2026
20532c1
test(docs): require operation span status authority
seonghobae Aug 10, 2026
f21f47e
docs(observability): classify operation span error status
seonghobae Aug 10, 2026
93bd32d
docs(threat): classify operation span status boundary
seonghobae Aug 10, 2026
59ed8be
docs(traceability): link operation span error status
seonghobae Aug 10, 2026
59959e2
docs(fitness): classify operation span status overlay
seonghobae Aug 10, 2026
45056f8
test(docs): require OpenTelemetry packaging gap authority
seonghobae Aug 10, 2026
b7189fb
docs(prd): classify OpenTelemetry packaging gap
seonghobae Aug 10, 2026
abeb769
docs(adr): plan OpenTelemetry optional dependency contract
seonghobae Aug 10, 2026
4df6f69
docs(adr): index OpenTelemetry packaging plan
seonghobae Aug 10, 2026
157f64c
test(docs): bind OpenTelemetry packaging gap to PRD and ADR
seonghobae Aug 10, 2026
3aa6f15
test(docs): match ADR status formatting
seonghobae Aug 10, 2026
83a4e04
test(docs): require OpenTelemetry gap traceability
seonghobae Aug 10, 2026
3fcca80
docs(traceability): track OpenTelemetry packaging gap
seonghobae Aug 10, 2026
cc38344
docs(fitness): classify OpenTelemetry packaging gap
seonghobae Aug 10, 2026
cc7f895
test(docs): require tokenizer and version gap traceability
seonghobae Aug 10, 2026
1c51625
test(docs): require current buyer gap backlog in PRD
seonghobae Aug 10, 2026
9987407
docs(prd): classify current buyer-visible gaps
seonghobae Aug 10, 2026
c0bd134
docs(trd): classify tokenizer and version authority gaps
seonghobae Aug 10, 2026
85eb34c
docs(fitness): classify tokenizer and version gaps
seonghobae Aug 10, 2026
3978411
docs(traceability): bind tokenizer and version gap owners
seonghobae Aug 10, 2026
2745c77
test(docs): require current packaging gap owners
seonghobae Aug 10, 2026
9f59d98
docs(product): classify current packaging gaps
seonghobae Aug 10, 2026
d07c38e
docs(trd): own packaging toolchain gaps
seonghobae Aug 10, 2026
b38d71d
docs(fitness): classify packaging evidence gaps
seonghobae Aug 10, 2026
ee45e61
docs(traceability): link packaging gap owners
seonghobae Aug 10, 2026
20f0efc
test(docs): require CLI argv gap owners
seonghobae Aug 10, 2026
fd697fe
docs(product): own CLI argv privacy gaps
seonghobae Aug 10, 2026
6d98344
docs(trd): own CLI argv authority gaps
seonghobae Aug 10, 2026
865bb6b
test(docs): require PostgreSQL logging privacy ownership
seonghobae Aug 10, 2026
f65ad75
docs(prd): own PostgreSQL logging privacy hardening
seonghobae Aug 10, 2026
20d0665
docs(trd): classify PostgreSQL query-text privacy boundary
seonghobae Aug 10, 2026
0411bd1
docs(threat): classify PostgreSQL query-text disclosure
seonghobae Aug 10, 2026
8196060
docs(fitness): reconcile privacy and argv gap maturity
seonghobae Aug 10, 2026
1b6e36a
docs(traceability): map argv and PostgreSQL privacy gaps
seonghobae Aug 10, 2026
55ccb57
test(docs): require PostgreSQL image supply-chain owner
seonghobae Aug 10, 2026
efe3236
docs(prd): own PostgreSQL image supply-chain gap
seonghobae Aug 10, 2026
1c7f8d0
test(docs): require bounded logging operability follow-up
seonghobae Aug 10, 2026
8aa47a5
docs(prd): classify container logging operability gap
seonghobae Aug 10, 2026
83bde08
docs(trd): own PostgreSQL image and logging gaps
seonghobae Aug 10, 2026
247a3aa
docs(fitness): classify PostgreSQL supply-chain and logging gaps
seonghobae Aug 10, 2026
e1dcdaa
docs(traceability): link PostgreSQL image and logging follow-ups
seonghobae Aug 10, 2026
45a784f
fix(test): bound issue entries by headings
seonghobae Aug 10, 2026
7ea4cc0
test(docs): require explicit secret encryption policy gap
seonghobae Aug 10, 2026
e1657eb
docs(security): define planned provider-secret encryption policy
seonghobae Aug 10, 2026
c87e602
docs(adr): index planned provider-secret encryption policy
seonghobae Aug 10, 2026
ef0b36c
test(docs): bind secret policy gap to indexed ADR
seonghobae Aug 10, 2026
059dd36
docs(prd): track explicit provider-secret encryption policy
seonghobae Aug 10, 2026
c880461
docs(trd): define provider-secret encryption policy target
seonghobae Aug 10, 2026
cad74b8
test(docs): bind secret policy to PRD and TRD targets
seonghobae Aug 10, 2026
0d952ad
docs(fitness): classify provider-secret encryption policy gap
seonghobae Aug 10, 2026
32fa95d
docs(traceability): link provider-secret encryption policy gap
seonghobae Aug 10, 2026
a31c71b
test(docs): align secret-policy status assertion with Markdown
seonghobae Aug 10, 2026
e08a167
test(docs): bind secret baseline assertion to Markdown authority
seonghobae Aug 11, 2026
2a7b58b
test(docs): require database timeout gap ownership
seonghobae Aug 11, 2026
564c320
docs(prd): track bounded PostgreSQL wait policy
seonghobae Aug 11, 2026
1ef3f7b
docs(trd): bound planned PostgreSQL wait authority
seonghobae Aug 11, 2026
791ed7b
docs(operability): track database wait budgets
seonghobae Aug 11, 2026
82b229d
docs(fitness): classify database wait-budget gap
seonghobae Aug 11, 2026
cb6b113
docs(traceability): map database wait-budget gap
seonghobae Aug 11, 2026
69f9363
test(docs): align wait-budget authority assertion
seonghobae Aug 11, 2026
d77ae46
test(docs): require PostgreSQL transport security owner
seonghobae Aug 11, 2026
17350d8
docs(security): define PostgreSQL transport policy
seonghobae Aug 11, 2026
6820edc
docs(product): track PostgreSQL transport security gap
seonghobae Aug 11, 2026
b56bce6
docs(adr): index PostgreSQL transport security decision
seonghobae Aug 11, 2026
c345c7d
test(docs): bind transport gap to canonical ADR
seonghobae Aug 11, 2026
f926b06
test(docs): require transport policy traceability
seonghobae Aug 11, 2026
e2d0375
docs(traceability): link PostgreSQL transport policy
seonghobae Aug 11, 2026
e410666
test(docs): require virtual payload integrity authority
seonghobae Aug 11, 2026
16ed2c5
docs(adr): define virtual JSONL payload integrity
seonghobae Aug 11, 2026
7eab797
docs(adr): index virtual payload integrity
seonghobae Aug 11, 2026
fe4a2c8
test(docs): bind payload integrity to canonical ADR
seonghobae Aug 11, 2026
390102c
docs(adr): bind payload text to line count
seonghobae Aug 11, 2026
c1317b0
test(docs): require payload count consistency
seonghobae Aug 11, 2026
be71651
test(docs): match normalized ADR labels
seonghobae Aug 11, 2026
b0e1b81
docs(payload): make pre-provider validation contract explicit
seonghobae Aug 11, 2026
885f2c4
test(docs): require lifecycle diagnostic and metadata failure boundaries
seonghobae Aug 11, 2026
f6224bc
docs(adr): define bounded lifecycle failure diagnostics
seonghobae Aug 11, 2026
2d0ae12
docs(adr): define endpoint-qualified tokenizer authority
seonghobae Aug 11, 2026
b596a33
docs(trd): bound lifecycle and tokenizer failure authority
seonghobae Aug 11, 2026
35e3cf1
docs(threat): classify tokenizer and lifecycle diagnostic failures
seonghobae Aug 11, 2026
abbf696
docs(traceability): own lifecycle diagnostic confidentiality
seonghobae Aug 11, 2026
c5e11bb
docs: close lifecycle diagnostics fitness gap
seonghobae Aug 11, 2026
4f5a775
test(docs): require tokenizer and lifecycle field owners
seonghobae Aug 11, 2026
009716f
docs: classify tokenizer and lifecycle field gaps
seonghobae Aug 11, 2026
d493204
docs: classify tokenizer and lifecycle field threats
seonghobae Aug 11, 2026
2a922ab
docs: trace tokenizer and lifecycle field gaps
seonghobae Aug 11, 2026
e849091
docs: classify tokenizer and lifecycle field fitness
seonghobae Aug 11, 2026
19905c1
test(docs): require credential representation confidentiality gap
seonghobae Aug 11, 2026
47794d2
docs(api): classify credential representation privacy gap
seonghobae Aug 11, 2026
aeb0deb
docs(threat): classify credential representation disclosure
seonghobae Aug 11, 2026
e01ce46
docs(trace): classify credential representation privacy gap
seonghobae Aug 11, 2026
1edd1b9
docs(fitness): classify credential representation privacy gap
seonghobae Aug 11, 2026
8bc9ce5
docs(prd): classify provider progress validation as active
seonghobae Aug 11, 2026
0d25c0a
docs(trd): bind provider progress validation to active owner
seonghobae Aug 11, 2026
b00f086
docs(traceability): promote provider progress owner to active
seonghobae Aug 11, 2026
6cb02ba
test(docs): require recent buyer gaps in PRD
seonghobae Aug 11, 2026
dff2f1d
docs(prd): track recent buyer-visible gaps
seonghobae Aug 11, 2026
9a60634
test(docs): require tenant content isolation target
seonghobae Aug 11, 2026
fccd5b1
docs(prd): capture tenant content isolation gap
seonghobae Aug 11, 2026
a6abf93
test(docs): bind tenant content isolation authorities
seonghobae Aug 11, 2026
a104636
docs(erd): expose tenant content isolation gap
seonghobae Aug 11, 2026
d590f00
docs(threat): distinguish lifecycle and content tenant isolation
seonghobae Aug 11, 2026
9689291
docs(trace): link tenant content isolation gap
seonghobae Aug 11, 2026
1eb6b9f
test(docs): require token diagnostic privacy target
seonghobae Aug 11, 2026
092bd41
docs(prd): capture token diagnostic privacy gap
seonghobae Aug 11, 2026
d6bf12c
test(docs): require latest buyer gaps in PRD
seonghobae Aug 11, 2026
6839e90
docs(product): track latest security gaps
seonghobae Aug 11, 2026
263a22b
test(docs): bind provisioning dependencies structurally
seonghobae Aug 11, 2026
7b4818e
test(docs): require traceability for latest buyer gaps
seonghobae Aug 11, 2026
94615f1
docs(traceability): classify latest security gaps
seonghobae Aug 11, 2026
acc6d47
docs(fitness): classify latest buyer gaps
seonghobae Aug 11, 2026
04be894
test(docs): require provider file lifecycle gap
seonghobae Aug 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 230 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# pg-llm-batch Architecture

## Document authority

This document is the root architectural map for `pg-llm-batch`. It deliberately separates **protected-main as-built** behavior from the **active-PR overlay**. The as-built section is grounded in protected `main` at `bf2cc2e140dc3ff4a56c3203f80f41bb9fed5d10`; active PRs are directional integration work and are not shipped merely because they appear below.

Detailed requirements live in `docs/product/PRD.md` and `docs/product/TRD.md`. Behavior/deployment diagrams live in `docs/architecture/UML.md`; persistence cardinality lives in `docs/architecture/ERD.md`; security ownership lives in `docs/THREAT_MODEL.md`.

## 1. Protected-main as-built

### 1.1 System purpose

`pg-llm-batch` is a PostgreSQL-centered batch engine. It accepts database-backed LLM request state, counts tokens through `pg_tiktoken`, prepares bounded JSONL payloads in PostgreSQL, submits/polls/waits/cancels/retrieves through an OpenAI-compatible Batch API, and optionally persists validated remote lifecycle observations and emits host-owned OpenTelemetry operation signals.

### 1.2 Logical component topology

```mermaid
flowchart LR
Host[Host application / operator]
CLI[pg_llm_batch.cli]
Orch[PostgresBatchOrchestrator]
Token[TokenCounter / BatchAccumulator]
Client[BatchAPIClient]
Durable[DurableBatchAPIClient]
OTel[OpenTelemetryBatchAPIClient]
Config[PostgresConfigStore / SecretStore]
Health[health.py]
DB[(PostgreSQL)]
Tiktoken[pg_tiktoken]
Provider[OpenAI-compatible Files / Batches API]
Telemetry[Host OpenTelemetry SDK / exporter]

Host --> CLI
Host --> Orch
Host --> Client
Host --> Durable
Host --> OTel
CLI --> Orch
CLI --> Client
Orch --> Token
Token --> DB
DB --> Tiktoken
Orch --> DB
Config --> DB
Client --> Config
Client --> DB
Client --> Provider
Durable --> Client
Durable --> DB
OTel --> Client
OTel --> Telemetry
Health --> DB
```

### 1.3 Module responsibilities

| Module | Responsibility | Must not own |
| --- | --- | --- |
| `token_counter.py` | model/tokenizer lookup, token counting, batch resource accounting | provider credentials, remote lifecycle |
| `orchestrator.py` | resolve batch identity, select queued requests, bounded payload assembly, transactional persistence | provider HTTP policy |
| `batch_api_client.py` | provider destination/resource/path validation, upload/create/poll/wait/cancel/retrieve, bounded HTTP/JSON/download/retry behavior | tenant authorization, global telemetry configuration |
| `durable_client.py` | reserve observation order before provider call; persist validated lifecycle snapshots | authentication of host tenant/user |
| `config.py` | database-backed config and secrets | external secret-management policy for embedding hosts |
| `db.py` | schema application and database helpers, virtual payload loading, lifecycle persistence | provider networking |
| `observability.py` | opt-in operation telemetry with bounded attributes | global SDK/exporter/resource configuration |
| `health.py` | readiness aggregation and minimal HTTP health serving | general web application serving |
| `cli.py` | standalone operator composition | higher-level workflow orchestration |

## 2. Data flow

### 2.1 Preparation path

1. A host/operator identifies an existing batch by UUID or supported lookup key.
2. `PostgresBatchOrchestrator` reads queued, unassigned `llm_requests` for that batch.
3. `TokenCounter` consults configuration/model-tokenizer mapping and `pg_tiktoken`; `BatchAccumulator` counts and partitions the in-memory request rows under token/byte/record limits before preparation persistence begins.
4. Under one advisory-locked PostgreSQL preparation transaction, `_persist_payloads()` first persists each payload document in `llm_batch_file_payloads`, then its `llm_batch_files` row, then JSONL line rows and queued-request assignments, and finally batch totals before commit.
5. Any exception before commit rolls back that preparation transaction rather than leaving a partially committed file/request/line assignment from that invocation.
6. A virtual `memory://<file_id>` path refers back to PostgreSQL; package-owned payload files are not written to disk.

### 2.2 Provider path

1. `BatchAPIClient` resolves a credential set for a validated endpoint alias.
2. It validates the credential-bearing gateway destination before making the authenticated request.
3. It streams the selected PostgreSQL payload to the provider Files API.
4. It creates a remote batch job, polls/waits for terminal state, and retrieves output/error files under finite request and decoded-byte bounds.
5. GET retries are bounded and limited to the protected-main reviewed set. Side-effecting POST operations are not automatically replayed.

### 2.3 Durable lifecycle path

`DurableBatchAPIClient` composes the base provider client rather than replacing it. Before each lifecycle operation it persists a database-owned observation ordering reservation. After a provider response succeeds, it revalidates remote identity/optional file identifiers/status/metadata and writes a projection into `llm_remote_batch_jobs`. Reservation failure prevents provider I/O; persistence failure after provider success produces explicit reconciliation evidence rather than pretending the provider operation did not happen.

## 3. Trust and authority boundaries

### 3.1 PostgreSQL

PostgreSQL is trusted as the package-owned durable state boundary for current-main configuration, secrets, preparation state, endpoint/model mapping, and remote lifecycle projection. Database administrator/superuser power remains outside package-enforced guarantees.

### 3.2 Provider

The provider is an external system. URLs, resource IDs, endpoint paths, response statuses, metadata, JSON bodies, JSONL content, timing guidance, and errors are untrusted until validated by the relevant bounded contract.

### 3.3 Credentials

The built-in path stores provider URL configuration in `com_config` and provider API keys in `com_secrets`; a host can inject another credential provider. Environment variables are bootstrap transport only where explicitly documented. The package must not infer user/tenant authorization from provider data.

### 3.4 Host application

The host owns user/workload authentication, mapping to trusted tenant scope where tenancy is used, external business transactions, global OpenTelemetry policy, ingress/WAF/service-mesh policy, infrastructure TLS/trust stores, backup/restore, retention, and any cross-system exactly-once strategy.

### 3.5 GitHub / release evidence

Source code, PR base, live base tip, GitHub synthetic merge commit, workflow checkout commit, check result, formal review, branch/ruleset policy, and release artifact evidence are separate authority classes. The repository may require all of them, but none silently substitutes for another.

## 4. Resource-bound architecture

Protected main establishes finite bounds for:

- request timeout (`DEFAULT_REQUEST_TIMEOUT_SECONDS`);
- provider control JSON (`DEFAULT_MAX_CONTROL_RESPONSE_BYTES`);
- provider-file decoded bytes (`DEFAULT_MAX_DOWNLOAD_BYTES`);
- download chunk size;
- retry attempt count and delay ceiling;
- remote resource identifier/path syntax;
- batch token, record, and provider file constraints; and
- wait timeout/poll interval supplied by the caller.

The architectural rule is **bound before materialization or repeat**. If an adapter cannot expose the required bounded stream, the package fails closed rather than falling back to an unbounded body read.

## 5. Deployment architecture

### 5.1 Standalone

The bundled Compose profile builds a PostgreSQL image with required extensions and a Python component image. The component receives the DSN as bootstrap transport and serves the current health endpoint. The host/operator owns network publishing, firewalling, persisted Docker volume lifecycle, and production-grade ingress. The current protected-main Compose file publishes 5432 and 8080 without a host IP; #91 is the ACTIVE-PR hardening target for loopback publishing.

### 5.2 Embedded library / submodule

An embedding application imports `TokenCounter`, `PostgresBatchOrchestrator`, `BatchAPIClient`/`DurableBatchAPIClient`, and configuration seams directly. It may apply the package schema to an existing database and supply its own credential resolver. The package does not require a separate network hop between the host and these Python APIs.

### 5.3 CWL MSA interoperability

In a ContextualWisdomLab deployment, another service can own authentication, tenant routing, secret resolution, model/gateway selection, and OpenTelemetry export while `pg-llm-batch` remains a bounded batch/persistence module. This is an integration topology, not a dependency on a particular CWL service.

## 6. Failure architecture

### 6.1 Local validation failure

Invalid config, runtime limits, IDs, endpoint paths, or gateway destinations fail before the external/database effect that relies on them wherever the implementation contract permits.

### 6.2 Provider transport/status failure

The base client converts reviewed failures into structured package exceptions. Bounded idempotent GET failures may retry; non-idempotent operations do not gain retry simply because a network error occurred.

### 6.3 Provider-success / persistence-failure split

Durable lifecycle persistence occurs after provider success for the corresponding observation. A database failure at that point is explicitly a reconciliation case; the package must not hide the remote effect by rewriting it as a pre-request failure.

### 6.4 Telemetry failure

Optional observer failure is best effort and cannot replace the application result/error. The host still owns telemetry backend availability and retention.

### 6.5 Readiness failure

Readiness fails when required DB/tokenizer/config components are not available. Current protected main exposes local diagnostic detail in the health response; #70 is the ACTIVE-PR hardening target for public redaction and bounded concurrent/read work.

## 7. Active-PR overlay

The following overlay is intentionally **not** part of the protected-main as-built architecture until integrated:

```mermaid
flowchart LR
Protected[Protected-main batch + lifecycle architecture]
Tenant[Tenant scope + lifecycle RLS #53]
Stream[Incremental result streaming #58]
Checkpoint[Prefix checkpoints #59]
DurableCP[Durable checkpoint store #60]
CPTelemetry[Checkpoint telemetry #92]
Audit[Acceptance audit #94]
Migrations[Atomic checkpoint migrations #95]
Pages[Stable audit pages #96]
Manifest[Audit snapshot manifests #97]
ExactCI[Exact source-head CI #88]
Release[Reproducible release evidence #57]
Ops[Health / CLI / config / connection / compose hardening #70 #85 #86 #87 #89 #91]

Protected --> Tenant
Protected --> Stream
Stream --> Checkpoint
Checkpoint --> DurableCP
DurableCP --> CPTelemetry
CPTelemetry --> Audit
Audit --> Migrations
Migrations --> Pages
Pages --> Manifest
Protected --> ExactCI
ExactCI --> Release
Protected --> Ops
```

The checkpoint nodes above are the current active implementation chain. Superseded predecessor lineages are indexed in `docs/adr/README.md` and are deliberately excluded from this ACTIVE-PR overlay; their old evidence does not transfer to replacements.

The overlay is dependency-aware, not a claim that every PR must merge in the diagram's visual order; the live PR stack/base relations remain authoritative.

## 8. Architecture invariants

1. **Standalone operation is first-class.** A host integration may add services, but core package behavior must not require them.
2. **PostgreSQL and provider authority stay explicit.** Local durable state does not magically authenticate external provider truth.
3. **Side effects are not casually replayed.** Automatic retry is a reviewed method/status/transport contract.
4. **Large data is bounded before full materialization.** Streaming exists to enforce memory bounds, not merely as an implementation detail.
5. **Host authority remains host-owned.** Authentication, tenant mapping, external business effects, global telemetry and ingress do not silently move into this library.
6. **Active PR is not shipped architecture.** Every overlay item must be relabeled after merge/closure/supersession.
7. **Evidence identity is architectural.** Commercial/release decisions must know which source/base/merge/check/review/artifact they are proving.
8. **Database names are descriptive.** New package-owned objects use descriptive two-or-more-word snake_case by default.

## 9. Architecture decision and detail map

- Product outcomes: `docs/product/PRD.md`
- Technical requirements: `docs/product/TRD.md`
- UML: `docs/architecture/UML.md`
- ERD/data model: `docs/architecture/ERD.md`
- Security/threats: `docs/THREAT_MODEL.md`
- Tests/evidence: `docs/TEST_STRATEGY.md`
- Operations/recovery: `docs/OPERABILITY.md`
- Traceability: `docs/TRACEABILITY.md`
- ADR index: `docs/adr/README.md`
- Maintenance governance: `docs/automation/ADR-0001-work-conserving-maintenance.md`
- Evidence identity/writer lease: `docs/automation/ADR-0002-evidence-identity-and-writer-lease.md`

## 10. Change discipline

A runtime, schema, API, security, deployment, CI, evidence, or release change that contradicts an invariant above requires either an ADR update/new ADR or an explicit correction to this architecture in the same change set. PR-body prose alone is not a durable architecture decision.
80 changes: 72 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ relicensed to **Apache-2.0** (see [`NOTICE`](NOTICE) for provenance).
- **Token counting is authoritative.** Counts come from `pg_tiktoken` in the
database, so the numbers used to pack a batch are exactly what the DB sees —
there is no drifting Python-side tokenizer.
- **No secrets in the environment.** All configuration and credentials live in
Postgres KV tables (`com_config`, `com_secrets`). The environment is only a
*bootstrap transport* for the DSN and an optional Fernet key. This replaces
the ~75 `os.getenv` reads in the upstream app.
- **By default, provider credentials stay out of the environment in standalone mode.**
Operational configuration and provider credentials live in Postgres KV tables
(`com_config`, `com_secrets`). In standalone mode, the environment is only a
*bootstrap transport* for the DSN and an optional Fernet key. The Fernet key is sensitive bootstrap secret material,
not a provider credential, and must be protected accordingly. Embedded hosts
may instead supply credentials through the documented
`Callable[[str], GatewayCredentials]` integration boundary. This replaces the
~75 `os.getenv` reads in the upstream app.
- **Disk-free assembly.** JSONL payloads are stored as `JSONB` and reconstructed
by JOIN, never written to disk.

Expand Down Expand Up @@ -65,27 +69,72 @@ docker compose up -d --build
curl -fsS localhost:8080/healthz
```

### 2. Point it at your gateway (config + secret in the DB, not env)
### 2. Point it at your gateway (provider config + credential in the DB)

```bash
export PG_LLM_BATCH_DSN=postgresql://pgllm:pgllm@localhost:5432/pgllm
python -m pg_llm_batch init-db # idempotent
python -m pg_llm_batch config set gateway base_url https://your-gateway/v1
python -m pg_llm_batch config set-secret gateway_api_key.default sk-your-key
```

Production gateway destinations must use HTTPS. Plain HTTP is accepted only for
explicit loopback development endpoints (`localhost`, `127.0.0.0/8`, or `::1`).
URLs containing user information, query parameters, fragments, whitespace, or
invalid ports are rejected before the API key is read from `com_secrets`.

Encrypt secrets at rest by exporting a Fernet key as bootstrap transport:
For the protected-main-compatible credential path, install the optional Fernet
dependency, inject the Fernet key **before** constructing `SecretStore`, and use
a terminal prompt that fails closed if Python cannot disable echo. Do not place
the provider key in process argv, shell history, or command diagnostics:

```bash
pip install '.[secrets]'
export PG_LLM_BATCH_SECRET_KEY=$(python -c "from cryptography.fernet import Fernet;print(Fernet.generate_key().decode())")
python -m pg_llm_batch config set-secret gateway_api_key.default sk-your-key
python - <<'PY'
import getpass
import os
import warnings

from pg_llm_batch.bootstrap import resolve_secret_key
from pg_llm_batch.config import SecretStore

warnings.simplefilter("error", getpass.GetPassWarning)

store = SecretStore(
os.environ["PG_LLM_BATCH_DSN"],
fernet_key=resolve_secret_key(),
)
try:
try:
api_key = getpass.getpass("Gateway API key: ")
except getpass.GetPassWarning as exc:
raise SystemExit("Cannot disable terminal echo; refusing secret input") from exc
store.set_secret("gateway_api_key.default", api_key)
finally:
store.close()
PY
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
unset PG_LLM_BATCH_SECRET_KEY
```

This uses the existing database-backed `SecretStore.set_secret()` API and keeps
provider credential plaintext out of argv. Setting `PG_LLM_BATCH_SECRET_KEY`
before `SecretStore` construction ensures the example uses Fernet encryption
instead of the local/dev-only base64-obfuscation fallback; unsetting it after the
write shortens ambient key lifetime. The warning-to-error policy prevents
`getpass` from falling back to visibly echoed input when terminal echo control is
unavailable. ACTIVE-PR #85 adds an equivalent argv-safe `config set-secret` CLI
input path; until that PR is integrated, do not treat a plaintext positional CLI
secret example as a production procedure. Non-interactive host applications
should use their own secret-manager integration and the documented
`Callable[[str], GatewayCredentials]` boundary instead of weakening this prompt.

`PG_LLM_BATCH_SECRET_KEY` is sensitive bootstrap secret material. Keep it out of
shell history, logs, source control, images, and other ambient diagnostics; use a
secret-injection mechanism appropriate to the deployment. The generated-key
`export` above is a local bootstrap example, not a production secret-distribution
mechanism. Provider API credentials remain in `com_secrets` rather than
environment variables by default in standalone mode.

Comment thread
seonghobae marked this conversation as resolved.
Resolved
### 3. Count, submit, wait, retrieve

```bash
Expand Down Expand Up @@ -223,6 +272,21 @@ PG_LLM_BATCH_TEST_DSN=postgresql://pgllm:pgllm@localhost:5432/pgllm \

## Docs

Canonical product and acquisition-readiness documentation is indexed here so
buyers, contributors, and operators do not need chat history or PR-body
archaeology. The newly introduced canonical graph is **ACTIVE-PR #93** until it
reaches protected `main`; ACTIVE-PR or PARTIAL material is not shipped behavior.
Use [Documentation fitness and maturity](docs/DOCUMENTATION_FITNESS.md) as the
status authority for each documentation family and capability.

- [Architecture](ARCHITECTURE.md), [PRD](docs/product/PRD.md), [TRD](docs/product/TRD.md), and [public API/compatibility contract](docs/product/API_CONTRACT.md)
- [UML behavior views](docs/architecture/UML.md) and [ERD/data model](docs/architecture/ERD.md)
- [Security policy](SECURITY.md), [threat model](docs/THREAT_MODEL.md), [test strategy](docs/TEST_STRATEGY.md), and [operability/recovery](docs/OPERABILITY.md)
- [Release acceptance](docs/RELEASE_ACCEPTANCE.md), [traceability](docs/TRACEABILITY.md), and [ADR index](docs/adr/README.md)
- [Documentation fitness and maturity matrix](docs/DOCUMENTATION_FITNESS.md)

Additional method and research documentation:

- [`docs/doctoring/opentelemetry-operations.md`](docs/doctoring/opentelemetry-operations.md)
— opt-in operation traces/metrics, host ownership, privacy and cardinality
boundaries, verification, and APA 7 references.
Expand Down
Loading
Loading