@caddis/cli 0.4.14 → 0.4.15

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.
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: pr-merge
3
+ description: End-to-end pull request and merge lane — push feature branch, open or update PR, monitor CI to green, merge to default branch, and clean up the feature branch.
4
+ ---
5
+
6
+ # /pr-merge — the unified reviewed lane: branch → PR → green → merged → cleaned up
7
+
8
+ End-to-end delivery of feature-branch work through the reviewed lane in one shot: run preflight checks,
9
+ push safely, create or update the Pull Request, monitor CI checks to green, merge into the default
10
+ branch, validate the deployment, and clean up the feature branch.
11
+
12
+ For a hotfix straight to the default branch with no PR ceremony, use `/ship` (the express lane) instead.
13
+ To open a PR and stop at green for human review without merging, use `/ship-pr`.
14
+ To merge an already-opened PR, use `/ship-merge`.
15
+
16
+ Optional argument: **$ARGUMENTS** (PR title override; default = derived from the branch's
17
+ conventional-commit summary). An optional strategy override (`squash` | `merge` | `rebase`)
18
+ can be provided.
19
+
20
+ ## Step 0 — Detect the lane (before anything else)
21
+
22
+ - **Gitea lane** — `.gitea/workflows/` exists. PR creation, CI monitoring, and merge via the Gitea API
23
+ (token loading and job-polling procedure: the `deploy-local` skill).
24
+ - **GitHub lane** — `.github/workflows/` exists (and no `.gitea/`). PR creation, checks monitoring,
25
+ and merge via the `gh` CLI (`gh pr create`, `gh pr checks --watch`, `gh pr merge` — see the `gh-cli` skill).
26
+ - **Local-only lane** — neither exists, or there is no push remote. There is no forge and no PR concept:
27
+ **refuse early**, tell the user to use `/ship`, and stop. Do not fabricate a PR flow.
28
+
29
+ Read `AGENTS.md` + the detected workflow file(s) first for the repo's real gate names, default
30
+ branch, and merge conventions — never assume `main`, never assume job names.
31
+
32
+ ## Step 1 — Refuse on the default branch
33
+
34
+ A PR is *branch → default*. If HEAD **is** the default branch, stop and point at `/ship` — there is
35
+ nothing to open a PR from. (Offer to create a feature branch from the current work if the changes
36
+ are uncommitted.)
37
+
38
+ ## Step 2 — Preflight (local gates mirroring CI)
39
+
40
+ - Backend: `ruff check .` clean (or repository linter).
41
+ - Frontend: `npm run typecheck && npm run build` if `frontend/` exists.
42
+ - Fix failures first. **Never open a PR over red preflight** — a PR that arrives red wastes CI resources
43
+ and reviewer time.
44
+
45
+ ## Step 3 — Scope-guard pre-check (before the PR exists)
46
+
47
+ - If the repo has a **named scope-guard workflow** (e.g. a Gitea `pr-scope-guard` that blocks PRs
48
+ mixing infra `.gitea/`/`.github/` changes with product `src/`/`frontend/`/`tests/` changes): read
49
+ the workflow's own rule and check the branch diff against exactly that rule **before** creating
50
+ the PR. On a violation, **refuse with the specific offending files** — do not let the guard fail
51
+ the PR after the fact.
52
+ - Without a named guard, apply the generic infra-vs-product mixed-diff heuristic as a **warning
53
+ only** — surface it and proceed (repos without a guard allow mixed PRs by construction).
54
+
55
+ ## Step 3b — Cross-review trigger (before anything is pushed)
56
+
57
+ <!-- shared:cross-review-trigger — keep byte-identical across commands; a test pins it -->
58
+ **Run the trigger, do not eyeball the diff:**
59
+
60
+ ```bash
61
+ python "${CLAUDE_PLUGIN_ROOT}/scripts/caddis_gate.py" review-trigger --range <base>...HEAD
62
+ ```
63
+
64
+ Exit **0** — say nothing, carry on. Exit **2** — it prints which rule fired and on which files.
65
+ Run `/caddis:cross-review`, show the findings, and let the user decide. It **never blocks**: this
66
+ picks when to ask for a second opinion, it is not a verdict, and a review gate that blocks a ship
67
+ gets switched off inside a week.
68
+
69
+ It fires on SQL and repositories, `services/`, caches and refresh jobs, auth and RBAC, or a diff
70
+ over 400 changed lines. No judgement in any of those — deliberately, because judgement is exactly
71
+ what failed.
72
+ <!-- /shared:cross-review-trigger -->
73
+
74
+ ## Step 4 — Rebase-safe currency
75
+
76
+ - If the branch is **behind** the default branch, offer to rebase onto it (stale branches are how
77
+ merges rot). Only when behind — never rebase gratuitously.
78
+ - If the branch was already pushed, a rebase rewrites history. **Snapshot first, then push safely:**
79
+ ```
80
+ git branch backup/<branch>-preship # recovery ref BEFORE any rewrite
81
+ git rebase <default-branch>
82
+ git push --force-with-lease origin <branch> # never bare --force
83
+ ```
84
+
85
+ ## Step 5 — Push + create or update the PR
86
+
87
+ - Push the branch to remote (plain push if no rewrite happened).
88
+ - Create the PR: title from the branch's conventional-commit summary (or `$ARGUMENTS`); body = the
89
+ commit list + a "generated by /pr-merge" note.
90
+ - **Idempotent:** if a PR for this branch **already exists**, reuse it, update its title/body, and
91
+ report it — never error, never open a duplicate.
92
+
93
+ ## Step 6 — Monitor PR CI checks
94
+
95
+ Watch the PR's checks job-by-job until completion:
96
+ - Gitea lane: poll the run for the PR's head SHA via the API (`deploy-local` skill procedure).
97
+ - GitHub lane: `gh pr checks <pr> --watch` / `gh run watch` (`gh-cli` skill).
98
+ - If any check fails (red check): report the failure, classify the cause, and **stop before merging**.
99
+ Do not merge a failing PR. Apply the minimum source fix and re-push.
100
+
101
+ ## Step 7 — Merge to default branch
102
+
103
+ Once all required checks are **green**, there are no merge conflicts, and review requirements are satisfied:
104
+ - Use the repo's configured **merge strategy** — read it from repo settings (Gitea repo settings API /
105
+ `gh repo view --json squashMergeAllowed,mergeCommitAllowed,rebaseMergeAllowed`) and `AGENTS.md`;
106
+ an explicit argument wins. Options: **squash**, **merge-commit**, rebase-merge. **Don't assume** —
107
+ if detection is inconclusive, use merge-commit (never silently squash someone's history without evidence).
108
+ - Execute merge:
109
+ - GitHub: `gh pr merge <pr> --<strategy>` (e.g. `gh pr merge <pr> --squash`).
110
+ - Gitea: call the Gitea PR merge API with the chosen strategy.
111
+ - Record the merge SHA.
112
+
113
+ ## Step 8 — Monitor deployment & validate (if applicable)
114
+
115
+ If the default branch triggers an automated deployment pipeline:
116
+ - Gitea: `lint_and_test` → `deploy_prod` → `release_metadata` (`deploy-local` skill).
117
+ - GitHub: `gh run watch <run-id> --exit-status` on the default branch. If CI-only, note that no deploy occurs.
118
+ - Validate health and deployed SHA if a live service is deployed. If deploy validation fails, report
119
+ immediately and **skip cleanup** (Step 9).
120
+
121
+ ## Step 9 — Close feature-branch lifecycle (Clean up)
122
+
123
+ **Only after** the merge is complete and deployment (if any) is validated green:
124
+ - Switch to the default branch: `git switch <default-branch>`.
125
+ - Fast-forward to the merge commit: `git pull --ff-only origin <default-branch>`.
126
+ - Delete the **local** feature branch: `git branch -d <branch>` (use `-D` only if squashed after verifying tree contents match).
127
+ - Delete the **remote** feature branch: `git push origin --delete <branch>` (if not deleted by forge).
128
+ - Drop the temporary `backup/<branch>-preship` ref if one was created in Step 4.
129
+
130
+ If deploy validation failed: **skip cleanup** entirely and report why — never delete a branch whose
131
+ work may need re-work.
132
+
133
+ ## Step 10 — Report
134
+
135
+ ```
136
+ PR: #<n> <title> — merged (<strategy>) as <merge-sha>
137
+ Checks: <check ✓ per check>
138
+ Deploy: <job ✓ / ✗ per job | n/a>
139
+ Prod SHA: matches merge ✓ | n/a
140
+ Cleanup: remote branch deleted / local branch deleted / backup ref dropped | SKIPPED (<why>)
141
+ ```
142
+
143
+ ## Rules
144
+
145
+ - Never merge a PR whose required checks are red or absent.
146
+ - Never delete a feature branch before its merge is confirmed and any deploy validated.
147
+ - Never `git add -A` without reviewing `git status` first (stage named files only).
148
+ - Never force-push without a `backup/*-preship` recovery ref; force pushes are `--force-with-lease` only.
149
+ - Never edit a workflow file (`.gitea/workflows/`, `.github/workflows/`) to make a gate pass — fix the source.
150
+ - Local-only lane: refuse + point at `/ship`. On the default branch: stop + point at `/ship`.
151
+
152
+ ## Skill reference
153
+
154
+ Gitea API monitoring, deploy tracking, failure triage: the `deploy-local` skill (ships in optional `caddis-extras`).
155
+ GitHub `gh pr create`, `gh pr checks`, `gh pr merge`: the `gh-cli` skill.
@@ -0,0 +1,375 @@
1
+ ---
2
+ name: confluence-hla
3
+ description: Author enterprise High-Level Architecture (HLA) documents in Simplified Technical English and generate Confluence Storage Format XHTML with self-contained PlantUML diagrams, wrapped tables, and zero AI fingerprints. Use when creating high-level architecture designs, architecture documentation for Confluence, or converting markdown architecture to Confluence storage format.
4
+ ---
5
+
6
+ # Confluence High-Level Architecture (HLA) Authoring Skill
7
+
8
+ A cross-agent skill for **Claude Code**, **OpenAI Codex CLI**, and **Antigravity (`agy`)** to research systems, discover data pipelines, author enterprise-grade High-Level Architecture (HLA) documents, and export them directly into clean, self-contained **Confluence Storage Format XHTML** with native PlantUML macros.
9
+
10
+ ---
11
+
12
+ ## 1. Core Principles
13
+
14
+ 1. **Simplified Technical English (ASD-STE100 Style):**
15
+ - Short sentences (under 20 words where possible).
16
+ - Active voice ("The worker queries telemetry" rather than "Telemetry is queried by the worker").
17
+ - Clear, everyday technical words; one concept per sentence.
18
+ - **CRITICAL:** Apply this style naturally. **NEVER** write notices, disclaimers, or metadata banners into the document stating that it was written in Simplified Technical English or ASD-STE100.
19
+ 2. **Zero AI Fingerprints, Zero Em-Dashes & Anti-Slop Discipline:**
20
+ - **NEVER use em-dashes (`—`) or en-dashes (`–`):** Em-dashes are the single most prominent dead giveaway of LLM-generated prose. Enterprise solutions architects do not write em-dashes. Use standard colons (`:`), hyphens (`-`), parentheses (`(...)`), or separate sentences instead.
21
+ - *Banned:* `High-Level Architecture (HLA) — AppointmentAssist`
22
+ - *Required:* `High-Level Architecture (HLA): AppointmentAssist`
23
+ - *Banned:* `- **Cancel Appointment — Area Outage:** ...`
24
+ - *Required:* `- **Cancel Appointment (Area Outage):** ...`
25
+ - *Banned:* `The system — which runs on Windows Server — polls telemetry.`
26
+ - *Required:* `The system runs on Windows Server. It polls telemetry.`
27
+ - **Absolute Ban on AI Slop Buzzwords and Hyperbolic Clichés:**
28
+ - *Banned verbs & nouns:* `delve`, `tapestry`, `plethora`, `beacon`, `game-changer`, `testament`, `revolutionize`, `cornerstone`, `leverage` (use `use`, `read`, or `query`), `foster`, `streamline`, `harnessing`, `embark`, `landscape` (in non-geographical contexts).
29
+ - *Banned adjectives:* `pivotal`, `crucial`, `meticulous`, `seamless`, `holistic`, `robust`, `comprehensive`, `cutting-edge`, `paramount`, `vibrant`.
30
+ - *Banned transitions & framing:* `Furthermore`, `Moreover`, `In conclusion`, `It is important to note`, `Let's explore`, `Here is a breakdown:`, `Key takeaways:`, `Summary:`.
31
+ - **Clean ASCII Punctuation:**
32
+ - Never use curly / smart quotes (`“`, `”`, `‘`, `’`) — always use straight ASCII quotes (`"`, `'`).
33
+ - Never use unicode bullet symbols (`•`) — always use standard markdown hyphens (`-`).
34
+ - Never use backtick formatting on ordinary English nouns.
35
+ - **Zero Meta-Commentary & Self-Referential Announcements:**
36
+ - Never write phrases announcing what the document is doing (e.g., "In this document we delve into...", "As requested by the user...").
37
+ - Start immediately with the title, status, metadata block, and executive overview.
38
+ - **Zero Tool / Agent / Assistant / Model Self-Attribution:**
39
+ - The final Confluence export must **NEVER** contain YAML frontmatter, agent attribution tags, model names, preparation notices, or document references that expose internal repository paths or harness tooling (`caddis`, `claude code`, `codex`, `antigravity`, `asd-ste100`).
40
+ - Note: Production application components (such as a local LLM daemon running on an on-premises GPU server) are documented as objective production system components, but the HLA itself must never attribute its own authorship to AI.
41
+ - **Automated Converter Enforcement:**
42
+ - The converter script (`convert_hla_to_confluence.py`) enforces this automatically by stripping all em-dashes, en-dashes, smart quotes, and AI buzzwords during HTML export.
43
+ 3. **Confluence Native Compatibility (Self-Contained PlantUML):**
44
+ - Uses native Confluence Storage Format XHTML.
45
+ - All tables wrapped with `<table class="wrapped">` and explicit `<colgroup>`.
46
+ - Table of contents generated via `<ac:structured-macro ac:name="toc" ac:schema-version="1"/>`.
47
+ - **Pure PlantUML:** Diagrams are rendered natively via Confluence PlantUML macros. No image uploads, attachments, or base64 data URIs are required—the generated HTML is 100% self-contained and ready for a single copy-paste into the Confluence Source Editor.
48
+ - Guaranteed 100% valid XML parseable by the Confluence Source Editor.
49
+ 4. **Mermaid & PlantUML Full-Text Fidelity (Zero Truncation Rule):**
50
+ - In Markdown (`.md`), always wrap Mermaid text lines using explicit `<br/>` tags (maximum ~35 to 45 characters per line) across actors, notes, messages, node labels, and edge transitions.
51
+ - Never allow unwrapped single-line strings to blow out diagram dimensions (>1200px) or truncate text in Git viewers, VS Code, or Confluence viewports.
52
+ - The converter (`convert_hla_to_confluence.py`) dynamically maps `<br/>` to `\n` in PlantUML so that both formats render complete, untruncated text cleanly.
53
+
54
+ ---
55
+
56
+ ## 2. Standard High-Level Architecture (HLA) Sections
57
+
58
+ When authoring an HLA, strictly adhere to the following 7-section structure:
59
+
60
+ ```
61
+ 1. Executive Summary
62
+ 1.1 Initiative Goal
63
+ 1.2 Solution Architecture Summary (Functional layers)
64
+ 1.3 Business Value & Operational Outcomes
65
+ 2. Project Context and Scope
66
+ 2.1 Background
67
+ 2.2 Scope (In Scope / Out of Scope)
68
+ 2.3 Architecture Boundaries and Assumptions
69
+ 3. Solution Approach and Workflow
70
+ 3.1 Operational Process Flow (Step-by-step numbers)
71
+ 3.2 End-to-End Sequence Diagram (PlantUML sequence diagram with autonumber)
72
+ 4. Solution Architecture Landscape
73
+ 4.1 Solution Design and Architecture (Compact topology and system boundary diagram)
74
+ 4.2 Applications and Components Overview (Wrapped table: ID, Name, Function, Technology, Hosting)
75
+ 4.3 Telemetry and Health Information APIs (Apigee / REST / RPC interfaces with target systems)
76
+ 4.4 Multi-Stage Summarization and Recommendation Pipeline (PlantUML multi-track data flow)
77
+ 4.5 End-to-End Database and Data Processing Pipeline (Mandatory discovery: Source DB -> Staging -> Input -> LLM -> Recs -> UI -> RLHF)
78
+ 4.6 Screener Feedback Service and Continuous Learning (RLHF) (Capturing human decisions, notes, and ground truth)
79
+ 5. Security Architecture and Controls
80
+ 5.1 Identity and Access Management (Authentication protocols, RBAC, loopback binding)
81
+ 5.2 Network Boundaries and Perimeter Controls (Internal subnets, API gateway mediation, service accounts)
82
+ 5.3 Data Protection and Privacy (TLS 1.2+ transit, TDE at rest, payload minimization)
83
+ 5.4 Auditability and Operational Visibility (Trace logging, read-back verification, health checks)
84
+ 6. Target State Roadmap (Work In Progress)
85
+ 6.1 Identity Evolution (e.g. Migration from NTLM to SAML 2.0 / OIDC SSO)
86
+ 6.2 Compute / Intelligence Evolution (e.g. Cloud API to On-Premises GPU / Gemma model)
87
+ 7. Appendix
88
+ 7.1 Terms and Definitions (Wrapped table: Term, Definition)
89
+ [Note: 7.2 References is kept in working Markdown but STRICTLY OMITTED from Confluence HTML]
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 3. High-Level Database and Data Processing Pipeline Discovery
95
+
96
+ Every application in the fleet follows an end-to-end data processing pipeline connecting operational database systems to machine learning intelligence and human screener decisions.
97
+
98
+ ### 3.1 Formal Database Asset & Lineage Hierarchy Notation
99
+
100
+ Do not reference database tables in isolation. In enterprise architectures, tables reside within database catalogs hosted on specific physical or virtual servers, and are transformed or moved by explicit stored procedures or ETL engines running on designated hosts.
101
+
102
+ Always identify data pipeline entities using the full hierarchy:
103
+
104
+ ```
105
+ Host[Server] -> Database[DB] -> Schema.Table[Table/View]
106
+ ```
107
+
108
+ Every lineage stage must explicitly specify:
109
+ 1. **Host Server:** The physical server, cluster, or virtual machine hosting the database engine (e.g., `IEROXAPP2`, `DBUATL01`).
110
+ 2. **Database Catalog:** The database name (e.g., `DERBY`, `Customer_FeedBack_JIT`).
111
+ 3. **Schema & Table / View:** The object namespace and name (e.g., `dbo.CASE_FAULTS`, `dbo.AppScreen_Pending_Calls`).
112
+ 4. **Population / Transformation Mechanism:** The exact script, worker process, SSIS package, or stored procedure (`sp_...`) that populates or updates the table.
113
+ 5. **Executing Host:** The exact machine where the ETL process, worker loop, or stored procedure runs (e.g., on the source database server itself, on a dedicated ETL host, or on the application server).
114
+ 6. **Trigger / Cadence:** The execution trigger (e.g., scheduled cron, continuous polling loop, SQL Agent job, or UI event).
115
+ 7. **Operational Payload:** The specific attributes, signals, or features passed through the stage.
116
+ 8. **Downstream Consumer:** The next service, worker, or human actor reading the entity.
117
+
118
+ ---
119
+
120
+ ### 3.2 Active Database Discovery Protocol (Do NOT Rely Solely on Documentation)
121
+
122
+ Architecture documents and blueprints frequently become outdated or retain deprecated table names. The authoring agent must **actively inspect live configuration, code implementations, and database metadata**:
123
+
124
+ 1. **Configuration & Credential Discovery Protocol:**
125
+ - Scan `.env.*`, `config/.env*`, settings files, and connection strings.
126
+ - **Credential Priority:**
127
+ - **Priority 1 (Standard Fleet User):** Check for database credentials in `.env*`. The default enterprise user across fleet applications is typically `LinkedUser` (extract user, password, and port from config).
128
+ - **Priority 2 (Ambient Windows Auth Fallback):** If `LinkedUser` is absent or connection fails, use ambient Windows Integrated Authentication (`Trusted_Connection=yes;` with the executing user's ambient Windows context). Never hardcode or pin personal usernames so that all team members can execute the skill seamlessly.
129
+ - **Table Exclusion Rule:** Never map backup (`_BU`), partition (`_P1`, `_P2`, `_P\d+`), or historical replica tables. Exclude these during catalog queries and pipeline lineage synthesis to prevent noise.
130
+ - Extract primary database host (`DB_HOST`), secondary/telemetry host (`DERBY_SERVER`), database names (`DB_NAME`, `DERBY_DATABASE`), ODBC driver, and trust settings.
131
+ - Inspect Linked Server definitions (`sys.servers`) on connected hosts to identify cross-database federations and distributed queries.
132
+
133
+ 2. **Active Database Metadata Catalog Querying & Job Discovery:**
134
+ - When database connectivity or credentials exist, query the live database catalog:
135
+ - `INFORMATION_SCHEMA.TABLES` & `sys.tables`: Verify that referenced tables physically exist and identify current row counts and schemas. Distinguish active production tables from retired, backup, or partition tables.
136
+ - `INFORMATION_SCHEMA.ROUTINES` & `sys.procedures`: Identify active stored procedures (e.g., `dbo.usp_LoadCustomerTimeline`, `dbo.usp_CustomerTimeline_ApplyStage`, `dbo.sp_CASE_FAULTS`) that load, clean, or move data.
137
+ - `INFORMATION_SCHEMA.VIEWS`: Inspect view definitions (`OBJECT_DEFINITION` / `VIEW_DEFINITION`) to understand joined tables and upstream dependencies.
138
+ - `msdb.dbo.sysjobs` & `sysjobsteps`: Query live SQL Server Agent jobs to uncover exact scheduled batch loaders, step execution commands, and pipeline schedules.
139
+ - Linked Server Probes (`sys.servers`): Inspect remote data sources and linked gateways (e.g. `SNOWFLAKE_GENESYS`).
140
+
141
+ 3. **Pipeline Worker & Codebase Usage Verification:**
142
+ - Trace background batch scripts, CLI runners, and worker loops (e.g., `run_e2e_now.py`, `appscreen_diagnostics_processor.py`, `pipeline_service.py`, `Run_Genesys_Core_Daily.ps1`).
143
+ - Identify SQL queries, ORM models, and YAML query definitions (`queries_insights.yaml`, etc.) to verify which tables are actually active in application code.
144
+ - **Purge Unreferenced Tables:** Do NOT map tables that merely exist in the database catalog if code analysis shows they are unreferenced by the application (e.g., legacy order tables, obsolete staging tables, or test fixtures).
145
+
146
+ 4. **External ETL Bridges & Cross-Host Script Mapping:**
147
+ - If data originates from an external SaaS/Cloud datashare (e.g., Snowflake, Genesys Cloud, Salesforce) and traverses an ETL gateway server, document the exact bridge scripts (e.g. `C:\Scripts\Genesys\*.py`, `.ps1`), schedule triggers, and target upsert mechanisms.
148
+
149
+ 5. **User Consultation Rule for Remaining Gaps:**
150
+ - If an upstream ETL or batch trigger cannot be confirmed from code or live database catalogs, do not invent names.
151
+ - Summarize the verified facts and ask the user targeted questions to confirm the remaining operational links.
152
+
153
+ ---
154
+
155
+ ### 3.3 Fluid & Dynamic Pipeline Architecture Across Fleet Applications
156
+
157
+ Pipeline stages are **fluid, adaptive, and application-specific**. The authoring agent must **NOT** hardcode or assume the stage names of AppointmentAssist ("Source Trouble Tickets", "Appointment Staging", "Diagnostic Enrichment") across other fleet repositories.
158
+
159
+ The pipeline stage count typically varies between **3 and 8 stages**, depending on the operational archetype of the system:
160
+
161
+ 1. **Decision Support & Triage Systems (e.g., AppointmentAssist):**
162
+ ```
163
+ [1. Source Trouble Tickets] -> [2. Appointment Staging] -> [3. Diagnostic Enrichment] -> [4. AI Model Inference] -> [5. Recommendation Storage] -> [6. Dispatcher Review Queue] -> [7. RLHF Feedback Capture]
164
+ ```
165
+ 2. **Entity Resolution & Customer Profile Systems (e.g., Customer Profile Service / Timeline Engine):**
166
+ - Must trace: Raw Telephony / CRM Staging -> Staging Swap Jobs -> Canonical Event Table (`dbo.CustomerTimelineEvent` / `EventDigest`) -> LLM Context Assembly (`dbo.CustomerLLMContext`) -> Standalone Inference Engine (Ollama / Local GPU) -> Summary Persistence -> Application UI.
167
+ 3. **Real-Time Telemetry & Probing Systems (e.g., Telemetry Monitor / Probe Service):**
168
+ ```
169
+ [1. Network Telemetry Probing] -> [2. Time-Series Raw DB] -> [3. Threshold Rule Engine] -> [4. Anomaly Prediction Model] -> [5. Incident Dispatch Queue] -> [6. Operator Acknowledgment]
170
+ ```
171
+ 4. **ELT Data Warehouses & Analytics Marts:**
172
+ ```
173
+ [1. Operational DB Replicas] -> [2. CDC Staging Tables] -> [3. Conformance & Cleaning Mart] -> [4. Dimensional & Fact Tables] -> [5. BI Reporting Views]
174
+ ```
175
+ 5. **Document & Audio AI Processing Systems:**
176
+ ```
177
+ [1. Multi-Channel Document Ingest] -> [2. Raw File Object Store] -> [3. OCR & Audio Transcription] -> [4. Entity & Feature Extraction] -> [5. LLM Synthesis Engine] -> [6. Verification UI] -> [7. Ground Truth Annotation Store]
178
+ ```
179
+
180
+ ---
181
+
182
+ ### 3.4 Standard Lineage Documentation Format (Section 4.5)
183
+
184
+ Section 4.5 of the High-Level Architecture must include:
185
+ 1. **Narrative Overview:** Explanation of the end-to-end data lifecycle from input inception to output consumption or model fine-tuning.
186
+ 2. **Horizontal Stacked Lineage Diagram (STRICT MAX 4 LAYERS):**
187
+ - Mermaid in `.md`, PlantUML in Confluence HTML, showing Host, DB, Table, and Execution context.
188
+ - **CRITICAL READABILITY CONSTRAINT:** Do NOT stack 7 or 8 vertical layers. Group stages into **at most 4 logical layers** (e.g., Layer 1: Upstream Ingestion & Raw Staging, Layer 2: Canonical Event Spine & Context Assembly, Layer 3: AI Inference & Persistence, Layer 4: Application Presentation Layer).
189
+ - In each layer, arrange components horizontally (`direction LR` in Mermaid, `-right->` in PlantUML).
190
+ - Connect layers with clean orthogonal, 90-degree lines.
191
+ 3. **Structured 7-Column Lineage Table:**
192
+ While the stage count and names adapt fluidly to the application, the table schema strictly maintains all 7 standard columns:
193
+
194
+ | Stage | Host Server | Database | Schema & Table / Entity | Population / Transformation Mechanism & Executing Host | Trigger / Schedule Cadence | Operational Payload & Downstream Consumer |
195
+ |---|---|---|---|---|---|---|
196
+ | **1. <Fluid Stage Name>** | Discovered host (`DB_HOST` or source) | Discovered DB / Catalog | Discovered tables or entities (`dbo.TABLE_NAME`) | Stored Procedure `dbo.usp_...` or ETL worker with executing host | Execution trigger (Continuous, Batch, Polling, Event) | Business data payload and the downstream consumer. |
197
+ | **2. <Fluid Stage Name>** | Discovered host | Discovered DB | Discovered staging table or queue | Ingestion worker or service with executing host | Polling interval or event stream | Staged records awaiting enrichment or transformation. |
198
+ | **3. <Fluid Stage Name>** | Processing host | Processing DB | Discovered feature table or dataset | Background worker, rule engine, or ETL script | Continuous polling loop or worker batch | Enriched attributes, normalized features, telemetry signals. |
199
+ | **4. <Fluid Stage Name>** | Inference host | Model Runtime | AI model or scoring service | Scoring engine or LLM service with executing host | Pipeline batch or on-demand event | Input prompts / features, outputs scores or recommendations. |
200
+ | **5. <Fluid Stage Name>** | Storage host | Output DB | Discovered results table or data mart | Persistence worker or database write | Post-processing transactional write | Final predictions, calculated indicators, alert records. |
201
+ | **6. <Fluid Stage Name>** | App Host / Browser | UI / App DB | User dashboard or operational queue | Web dashboard and backend REST API | User interaction or session lifecycle | Interactive record presentation, claim locks, advisory state. |
202
+ | **7. <Fluid Stage Name>** | Storage host | Target DB | Audit table, feedback store, or ground truth | Feedback API or audit worker with executing host | User action or system audit event | Operational decisions, override justifications, RLHF ground truth. |
203
+
204
+ > **Critical Rule:** Never copy AppointmentAssist stage names or tables into an HLA for another application. Inspect the application's actual tables, stored procedures, worker scripts, and `.env*` configurations to formulate domain-accurate stages.
205
+
206
+ ---
207
+
208
+ ### 3.5 Standalone Database Lineage Discovery Tool & CLI Switches
209
+
210
+ When you need to discover, map, or render the database lineage without executing a full HLA document generation cycle, use the dedicated lineage switches:
211
+
212
+ 1. **Automated Repository Lineage Discovery (`discover_db_lineage.py`):**
213
+ ```powershell
214
+ python scripts/discover_db_lineage.py --target-dir <path-to-repo> [--output <report.md>] [--format md|json]
215
+ ```
216
+ - Automatically parses `.env*` files in the target repository.
217
+ - Connects using `LinkedUser` or Windows Auth fallback.
218
+ - Queries `INFORMATION_SCHEMA`, `sys.procedures`, and `sys.servers`.
219
+ - Analyzes local codebase ORM models and background worker scripts.
220
+ - Outputs the standardized 7-column lineage table and Mermaid diagram.
221
+
222
+ 2. **Standalone Lineage Confluence Export (`--lineage-only` switch):**
223
+ ```powershell
224
+ python scripts/convert_hla_to_confluence.py <path-to-hla.md> --lineage-only [--output <lineage.html>]
225
+ ```
226
+ - Extracts only Section 4.5 from the HLA markdown file.
227
+ - Emits self-contained Confluence Storage Format XHTML with the horizontal stacked PlantUML diagram and wrapped 7-column table.
228
+ - Ideal for pasting solely the database pipeline architecture into team documentation.
229
+
230
+ ---
231
+
232
+ ## 4. PlantUML Diagram Standards & Material Design Palette
233
+
234
+ Confluence natively renders PlantUML without external image dependencies. Follow these styling and layout rules:
235
+
236
+ ### 4.1 Google Material Design Corporate Palette
237
+
238
+ Never use default bright or garish PlantUML colors. Use muted corporate Material tones:
239
+
240
+ | Layer / Role | Hex Stroke | Hex Fill | Hex Text | Skinparam Target |
241
+ |---|---|---|---|---|
242
+ | **Client / User Web Browser** | `#3949AB` | `#E8EAF6` | `#1A237E` | `skinparam rectangle<<user>>` / `skinparam actor` |
243
+ | **Web Server / Reverse Proxy** | `#455A64` | `#ECEFF1` | `#263238` | `skinparam rectangle<<proxy>>` |
244
+ | **App Services / Worker** | `#00695C` | `#E0F2F1` | `#004D40` | `skinparam rectangle<<service>>` |
245
+ | **API Gateway (Apigee)** | `#E65100` | `#FFF3E0` | `#BF360C` | `skinparam queue<<gateway>>` |
246
+ | **Databases / Staging Queues** | `#0277BD` | `#E1F5FE` | `#01579B` | `skinparam database<<db>>` |
247
+ | **External Core Telemetry APIs** | `#C2185B` | `#FCE4EC` | `#880E4F` | `skinparam rectangle<<telemetry>>` |
248
+ | **Artificial Intelligence / LLM** | `#6A1B9A` | `#F3E5F5` | `#4A148C` | `skinparam rectangle<<model>>` |
249
+ | **Feedback / RLHF Audit** | `#2E7D32` | `#E8F5E9` | `#1B5E20` | `skinparam database<<rlhf_db>>` |
250
+
251
+ ### 4.2 Layout Rules: 90-Degree Orthogonal Routing & Horizontal Stacked Layers
252
+
253
+ 1. **Mandate 90-Degree Orthogonal Connections (`skinparam linetype ortho`):**
254
+ - Always include `skinparam linetype ortho` in structural PlantUML diagrams (Topology, DB Lineage, Summarization Pipeline).
255
+ - Standard Graphviz splines create curved diagonal arcs that slice through package boundaries. Orthogonal routing forces clean Manhattan routing: all connections consist strictly of horizontal and vertical segments with 90° bends.
256
+ - Do NOT use `skinparam handwritten false` (triggers an unwanted yellow warning banner in modern PlantUML).
257
+
258
+ 2. **Horizontal Flow Stacked in Functional Layers (DB Lineage Pipeline):**
259
+ - Do NOT draw the DB Lineage pipeline as a single, tall vertical strip.
260
+ - Structure the pipeline as horizontal flows stacked in functional layers:
261
+ - **Layer 1 (Upstream Ingestion & Telemetry Enrichment):** `SourceDB` -> `PendingDB` -> `InputDB` connected via `-right->`.
262
+ - **Layer 2 (AI Summarization & Triage Inference):** `LLM` -> `RecDB` connected via `-right->`.
263
+ - **Layer 3 (Screener Review & Continuous Learning / RLHF):** `UI` -> `FeedbackDB` connected via `-right->`.
264
+ - Stack layers vertically using `L1 -[hidden]down- L2` and `L2 -[hidden]down- L3`.
265
+ - Connect inter-layer steps vertically: `InputDB -down-> LLM : 3. Case Prompts` and `RecDB -down-> UI : 5. Present to Queue`.
266
+ - Keep edge labels concise (`1. Extract`, `2. Ingest`, `4. Predict`, `6. Feedback`) with `skinparam nodesep 80` to prevent label collision with box borders.
267
+
268
+ 3. **Horizontal Flow with Stacked Multi-Track Inputs (Summarization Pipeline):**
269
+ - Do NOT draw summarization pipelines as single vertical columns.
270
+ - Structure as a 3-stage left-to-right pipeline:
271
+ - **Stage 1 (Left):** Multiple input tracks (e.g., Track A: Network Health, Track B: Case History, Track C: Account Profile) stacked vertically (`TrackA -[hidden]down- TrackB`), with each track flowing horizontally left-to-right (`N1 -right-> N2 -right-> NSum`).
272
+ - **Stage 2 (Middle):** Language Model Synthesis Engine (`LLMEngine`), receiving 90-degree orthogonal connections from each track's summary node (`NSum -right-> LLMEngine`, etc.).
273
+ - **Stage 3 (Right):** Action Recommendation & Justification (`RecOutput`), receiving a horizontal connection from `LLMEngine`.
274
+
275
+ 4. **Component-to-Component Connections in System Topology:**
276
+ - Connect internal component nodes directly (e.g., `Worker -down-> SQL`, `Worker -down-> Apigee`, `Worker -right-> LLM`).
277
+ - Do NOT connect package boundaries (e.g., `HostLayer -down-> MidLayer`), which inflates diagram bounding boxes and distorts routing.
278
+ - Use `skinparam nodesep 60` and `skinparam ranksep 50` for comfortable whitespace.
279
+
280
+ 5. **Diagram Parity: Mermaid in Markdown, PlantUML in Confluence:**
281
+ - Source `.md` documents MUST use standard Mermaid diagrams (`flowchart LR/TD`, `sequenceDiagram`) with subgraphs reflecting the horizontal/stacked layout so they render natively in Git repositories and Markdown viewers.
282
+ - The conversion tool (`convert_hla_to_confluence.py`) translates the diagrams into native Confluence PlantUML macros with orthogonal routing.
283
+
284
+ 6. **Mermaid Diagram Text Wrapping & Truncation Prevention in Markdown Documents:**
285
+ - **The Problem:** Standard Markdown viewers (GitHub, Azure DevOps, GitLab, VS Code, browsers) do NOT automatically wrap text inside Mermaid SVG elements (nodes, participant boxes, sequence notes, or message arrows). Long unwrapped strings stretch the SVG viewport to over 1500px, causing the diagram to truncate, hide labels off-screen, or force horizontal scrollbars.
286
+ - **The Rule:** In all Mermaid diagrams within `.md` documents, **always enforce explicit linebreaks using `<br/>`** to keep lines compact (maximum ~35 to 45 characters per line):
287
+ - **Sequence Participants & Actors:** Wrap role and system names across lines:
288
+ ```mermaid
289
+ actor Agent as Contact Center<br/>Agent
290
+ participant UI as React 19 UI<br/>(Port 5701)
291
+ database DB as SQL Server<br/>(IEGEW3CCDR01)
292
+ ```
293
+ - **Sequence Notes:** Wrap multi-line explanations:
294
+ ```mermaid
295
+ Note over DB: UiPath bot inbox loads Pega & ServiceNow<br/>reports into dbo.L30D* tables
296
+ ```
297
+ - **Sequence Message Labels:** Break long method descriptions, endpoints, or query details:
298
+ ```mermaid
299
+ ETL->>SF: Query Genesys calls & NPS<br/>via SNOWFLAKE_GENESYS (06:00 UTC)
300
+ ```
301
+ - **Flowchart Node Labels:** Structure host, database, tables, and jobs onto distinct lines:
302
+ ```mermaid
303
+ PegaStaging["Pega & ServiceNow via UiPath Inbox<br/>DB: SERVSIGHT<br/>dbo.L30DInteractions, Cases,<br/>dbo.L30DSNOW, Webforms<br/>[SQL Agent: Daily_AI_*_L30D]"]:::srcStyle
304
+ ```
305
+ - **Flowchart Edge Labels:** Wrap action descriptions to avoid wide gaps and node label collisions:
306
+ ```mermaid
307
+ LLMContext -->|"5. Poll Queue &<br/>Context (TDS 1433)"| AISummaryGen
308
+ ```
309
+ - **Converter Parity:** The Confluence converter (`convert_hla_to_confluence.py`) dynamically translates `<br/>` and `<br>` into `\n` in PlantUML sequence notes, messages, nodes, and edge labels, guaranteeing that both Markdown and Confluence XHTML display full, untruncated text with zero literal `<br/>` syntax errors.
310
+
311
+ 7. **Legacy PlantUML Engine Compatibility (Stereotypes After Aliases):**
312
+ - **The Problem:** Enterprise Confluence installations commonly run older PlantUML plugin versions (such as PlantUML 1.2022.1). In these versions, placing stereotypes immediately after element types (e.g. `rectangle<<user_ui>> "Label" as Alias`) triggers a fatal `Syntax Error?` on render.
313
+ - **The Rule:** In all generated PlantUML code, **always place the stereotype at the very end after the alias**:
314
+ ```plantuml
315
+ rectangle "Contact Center Agent Browser\n(Customer Care & Retention Teams)" as Browser <<user_ui>>
316
+ database "SQL Server Database (SERVSIGHT)\nEvent Spine & Context Store" as ServSightDB <<staging_db>>
317
+ queue "Linked Server Gateway\n(SNOWFLAKE_GENESYS / MSDASQL)" as LinkedServer <<gateway>>
318
+ ```
319
+ 8. **Anti-Slop and Em-Dash Prohibition in PlantUML and Text:**
320
+ - **Zero Em-Dashes (`—`) or En-Dashes (`–`):** Never include em-dashes in sequence diagram step descriptions, participant names, note boxes, flowchart nodes, or edge labels. Use colons (`:`) or hyphens (`-`).
321
+ - **Clean ASCII Strings:** Do not use unicode bullet points (`•`), curved apostrophes (`’`), or fancy quotation marks (`“”`). Use ASCII straight apostrophes and quotes.
322
+ - **No Markdown Wildcard Collisions:** Protect code identifiers containing asterisks (`*`) so they do not collide with italic formatting during export.
323
+
324
+ ---
325
+
326
+ ## 5. End-to-End Execution Workflow
327
+
328
+ ### Step 1: Research the Target Codebase
329
+ Inspect the target codebase across five dimensions:
330
+ 1. **User Interface:** Framework (React, Vue, Vite), authentication flow, role capabilities.
331
+ 2. **Backend Services & Gateways:** Endpoints, worker tasks, integration gateway (Apigee, reverse proxy, loopback ports).
332
+ 3. **Data & Pipeline Layer:** Discover the 7-stage DB pipeline (Source Host.DB.Table -> Staging -> Feature Input -> LLM -> Recommendations -> UI -> Feedback/RLHF). If unverified, ask the user.
333
+ 4. **Integration APIs:** Telemetry endpoints, external incident checkers, OAuth2 flows.
334
+ 5. **Security & Perimeter:** Authentication mechanism, RBAC groups, network boundaries, data minimization.
335
+
336
+ ### Step 2: Author Markdown HLA (`docs/hla/<slug>/<slug>-hla.md`)
337
+ - Write using the 7-section canonical structure in Simplified Technical English.
338
+ - Author PlantUML (or Mermaid) diagram blocks for:
339
+ 1. Sequence diagram
340
+ 2. System topology diagram
341
+ 3. Multi-track summarization pipeline
342
+ 4. End-to-end database and processing pipeline (Section 4.5)
343
+ - Document the Screener Feedback Service and RLHF loop (Section 4.6).
344
+ - Maintain internal working references under section 7.2.
345
+ - **Do NOT add any Document Notice or STE preamble.**
346
+ - **Strictly eliminate all em-dashes (`—`), en-dashes (`–`), smart quotes, and AI buzzwords.**
347
+
348
+ ### Step 3: Convert to Confluence XHTML (`docs/hla/<slug>/<slug>-hla.html`)
349
+ Run the bundled converter script:
350
+ ```powershell
351
+ python scripts/convert_hla_to_confluence.py docs/hla/<slug>/<slug>-hla.md
352
+ ```
353
+ Or execute the script from the skill directory:
354
+ ```powershell
355
+ python <path-to-skill>/scripts/convert_hla_to_confluence.py docs/hla/<slug>/<slug>-hla.md
356
+ ```
357
+
358
+ The converter automatically:
359
+ 1. Strips YAML frontmatter completely.
360
+ 2. Strips `7.2 Reference Documents` and any internal repository paths.
361
+ 3. Purges all preparation notices, STE statements, and AI/agent metadata.
362
+ 4. Escapes all XML entities (`&amp;`, `&lt;`, `&gt;`) inside table cells and text.
363
+ 5. Replaces Markdown TOC with native `<ac:structured-macro ac:name="toc"/>`.
364
+ 6. Wraps tables in `<table class="wrapped">` with explicit column specifications.
365
+ 7. Translates diagrams into self-contained PlantUML macros with Google Material Design corporate styling.
366
+ 8. Converts all em-dashes (`—`) and en-dashes (`–`) to colons (`:`) or hyphens (`-`).
367
+ 9. Normalizes smart quotes (`“”‘’`) and unicode bullets (`•`) to clean ASCII.
368
+ 10. Scrubs prohibited AI buzzwords, hyperbolic clichés, and meta-commentary.
369
+ 11. Validates XML well-formedness before saving.
370
+
371
+ ### Step 4: Verification and Confluence Import
372
+ 1. Verify terminal reports: `XHTML validation successful: Content is well-formed XML.`
373
+ 2. Copy the entire contents of the `.html` file.
374
+ 3. Open Confluence, create or edit the target architecture page, open the **Confluence Source Editor** (`< >` icon), paste the XHTML, and click **Apply**.
375
+ 4. The page immediately renders all tables and PlantUML diagrams natively—zero attachments or extra setup required.