@caddis/cli 0.4.19 → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/bundles/antigravity-plugin/plugin.json +1 -1
  2. package/bundles/antigravity-plugin/skills/_registry.md +4 -2
  3. package/bundles/antigravity-plugin/skills/data-lineage/SKILL.md +32 -0
  4. package/bundles/antigravity-plugin/skills/hld/SKILL.md +20 -8
  5. package/bundles/antigravity-plugin/skills/lld/SKILL.md +27 -12
  6. package/bundles/antigravity-plugin/skills/port-to-github/SKILL.md +231 -0
  7. package/bundles/antigravity-plugin/skills/port-to-github/references/ci-and-credentials.md +66 -0
  8. package/bundles/antigravity-plugin/skills/port-to-github/references/config.example.json +18 -0
  9. package/bundles/antigravity-plugin/skills/port-to-github/references/old-host.md +61 -0
  10. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Compare-PortRefs.ps1 +68 -0
  11. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Convert-PortWorkflow.ps1 +92 -0
  12. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Get-PortSource.ps1 +459 -0
  13. package/bundles/antigravity-plugin/skills/port-to-github/scripts/PortCommon.ps1 +130 -0
  14. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Publish-PortToGitHub.ps1 +156 -0
  15. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Switch-CheckoutOrigin.ps1 +182 -0
  16. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Test-PortReadiness.ps1 +218 -0
  17. package/bundles/antigravity-plugin/skills/port-to-github/scripts/Test-PortWorkflowParses.ps1 +62 -0
  18. package/bundles/antigravity-plugin-extras/plugin.json +1 -1
  19. package/bundles/antigravity-plugin-extras/skills/_registry.md +3 -2
  20. package/bundles/antigravity-plugin-extras/skills/data-lineage/SKILL.md +158 -0
  21. package/bundles/antigravity-plugin-extras/skills/data-lineage/scripts/convert_doc_to_confluence.py +1430 -0
  22. package/bundles/antigravity-plugin-extras/skills/hld/SKILL.md +155 -35
  23. package/bundles/antigravity-plugin-extras/skills/hld/references/gold-standard-hld.md +428 -0
  24. package/bundles/antigravity-plugin-extras/skills/hld/scripts/convert_doc_to_confluence.py +900 -184
  25. package/bundles/antigravity-plugin-extras/skills/lld/SKILL.md +145 -41
  26. package/bundles/antigravity-plugin-extras/skills/lld/scripts/convert_doc_to_confluence.py +900 -184
  27. package/bundles/codex/.codex/skills/devops/port-to-github/SKILL.md +231 -0
  28. package/bundles/codex/.codex/skills/devops/port-to-github/references/ci-and-credentials.md +66 -0
  29. package/bundles/codex/.codex/skills/devops/port-to-github/references/config.example.json +18 -0
  30. package/bundles/codex/.codex/skills/devops/port-to-github/references/old-host.md +61 -0
  31. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Compare-PortRefs.ps1 +68 -0
  32. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Convert-PortWorkflow.ps1 +92 -0
  33. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Get-PortSource.ps1 +459 -0
  34. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/PortCommon.ps1 +130 -0
  35. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Publish-PortToGitHub.ps1 +156 -0
  36. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Switch-CheckoutOrigin.ps1 +182 -0
  37. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Test-PortReadiness.ps1 +218 -0
  38. package/bundles/codex/.codex/skills/devops/port-to-github/scripts/Test-PortWorkflowParses.ps1 +62 -0
  39. package/bundles/manifest.json +3 -3
  40. package/package.json +1 -1
@@ -0,0 +1,428 @@
1
+ ---
2
+ type: design
3
+ status: current
4
+ feature: invoice-composition-replacement
5
+ creation-agent: caddis
6
+ Original Author: Antigravity
7
+ Creation Date: 2026-09-19T13:35:00Z
8
+ Creating Model: gemini-3.8-flash
9
+ Last Author: Antigravity
10
+ Last Updated: 2026-09-19T14:05:00Z
11
+ Last Model Used: gemini-3.8-flash
12
+ ---
13
+
14
+ <!--
15
+ GOLD STANDARD REFERENCE for the hld skill.
16
+ This is a real HLD whose organisation-specific facts (company, vendors, hosts, paths, customer
17
+ volumes) were replaced with neutral ones so it can ship publicly. Everything the skill copies
18
+ from it is unchanged: the 8-section structure, heading numbering, the diagram types and their
19
+ styling, the ID schemes (SYS_nn, INT_nn, REQ-nn), and every table's columns. Match THAT, not
20
+ the domain.
21
+ -->
22
+
23
+ # High-Level Architecture (HLA): Invoice Composition Replacement Platform
24
+
25
+ ## 1. Executive Summary
26
+
27
+ ### 1.1 Initiative Goal
28
+ The Invoice Composition Replacement Platform replaces the proprietary third-party invoice composition system that a telecommunications operator uses for fixed-line billing.
29
+
30
+ This platform achieves the following primary business goals:
31
+ - It eliminates third-party licensing costs, proprietary dependencies, and vendor software lock-in.
32
+ - It provides a locally controlled, deterministic, and auditable composition engine.
33
+ - It delivers high-throughput batch generation for four recurring monthly billing cycles: `BR-07`, `BR-14`, `BR-21`, and `BR-28`.
34
+ - It processes approximately 100,000 customer accounts per billing run within a four-hour service level agreement (SLA) window.
35
+ - It simultaneously produces four synchronized output channels from a single canonical document model: Customer PDF, Print Spool AFP, Mailroom Index JRN, and Digital Portal XML.
36
+ - It guarantees full financial integrity through mandatory, fail-closed automated reconciliation gates.
37
+
38
+ ### 1.2 Solution Architecture Summary
39
+ The solution operates as a standalone Python-based batch processing engine deployed on host `batch-host-01`. It processes raw billing stream files (`.EN`) from the upstream billing engine, executes financial reconciliation, and renders customer-facing outputs. The engine isolates every run in an immutable staging directory, verifies cryptographic checksums, and publishes outputs atomically only after all financial and population gates pass.
40
+
41
+ ### 1.3 Business Value & Operational Outcomes
42
+ - **Cost Reduction**: Complete decommissioning of third-party composition licenses.
43
+ - **Operational Autonomy**: Full internal control over document templates, business rules, and legal notices.
44
+ - **Audit Defensibility**: Cryptographic sealing of every batch run with complete provenance manifests and append-only event journals.
45
+ - **Financial Compliance**: Zero-tolerance reconciliation preventing billing discrepancies between rated data and rendered customer invoices.
46
+
47
+ ---
48
+
49
+ ## 2. Project Context and Scope
50
+
51
+ ### 2.1 Background
52
+ The operator's fixed customer billing produces monthly invoices across four staggered billing cycles. The legacy composition workflow relied on an external vendor system. This introduced high annual licensing costs and operational delays whenever regulatory or template changes occurred. The replacement platform moves invoice composition entirely onto internal infrastructure using high-performance open standards.
53
+
54
+ ### 2.2 Scope
55
+
56
+ #### 2.2.1 In Scope
57
+ - Ingestion of raw `.EN` tagged-record stream files generated by the upstream billing engine.
58
+ - Syntactic and structural validation of incoming batch streams with marker-file arrival detection.
59
+ - Transformation of raw stream records into an immutable, strongly typed canonical domain model.
60
+ - Full-population financial reconciliation covering invoice totals, line item aggregates, tax breakdowns, and balance brought forward.
61
+ - Version-controlled template selection and date-effective static legal content resolution.
62
+ - High-performance direct-draw PDF rendering using PyMuPDF with byte-level determinism.
63
+ - High-speed print spool generation using MO:DCA AFP binary encoding.
64
+ - Print house journal index generation for postal insertion and mailroom tracking.
65
+ - Lossless structured XML generation for online customer self-service portals.
66
+ - Run-level cryptographic manifest creation and append-only event journaling.
67
+ - Atomic publication to destination endpoints with isolated staging and late-arriving release markers.
68
+
69
+ #### 2.2.2 Out of Scope
70
+ - Upstream rating, charging, or billing account balance calculation performed by the billing engine.
71
+ - Direct management or control of physical print-house insertion machinery and postal sorters.
72
+ - Real-time customer web serving; online portals ingest published outputs asynchronously.
73
+ - Probabilistic, generative, or Large Language Model (LLM) components in the financial generation path.
74
+
75
+ ### 2.3 Architecture Boundaries and Key Assumptions
76
+ - **Deterministic Processing**: All calculations and document renderings produce identical, byte-reproducible outputs for identical inputs.
77
+ - **Local Filesystem Isolation**: Network-isolated execution on `batch-host-01` with zero runtime external API or HTTP dependencies.
78
+ - **Fail-Closed Operations**: Any financial discrepancy, unmapped record, or population count mismatch immediately halts the run and prevents output release.
79
+
80
+ ---
81
+
82
+ ## 3. Solution Approach and Workflow
83
+
84
+ ### 3.1 Operational Process Flow
85
+
86
+ The batch execution pipeline operates across five consecutive stages governed by a strict nine-state finite state machine (`RunLifecycle`):
87
+ `RECEIVED` -> `INGESTING` -> `INPUT_VALIDATED` -> `GENERATING` -> `VALIDATING` -> `RECONCILING` -> `READY_FOR_RELEASE` -> `PUBLISHING` -> `RELEASED`.
88
+
89
+ ```mermaid
90
+ flowchart LR
91
+ classDef stageStyle fill:#F8FAFC,stroke:#475569,stroke-width:2px,color:#0F172A;
92
+ classDef gateStyle fill:#FEF2F2,stroke:#DC2626,stroke-width:2px,color:#991B1B;
93
+
94
+ subgraph S1["Stage 1: Ingestion & Staging"]
95
+ direction TB
96
+ P1["Check Marker & File Stability"]:::stageStyle
97
+ P2["Stage Input & Verify SHA-256"]:::stageStyle
98
+ end
99
+
100
+ subgraph S2["Stage 2: Canonical Mapping"]
101
+ direction TB
102
+ P3["Parse Tagged-Record Stream"]:::stageStyle
103
+ P4["Build Canonical BillDocument"]:::stageStyle
104
+ end
105
+
106
+ subgraph S3["Stage 3: Reconciliation Gate"]
107
+ direction TB
108
+ P5["Full-Population Financial Gate"]:::gateStyle
109
+ P6["Resolve Date-Effective Content"]:::stageStyle
110
+ end
111
+
112
+ subgraph S4["Stage 4: Composition & Rendering"]
113
+ direction TB
114
+ P7["Render Direct-Draw PDF"]:::stageStyle
115
+ P8["Compose AFP, JRN & XML"]:::stageStyle
116
+ end
117
+
118
+ subgraph S5["Stage 5: Atomic Release & Publish"]
119
+ direction TB
120
+ P9["Cross-Output Population Audit"]:::stageStyle
121
+ P10["Atomic Copy & Write Release Marker"]:::stageStyle
122
+ end
123
+
124
+ P1 --> P2
125
+ P2 --> P3
126
+ P3 --> P4
127
+ P4 --> P5
128
+ P5 --> P6
129
+ P6 --> P7
130
+ P7 --> P8
131
+ P8 --> P9
132
+ P9 --> P10
133
+ ```
134
+
135
+ ### 3.2 End-to-End Operational Sequence Diagram
136
+
137
+ The sequence diagram below illustrates the batch execution sequence from cycle trigger through atomic publication:
138
+
139
+ ```mermaid
140
+ sequenceDiagram
141
+ autonumber
142
+ participant Sched as Automated Batch Scheduler
143
+ participant Orch as Batch Orchestrator
144
+ participant Reader as Tagged-Record Ingestor
145
+ participant Reconcile as Financial Reconciliation Gate
146
+ participant Render as Multi-Channel Composition Engine
147
+ participant Audit as Cryptographic Audit Logger
148
+ participant Storage as Working Staging Root
149
+ participant Targets as Production Distribution Endpoints
150
+
151
+ Note over Sched,Targets: Stage 1: Ingestion & Verification
152
+ Sched->>Orch: Trigger cycle run (e.g. BR-07)
153
+ Orch->>Storage: Verify incoming .EN stream and arrival marker
154
+ Orch->>Storage: Stage input files and compute baseline SHA-256 hashes
155
+ Orch->>Audit: Record RunLifecycle::INPUT_VALIDATED
156
+
157
+ Note over Orch,Reconcile: Stage 2 & 3: Parsing, Mapping & Financial Gate
158
+ Orch->>Reader: Stream staged .EN tagged records
159
+ Reader->>Reader: Map raw tokens to canonical BillDocument model
160
+ Orch->>Reconcile: Execute full-population financial balance audit
161
+ alt Financial Discrepancy Found
162
+ Reconcile-->>Orch: Financial mismatch error (fail-closed)
163
+ Orch->>Audit: Record RunLifecycle::FAILED with audit delta
164
+ Orch-->>Sched: Abort run execution
165
+ else All Accounts Balanced
166
+ Reconcile-->>Orch: Reconciliation passed (0 errors)
167
+ Orch->>Audit: Record RunLifecycle::GENERATING
168
+ end
169
+
170
+ Note over Orch,Render: Stage 4: Multi-Channel Composition
171
+ par Parallel Rendering
172
+ Orch->>Render: Render byte-deterministic PDF invoices (PyMuPDF)
173
+ Orch->>Render: Generate MO:DCA AFP print spools
174
+ Orch->>Render: Compile JRN mailroom insertion indexes
175
+ Orch->>Render: Emit lossless eBilling XML files
176
+ end
177
+ Render->>Storage: Write outputs into staging directories
178
+
179
+ Note over Orch,Targets: Stage 5: Population Audit & Atomic Release
180
+ Orch->>Audit: Verify population counts (PDF == XML == AFP == 100,000)
181
+ Orch->>Audit: Seal freeze-manifest.json and compute final SHA-256 digests
182
+ Orch->>Audit: Transition to RunLifecycle::READY_FOR_RELEASE
183
+ Orch->>Targets: Copy verified artifacts to delivery endpoints
184
+ Orch->>Targets: Write atomic release marker file (.COMPLETE)
185
+ Orch->>Audit: Transition to RunLifecycle::RELEASED
186
+ Orch-->>Sched: Batch execution completed successfully
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 4. Solution Architecture Landscape
192
+
193
+ ### 4.1 Solution Design and Architecture
194
+
195
+ The solution landscape connects the upstream billing rating engine, the core batch transformation platform, and downstream customer presentation and physical print channels.
196
+
197
+ ```mermaid
198
+ flowchart TD
199
+ classDef existingStyle fill:#EFF6FF,stroke:#2563EB,stroke-width:2px,color:#1E40AF;
200
+ classDef newStyle fill:#FEF2F2,stroke:#DC2626,stroke-width:2px,color:#991B1B;
201
+
202
+ subgraph Upstream["Upstream Billing Systems"]
203
+ direction LR
204
+ SYS_01["SYS_01: Billing & Rating Engine<br/>Rating & Billing Lifecycle"]:::existingStyle
205
+ end
206
+
207
+ subgraph CorePlatform["Invoice Composition Replacement Platform (batch-host-01)"]
208
+ direction LR
209
+ SYS_02["SYS_02: Composition Replacement Engine<br/>Ingestion, Mapping, Reconcile & Render"]:::newStyle
210
+ SYS_06["SYS_06: Operations Control Centre<br/>Audit Journal, Sealed Manifest & CLI"]:::newStyle
211
+ end
212
+
213
+ subgraph Downstream["Downstream Distribution Channels"]
214
+ direction LR
215
+ SYS_03["SYS_03: Print House & Mailroom<br/>Physical Print & Insertion Spool"]:::existingStyle
216
+ SYS_04["SYS_04: Customer Self-Service Portal<br/>Online eBilling XML Viewer"]:::existingStyle
217
+ SYS_05["SYS_05: Enterprise Document Archive<br/>Customer PDF Storage & Email"]:::existingStyle
218
+ end
219
+
220
+ SYS_01 -->|"INT_01: .EN Billing Stream & Marker"| SYS_02
221
+ SYS_02 -->|"INT_02: MO:DCA AFP Spools"| SYS_03
222
+ SYS_02 -->|"INT_03: JRN Insertion Indexes"| SYS_03
223
+ SYS_02 -->|"INT_04: eBilling XML Batches"| SYS_04
224
+ SYS_02 -->|"INT_05: Deterministic PDF Invoices"| SYS_05
225
+ SYS_02 -->|"INT_06: Telemetry & Sealed Manifest"| SYS_06
226
+ ```
227
+
228
+ ### 4.2 Applications and Components Overview
229
+
230
+ The table below catalogs all systems and platforms within the solution boundary:
231
+
232
+ | ID | Application / Component | Application Type | Description | Impacted |
233
+ |---|---|---|---|---|
234
+ | `SYS_01` | Billing & Rating Engine | Billing / Rating | Upstream rating engine producing periodic `.EN` billing stream files. | No |
235
+ | `SYS_02` | Composition Replacement Engine | Batch Engine | Core batch orchestration, mapping, financial reconciliation, and multi-channel rendering engine. | Yes |
236
+ | `SYS_03` | External Print House & Mailroom Spool | Print Production | Commercial printing facility ingesting MO:DCA AFP spools and JRN insertion records. | No |
237
+ | `SYS_04` | Customer Self-Service Portal | Web Portal | Customer billing portal ingesting structured eBilling XML for web presentation. | No |
238
+ | `SYS_05` | Enterprise Document Archive & Dispatcher | Document Repository | Long-term customer communications repository and email dispatcher ingesting certified PDF invoices. | No |
239
+ | `SYS_06` | Operations Control Centre & Audit Journal | Ops & Governance | Operational monitoring CLI, telemetry aggregator, and sealed run manifest validator. | Yes |
240
+
241
+ #### 4.2.1 SYS_01: Billing & Rating Engine
242
+ The billing engine calculates customer monthly billing totals, rating, and payment adjustments. At cycle close, it exports raw `.EN` tagged-record stream files to the staging transfer area.
243
+
244
+ #### 4.2.2 SYS_02: Composition Replacement Engine
245
+ The core processing component implemented in Python. It executes local staging, canonical data mapping, strict financial reconciliation, and parallel document rendering.
246
+
247
+ #### 4.2.3 SYS_03: External Print House & Mailroom Spool
248
+ Receives binary MO:DCA AFP print spools and JRN insertion index files for postal sorting, physical paper printing, envelope inserting, and mail dispatch.
249
+
250
+ #### 4.2.4 SYS_04: Customer Self-Service Portal
251
+ The customer-facing digital web application that parses structured XML invoice streams to present interactive online bill breakdowns.
252
+
253
+ #### 4.2.5 SYS_05: Enterprise Document Archive & Dispatcher
254
+ The central document store that ingests byte-deterministic PDF files for permanent customer record retention and automated email bill dispatch.
255
+
256
+ #### 4.2.6 SYS_06: Operations Control Centre & Audit Journal
257
+ The administrative command-line and operational tooling suite used to trigger batch runs, monitor state transitions, verify cryptographic checksums, and inspect audit logs.
258
+
259
+ ### 4.3 Interfaces
260
+
261
+ The table below details all communication interfaces across the platform boundary:
262
+
263
+ | ID | Type / Protocol | From | To | Description | Connectivity |
264
+ |---|---|---|---|---|---|
265
+ | `INT_01` | SFTP / SMB File Feed | `SYS_01` | `SYS_02` | Tagged-record billing stream (`.EN`) and cycle marker file. | Existing Connectivity |
266
+ | `INT_02` | Secure File Transfer | `SYS_02` | `SYS_03` | MO:DCA AFP binary print stream partitioned at source-EN granularity. | New Connectivity |
267
+ | `INT_03` | Secure File Transfer | `SYS_02` | `SYS_03` | Tabular ASCII index files (`.JRN`) containing mailroom insertion records. | New Connectivity |
268
+ | `INT_04` | Secure File Transfer | `SYS_02` | `SYS_04` | Lossless structured XML documents matching customer portal schema. | New Connectivity |
269
+ | `INT_05` | Secure File Transfer | `SYS_02` | `SYS_05` | Certified, byte-deterministic PDF customer invoices. | New Connectivity |
270
+ | `INT_06` | Local File / JSONL | `SYS_02` | `SYS_06` | Append-only execution journal, telemetry events, and sealed manifest. | New Connectivity |
271
+
272
+ #### 4.3.1 INT_01: Billing Stream & Completion Marker
273
+ Transfers raw `.EN` data files containing account records, billing headers, charge breakdowns, and payment histories. A completion marker file signals batch completeness.
274
+
275
+ #### 4.3.2 INT_02: MO:DCA AFP Print Spools
276
+ Delivers structured binary AFP spools formatted for high-speed commercial printers. Each AFP file corresponds to an upstream input batch.
277
+
278
+ #### 4.3.3 INT_03: JRN Mailroom Insertion Indexes
279
+ Delivers ASCII index files specifying sheet counts, account identifiers, envelope barcodes, and selective advertising insert triggers.
280
+
281
+ #### 4.3.4 INT_04: eBilling XML Batches
282
+ Transfers schema-validated XML documents containing invoice data for online customer self-service viewing.
283
+
284
+ #### 4.3.5 INT_05: Deterministic PDF Invoices
285
+ Transfers byte-deterministic PDF documents containing vector brand artwork, billing transaction tables, and payment slips.
286
+
287
+ #### 4.3.6 INT_06: Telemetry & Sealed Manifest
288
+ Emits structured JSONL telemetry and a cryptographic `release_manifest.json` sealing file counts, execution parameters, and SHA-256 hashes.
289
+
290
+ ### 4.4 Primary Production Execution Surfaces
291
+ The platform provides administrative command-line surfaces for operations and scheduling:
292
+ - `python -m src.cli run --cycle BR-07`: Executes an end-to-end scheduled batch run.
293
+ - `python -m src.cli verify --run-id <ID>`: Validates stage outputs and cryptographic manifests.
294
+ - `python -m src.cli reconcile --run-id <ID>`: Executes standalone full-population financial audits.
295
+ - `python -m src.cli status`: Queries active pipeline state, worker progress, and memory utilization.
296
+
297
+ ### 4.5 Auxiliary and Operational Audit Surfaces
298
+ - **Freeze Manifests**: `<working_root>/<run_id>/<attempt_id>/manifests/freeze-manifest.json` locks template versions, configuration files, and legal text snapshots before rendering starts.
299
+ - **Release Manifests**: `<working_root>/<run_id>/<attempt_id>/manifests/release_manifest.json` contains cryptographic SHA-256 hashes for all generated output files.
300
+ - **Execution Evidence**: `<working_root>/<run_id>/<attempt_id>/evidence/` contains test logs, financial reconciliation summaries, and output population audits.
301
+
302
+ ---
303
+
304
+ ## 5. High-Level Data and Storage Architecture
305
+
306
+ ### 5.1 Host & Working Storage Topology
307
+ The engine executes entirely within a dedicated local filesystem hierarchy on host `batch-host-01`. Every batch run is isolated by unique run and attempt identifiers:
308
+
309
+ ```
310
+ <working_root>/<run_id>/<attempt_id>/
311
+ ├── input/ # Immutable local copy of source .EN files
312
+ ├── staging/ # Active rendering and composition working directory
313
+ │ ├── pdf/ # Rendered PDF files
314
+ │ ├── xml/ # Generated eBilling XML files
315
+ │ ├── afp/ # Generated MO:DCA AFP print spools
316
+ │ └── jrn/ # Generated JRN insertion journals
317
+ ├── output/ # Ready-for-release consolidated output artifacts
318
+ ├── manifests/ # Frozen configuration, effective hashes, and audit logs
319
+ │ ├── content.yml # Frozen legal and marketing text snapshot
320
+ │ ├── effective-config.json
321
+ │ └── freeze-manifest.json
322
+ └── evidence/ # Automated test reports, parity logs, and execution evidence
323
+ ```
324
+
325
+ ### 5.2 Canonical Domain Entity Model
326
+
327
+ The domain entity model enforces type safety and monetary precision across all transformation steps:
328
+
329
+ ```mermaid
330
+ classDiagram
331
+ class BillDocument {
332
+ +String invoice_id
333
+ +String account_number
334
+ +Date issue_date
335
+ +Date due_date
336
+ +Decimal total_amount
337
+ +Decimal balance_brought_forward
338
+ +Decimal amount_due
339
+ +List~ChargeItem~ charges
340
+ +List~PaymentRecord~ payments
341
+ +List~TaxItem~ tax_items
342
+ }
343
+ class ChargeItem {
344
+ +String description
345
+ +String category
346
+ +Decimal gross_amount
347
+ +Decimal vat_rate
348
+ +Decimal vat_amount
349
+ }
350
+ class PaymentRecord {
351
+ +Date payment_date
352
+ +String payment_method
353
+ +Decimal amount
354
+ }
355
+ class TaxItem {
356
+ +Decimal vat_rate
357
+ +Decimal net_amount
358
+ +Decimal vat_amount
359
+ }
360
+
361
+ BillDocument "1" *-- "many" ChargeItem
362
+ BillDocument "1" *-- "many" PaymentRecord
363
+ BillDocument "1" *-- "many" TaxItem
364
+ ```
365
+
366
+ ### 5.3 Multi-Channel Output Volume & Specifications
367
+ Production metrics established during candidate certification (ATT-006 baseline):
368
+ - **PDF Documents**: 100,750 total PDF files (100,000 primary invoices + 750 secondary itemized schedules).
369
+ - **XML Documents**: 100,000 structured customer eBilling files.
370
+ - **AFP Spools**: 32 consolidated MO:DCA print files matching the 32 upstream input batches.
371
+ - **JRN Journals**: 32 postal index files containing 100% field parity with postal insertion machinery.
372
+
373
+ ---
374
+
375
+ ## 6. Security Architecture and Controls
376
+
377
+ The platform security architecture adheres to strict controls defined in `docs/SECURITY_AND_PRIVACY.md`:
378
+
379
+ ### 6.1 Hardened Parsing & Processing Controls
380
+ - **XML Security**: `ingestion/xml_reader.py` disables external entity resolution (`resolve_entities=False`), network access (`no_network=True`), and DTD loading. Any incoming document containing a `DOCTYPE` declaration is rejected immediately. Input file size is capped at 10 MiB to prevent memory exhaustion attacks.
381
+ - **Output Escaping**: The Jinja2 rendering environment enforces `autoescape=True` unconditionally. File loaders are confined to approved template directories to prevent path traversal attacks.
382
+
383
+ ### 6.2 Zero Runtime Network Access
384
+ - No module within `ingestion/`, `mapping/`, `templating/`, or `rendering/` initiates external HTTP or network requests during generation.
385
+ - All fonts, styling assets, and configuration templates reside locally on disk on `batch-host-01`.
386
+
387
+ ### 6.3 Working Storage Path Isolation & Traversal Defense
388
+ - File discovery resolves candidate paths and rejects any file whose resolved parent directory escapes the staging root.
389
+ - Output filenames derive from validated invoice identifiers using a strict alphanumeric pattern (`[A-Za-z0-9._-]`). Path traversal attempts are rejected immediately.
390
+
391
+ ### 6.4 Privacy and Audit Redaction
392
+ - Domain models override string representations to redact personal customer names and street addresses from log outputs.
393
+ - Upstream customer metadata categories (`FIRSTNAME`, `EMAIL`, `OFFNETID`, `POSTCODE`) are dropped during ingestion mapping.
394
+ - Audit manifests record only source file basenames, billing reference numbers, and one-way SHA-256 correlation identifiers.
395
+
396
+ ---
397
+
398
+ ## 7. Architecture Traceability Matrix
399
+
400
+ ### 7.1 Architecture Traceability Matrix
401
+
402
+ | Requirement | Description | Component Implementation | Verification Control |
403
+ |---|---|---|---|
404
+ | `REQ-01` | Ingest `.EN` tagged-record streams | `SYS_02` (`ingestion/en_reader.py`) | Automated parser unit tests and zero-failure batch validation. |
405
+ | `REQ-02` | Strong financial reconciliation | `SYS_02` (`reconciliation/checks.py`) | Full-population balance reconciliation gate (`reconcile()`). |
406
+ | `REQ-03` | Byte-deterministic PDF rendering | `SYS_02` (`rendering/mupdf_renderer.py`) | SHA-256 byte-identity verification against certified baseline. |
407
+ | `REQ-04` | Multi-channel parity (PDF/XML/AFP/JRN) | `SYS_02` (`mapping/*`, `rendering/*`) | Cross-output population count verification (`100,000` exact). |
408
+ | `REQ-05` | Atomic release & staging isolation | `SYS_02` (`batch/orchestrator.py`) | Zero output visibility before `READY_FOR_RELEASE` and marker written last. |
409
+ | `REQ-06` | Auditability & run sealing | `SYS_06` (`audit/manifest.py`) | Cryptographic `release_manifest.json` generation. |
410
+
411
+ ---
412
+
413
+ ## 8. Appendix
414
+
415
+ ### 8.1 Terms and Definitions
416
+
417
+ | Term | Definition |
418
+ |---|---|
419
+ | `.EN` | Proprietary tagged-record flat file format emitted by the upstream billing engine. |
420
+ | AFP | Advanced Function Presentation / MO:DCA binary print architecture used in industrial mailrooms. |
421
+ | JRN | Journal insertion index file coordinating automated paper folding and envelope stuffing. |
422
+ | Byte Determinism | The guarantee that identical inputs rendered with identical parameters yield identical binary SHA-256 hashes. |
423
+ | Fail-Closed | An architectural principle where any detected inconsistency aborts processing before releasing outputs. |
424
+
425
+ ### 8.2 Reference Documents
426
+ - `<repo>/README.md`: System operational runbook and architecture overview.
427
+ - `<repo>/docs/SECURITY_AND_PRIVACY.md`: Security controls and privacy safeguards.
428
+ - `<repo>/docs/PRODUCTION_CANDIDATE_ATT006.md`: Candidate certification report and benchmark results.