Repository navigation
docs: establish canonical product documentation authority #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
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 7d66406
test(docs): require foundational product ADRs
seonghobae 53f32be
docs(adr): record PostgreSQL durable authority
seonghobae 87df20b
docs(adr): record provider HTTP trust boundary
seonghobae 9cdf269
docs(adr): record standalone composition boundary
seonghobae d16020a
docs(adr): record lifecycle observation authority
seonghobae e502665
docs(adr): index foundational product decisions
seonghobae cfcb149
docs(fitness): record foundational ADR coverage
seonghobae 0a0ebc0
test(docs): require review evidence separation ADR
seonghobae bff15e3
docs(adr): separate review and infrastructure evidence
seonghobae ba5e697
docs(adr): index review evidence separation
seonghobae d316b0f
docs(traceability): map review evidence separation
seonghobae cc52d8e
fix(docs): align ADR status contract
seonghobae 6eda0a4
test(docs): bind evidence separation to fitness matrix
seonghobae 6e845ce
docs(fitness): track review evidence separation
seonghobae 86291e7
test(docs): require acquisition licensing authority
seonghobae 69f9b2a
docs: add acquisition licensing and IP authority
seonghobae 973d99f
test(docs): bind licensing authority to existing release evidence
seonghobae 8383a66
docs: classify licensing and IP acquisition authority
seonghobae 6386dd5
docs: trace licensing and IP acquisition evidence
seonghobae d6a67b5
docs: make legal-review boundary machine-checkable
seonghobae e09668d
test(docs): reject permissive-only notice overclaim
seonghobae f68003a
docs: remove permissive-only dependency overclaim
seonghobae 1fb05be
test(docs): require psycopg binary license boundary
seonghobae 815bca8
docs: expose psycopg binary dependency boundary
seonghobae 0672191
test(docs): require licensing release rejection gate
seonghobae a792549
docs: make licensing a release rejection gate
seonghobae fd0e93c
test(docs): require licensing diligence changelog
seonghobae 236bf40
docs: record acquisition licensing diligence
seonghobae 762d7a6
test(docs): require canonical data governance authority
seonghobae 77c9e26
docs: establish data governance and privacy authority
seonghobae 9e56ef4
docs: index data governance authority
seonghobae 9afbf47
docs: classify data governance authority
seonghobae 2bad839
docs: trace data governance authority
seonghobae 231f749
docs: gate release on data governance
seonghobae fba2663
docs: record data governance authority
seonghobae 485dbbb
test(docs): bind product requirements to data governance
seonghobae 9799ff5
docs(prd): bind product data-governance authority
seonghobae be1f435
docs(trd): bind technical data-governance authority
seonghobae b2e951e
test(docs): require protected-main operational acceptance ADR
seonghobae 6f93123
docs: define protected-main operational acceptance
seonghobae 86fa40b
docs: index operational acceptance decision
seonghobae 825f17d
docs: trace protected-main acceptance authority
seonghobae 7c368f6
docs: bind release to post-merge operational proof
seonghobae e95aacb
docs: normalize operational ADR status label
seonghobae ddf871c
docs: record protected-main acceptance governance
seonghobae 255e724
docs: include protected-main acceptance in fitness matrix
seonghobae 66f0624
test(docs): bind operational proof after protected integration
seonghobae bb3e654
docs: order operational acceptance after protected integration
seonghobae ca52e88
docs: preserve protected-main post-check terminology
seonghobae c0b35fc
test(docs): keep provider-error redaction active-pr scoped
seonghobae dbb7b9a
docs(data): scope provider-error confidentiality to active PR
seonghobae 0a6999c
docs(traceability): classify provider-error confidentiality overlay
seonghobae 5e86635
docs(fitness): track provider-error confidentiality overlay
seonghobae cf23598
test(docs): reject universal provider compatibility claim
seonghobae 329e279
docs: qualify provider compatibility claims
seonghobae dc6de5c
test(docs): define scheduler failure recovery contract
seonghobae 6ac4f93
docs(adr): define scheduler failure recovery
seonghobae 7f28460
docs(adr): index scheduler failure recovery
seonghobae bc8e778
docs(operability): add scheduler recovery runbook
seonghobae ad19f46
docs(traceability): bind scheduler failure recovery
seonghobae b4c6a47
docs(fitness): classify scheduler failure recovery
seonghobae 26ed248
docs(changelog): record scheduler recovery governance
seonghobae 1747209
fix(docs): preserve review-evidence ADR trace
seonghobae 9ce0a98
test(docs): require scheduler recovery UML
seonghobae fc4d3ba
docs(uml): model scheduler failure recovery
seonghobae b57fd33
docs(architecture): index control-plane authority
seonghobae f5deae2
test(docs): capture current security overlay drift
seonghobae 6f22328
docs(trd): capture current active security overlays
seonghobae bec7e0d
docs(security): bind active overlay trust boundaries
seonghobae b032800
docs(data): capture provider and secret overlay privacy
seonghobae 84a3072
docs(ops): bind readiness and compose overlay controls
seonghobae 935f6b5
test(docs): require review-governance hold alignment
seonghobae 6331095
docs(governance): preserve solo-maintainer review hold
seonghobae 6863cf4
docs(release): align review gates with live governance
seonghobae 74223fc
docs(fitness): track code-owner review hold
seonghobae 4a3e66a
docs(traceability): bind code-owner review hold
seonghobae 25d1af9
test(docs): require no-shell health container authority
seonghobae adb242c
docs(trd): bind no-shell readiness container authority
seonghobae c6bf9fd
docs(ops): record exec-form readiness deployment boundary
seonghobae 72bd6dd
docs(threat): capture no-shell readiness command boundary
seonghobae 9f1e322
test(docs): require exact gateway authority overlay
seonghobae db8e46c
docs(security): distinguish gateway normalization authority
seonghobae 5d596d5
docs(threat): bind exact gateway input target
seonghobae 82c2dfa
test(docs): require current security overlay fitness
seonghobae c728b1f
docs: refresh active security overlay fitness
seonghobae 91b9618
test(docs): bind bootstrap authority overlay
seonghobae 42c440f
docs(bootstrap): capture exact authority inputs
seonghobae 9d707cb
test(docs): require bootstrap threat authority
seonghobae 8c74fdf
docs(bootstrap): capture threat authority boundary
seonghobae be6e02c
test(docs): require current product gaps in canonical graph
seonghobae c31021d
docs(product): track current commercial gap queue
seonghobae 0fe4cb4
docs(technical): bind retired SQL and current gap boundaries
seonghobae c445f3c
docs(fitness): classify current security and operability gaps
seonghobae 9e56a16
docs(traceability): bind current gap owners to evidence
seonghobae 76c381e
docs(product): name component container reproducibility target
seonghobae 5028bb8
test(docs): require operability and threat boundaries for SQL retirement
seonghobae 9af8b6e
docs(architecture): bind provider retrieval transition
seonghobae c5763b5
docs(security): model retired SQL provider authority
seonghobae 30be094
docs(ops): define provider retrieval transition
seonghobae aff92dc
test(docs): require legacy retrieval retirement overlay
seonghobae 984b392
docs(readme): label legacy SQL retrieval as active retirement
seonghobae 4c2dde2
docs(fitness): track staged SQL extension runtime retirement
seonghobae 8ca5fc4
docs(adr): index SQL retrieval retirement and follow-ups
seonghobae 8d7610f
test(docs): align fresh extension retirement wording
seonghobae 77f27d5
docs(api): classify BatchRequest runtime boundary
seonghobae bc8fadf
test(docs): require legacy extension retirement target
seonghobae 13a1f64
docs(adr): define legacy extension retirement boundary
seonghobae 521ad13
docs(adr): index legacy extension retirement decision
seonghobae de8a84c
test(docs): bind legacy extension retirement ADR
seonghobae bea405f
test(docs): require extension retirement architecture overlay
seonghobae fe51e64
docs(architecture): model extension retirement migration
seonghobae 37c3e54
test(docs): require extension retirement traceability
seonghobae de1684d
docs: trace legacy extension retirement
seonghobae a35cc67
test(docs): require BatchRequest fitness owner
seonghobae 6c05936
docs: classify active BatchRequest hardening
seonghobae cd30f7e
test(docs): require non-silent scheduler recovery
seonghobae e24ea7b
docs: reject silent scheduler recovery
seonghobae 9bdc1f7
docs: make scheduler recovery non-silent
seonghobae fa2f18c
docs: model non-silent scheduler recovery
seonghobae 6c89a85
docs: trace non-silent scheduler recovery
seonghobae dd44f80
docs: classify silent completion as control drift
seonghobae fb2e1ca
docs: record non-silent scheduler recovery
seonghobae c19147b
test(docs): require structured error evidence authority
seonghobae 6c68db0
docs: classify structured exception snapshots
seonghobae 2dadfa0
docs: govern structured exception evidence
seonghobae 9e145da
docs: trace active public error boundaries
seonghobae b4cb2eb
docs: classify structured error evidence overlay
seonghobae 8b14223
test(docs): require technical error-evidence boundaries
seonghobae c108ca3
docs: define structured exception evidence boundary
seonghobae d3a5cc5
docs: model caller-owned error evidence drift
seonghobae fd4fe49
test(docs): require compact hourly writer prompt
seonghobae a4b6249
docs: add compact hourly writer prompt
seonghobae f415a2d
test(docs): require prompt source discoverability
seonghobae f99e770
docs: compact hourly writer prompt
seonghobae cef867a
docs: index compact hourly writer prompt
seonghobae dd73ced
docs: trace compact hourly writer prompt
seonghobae e8c1ce8
docs: assess compact hourly writer prompt
seonghobae 20532c1
test(docs): require operation span status authority
seonghobae f21f47e
docs(observability): classify operation span error status
seonghobae 93bd32d
docs(threat): classify operation span status boundary
seonghobae 59ed8be
docs(traceability): link operation span error status
seonghobae 59959e2
docs(fitness): classify operation span status overlay
seonghobae 45056f8
test(docs): require OpenTelemetry packaging gap authority
seonghobae b7189fb
docs(prd): classify OpenTelemetry packaging gap
seonghobae abeb769
docs(adr): plan OpenTelemetry optional dependency contract
seonghobae 4df6f69
docs(adr): index OpenTelemetry packaging plan
seonghobae 157f64c
test(docs): bind OpenTelemetry packaging gap to PRD and ADR
seonghobae 3aa6f15
test(docs): match ADR status formatting
seonghobae 83a4e04
test(docs): require OpenTelemetry gap traceability
seonghobae 3fcca80
docs(traceability): track OpenTelemetry packaging gap
seonghobae cc38344
docs(fitness): classify OpenTelemetry packaging gap
seonghobae cc7f895
test(docs): require tokenizer and version gap traceability
seonghobae 1c51625
test(docs): require current buyer gap backlog in PRD
seonghobae 9987407
docs(prd): classify current buyer-visible gaps
seonghobae c0bd134
docs(trd): classify tokenizer and version authority gaps
seonghobae 85eb34c
docs(fitness): classify tokenizer and version gaps
seonghobae 3978411
docs(traceability): bind tokenizer and version gap owners
seonghobae 2745c77
test(docs): require current packaging gap owners
seonghobae 9f59d98
docs(product): classify current packaging gaps
seonghobae d07c38e
docs(trd): own packaging toolchain gaps
seonghobae b38d71d
docs(fitness): classify packaging evidence gaps
seonghobae ee45e61
docs(traceability): link packaging gap owners
seonghobae 20f0efc
test(docs): require CLI argv gap owners
seonghobae fd697fe
docs(product): own CLI argv privacy gaps
seonghobae 6d98344
docs(trd): own CLI argv authority gaps
seonghobae 865bb6b
test(docs): require PostgreSQL logging privacy ownership
seonghobae f65ad75
docs(prd): own PostgreSQL logging privacy hardening
seonghobae 20d0665
docs(trd): classify PostgreSQL query-text privacy boundary
seonghobae 0411bd1
docs(threat): classify PostgreSQL query-text disclosure
seonghobae 8196060
docs(fitness): reconcile privacy and argv gap maturity
seonghobae 1b6e36a
docs(traceability): map argv and PostgreSQL privacy gaps
seonghobae 55ccb57
test(docs): require PostgreSQL image supply-chain owner
seonghobae efe3236
docs(prd): own PostgreSQL image supply-chain gap
seonghobae 1c7f8d0
test(docs): require bounded logging operability follow-up
seonghobae 8aa47a5
docs(prd): classify container logging operability gap
seonghobae 83bde08
docs(trd): own PostgreSQL image and logging gaps
seonghobae 247a3aa
docs(fitness): classify PostgreSQL supply-chain and logging gaps
seonghobae e1dcdaa
docs(traceability): link PostgreSQL image and logging follow-ups
seonghobae 45a784f
fix(test): bound issue entries by headings
seonghobae 7ea4cc0
test(docs): require explicit secret encryption policy gap
seonghobae e1657eb
docs(security): define planned provider-secret encryption policy
seonghobae c87e602
docs(adr): index planned provider-secret encryption policy
seonghobae ef0b36c
test(docs): bind secret policy gap to indexed ADR
seonghobae 059dd36
docs(prd): track explicit provider-secret encryption policy
seonghobae c880461
docs(trd): define provider-secret encryption policy target
seonghobae cad74b8
test(docs): bind secret policy to PRD and TRD targets
seonghobae 0d952ad
docs(fitness): classify provider-secret encryption policy gap
seonghobae 32fa95d
docs(traceability): link provider-secret encryption policy gap
seonghobae a31c71b
test(docs): align secret-policy status assertion with Markdown
seonghobae e08a167
test(docs): bind secret baseline assertion to Markdown authority
seonghobae 2a7b58b
test(docs): require database timeout gap ownership
seonghobae 564c320
docs(prd): track bounded PostgreSQL wait policy
seonghobae 1ef3f7b
docs(trd): bound planned PostgreSQL wait authority
seonghobae 791ed7b
docs(operability): track database wait budgets
seonghobae 82b229d
docs(fitness): classify database wait-budget gap
seonghobae cb6b113
docs(traceability): map database wait-budget gap
seonghobae 69f9363
test(docs): align wait-budget authority assertion
seonghobae d77ae46
test(docs): require PostgreSQL transport security owner
seonghobae 17350d8
docs(security): define PostgreSQL transport policy
seonghobae 6820edc
docs(product): track PostgreSQL transport security gap
seonghobae b56bce6
docs(adr): index PostgreSQL transport security decision
seonghobae c345c7d
test(docs): bind transport gap to canonical ADR
seonghobae f926b06
test(docs): require transport policy traceability
seonghobae e2d0375
docs(traceability): link PostgreSQL transport policy
seonghobae e410666
test(docs): require virtual payload integrity authority
seonghobae 16ed2c5
docs(adr): define virtual JSONL payload integrity
seonghobae 7eab797
docs(adr): index virtual payload integrity
seonghobae fe4a2c8
test(docs): bind payload integrity to canonical ADR
seonghobae 390102c
docs(adr): bind payload text to line count
seonghobae c1317b0
test(docs): require payload count consistency
seonghobae be71651
test(docs): match normalized ADR labels
seonghobae b0e1b81
docs(payload): make pre-provider validation contract explicit
seonghobae 885f2c4
test(docs): require lifecycle diagnostic and metadata failure boundaries
seonghobae f6224bc
docs(adr): define bounded lifecycle failure diagnostics
seonghobae 2d0ae12
docs(adr): define endpoint-qualified tokenizer authority
seonghobae b596a33
docs(trd): bound lifecycle and tokenizer failure authority
seonghobae 35e3cf1
docs(threat): classify tokenizer and lifecycle diagnostic failures
seonghobae abbf696
docs(traceability): own lifecycle diagnostic confidentiality
seonghobae c5e11bb
docs: close lifecycle diagnostics fitness gap
seonghobae 4f5a775
test(docs): require tokenizer and lifecycle field owners
seonghobae 009716f
docs: classify tokenizer and lifecycle field gaps
seonghobae d493204
docs: classify tokenizer and lifecycle field threats
seonghobae 2a922ab
docs: trace tokenizer and lifecycle field gaps
seonghobae e849091
docs: classify tokenizer and lifecycle field fitness
seonghobae 19905c1
test(docs): require credential representation confidentiality gap
seonghobae 47794d2
docs(api): classify credential representation privacy gap
seonghobae aeb0deb
docs(threat): classify credential representation disclosure
seonghobae e01ce46
docs(trace): classify credential representation privacy gap
seonghobae 1edd1b9
docs(fitness): classify credential representation privacy gap
seonghobae 8bc9ce5
docs(prd): classify provider progress validation as active
seonghobae 0d25c0a
docs(trd): bind provider progress validation to active owner
seonghobae b00f086
docs(traceability): promote provider progress owner to active
seonghobae 6cb02ba
test(docs): require recent buyer gaps in PRD
seonghobae dff2f1d
docs(prd): track recent buyer-visible gaps
seonghobae 9a60634
test(docs): require tenant content isolation target
seonghobae fccd5b1
docs(prd): capture tenant content isolation gap
seonghobae a6abf93
test(docs): bind tenant content isolation authorities
seonghobae a104636
docs(erd): expose tenant content isolation gap
seonghobae d590f00
docs(threat): distinguish lifecycle and content tenant isolation
seonghobae 9689291
docs(trace): link tenant content isolation gap
seonghobae 1eb6b9f
test(docs): require token diagnostic privacy target
seonghobae 092bd41
docs(prd): capture token diagnostic privacy gap
seonghobae d6bf12c
test(docs): require latest buyer gaps in PRD
seonghobae 6839e90
docs(product): track latest security gaps
seonghobae 263a22b
test(docs): bind provisioning dependencies structurally
seonghobae 7b4818e
test(docs): require traceability for latest buyer gaps
seonghobae 94615f1
docs(traceability): classify latest security gaps
seonghobae acc6d47
docs(fitness): classify latest buyer gaps
seonghobae 04be894
test(docs): require provider file lifecycle gap
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.