@caddis/cli 0.4.19 → 0.4.21

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