gaia-framework 1.65.0 → 1.66.0

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 (92) hide show
  1. package/.claude/commands/gaia-add-feature.md +2 -2
  2. package/.claude/commands/gaia-change-request.md +16 -4
  3. package/.claude/commands/gaia-edit-ux.md +17 -0
  4. package/.claude/commands/gaia-resume.md +1 -1
  5. package/.claude/commands/gaia-validate-prd.md +9 -3
  6. package/CLAUDE.md +16 -1
  7. package/README.md +3 -3
  8. package/_gaia/_config/adversarial-triggers.yaml +91 -0
  9. package/_gaia/_config/files-manifest.csv +1 -0
  10. package/_gaia/_config/gaia-help.csv +10 -6
  11. package/_gaia/_config/global.yaml +2 -1
  12. package/_gaia/_config/lifecycle-sequence.yaml +26 -4
  13. package/_gaia/_config/manifest.yaml +3 -3
  14. package/_gaia/_config/skill-manifest.csv +3 -1
  15. package/_gaia/_config/workflow-manifest.csv +5 -3
  16. package/_gaia/core/config.yaml +1 -1
  17. package/_gaia/core/engine/workflow.xml +31 -5
  18. package/_gaia/core/protocols/review-gate-check.xml +29 -1
  19. package/_gaia/core/workflows/brainstorming/template.md +6 -0
  20. package/_gaia/lifecycle/agents/pm.md +9 -10
  21. package/_gaia/lifecycle/agents/ux-designer.md +1 -0
  22. package/_gaia/lifecycle/agents/validator.md +2 -1
  23. package/_gaia/lifecycle/config.yaml +1 -1
  24. package/_gaia/lifecycle/knowledge/brownfield/config-contradiction-scan.md +137 -0
  25. package/_gaia/lifecycle/knowledge/brownfield/dead-code-scan.md +179 -0
  26. package/_gaia/lifecycle/knowledge/brownfield/test-execution-scan.md +209 -0
  27. package/_gaia/lifecycle/module-help.csv +1 -1
  28. package/_gaia/lifecycle/skills/document-rulesets.md +251 -0
  29. package/_gaia/lifecycle/skills/memory-management-cross-agent.md +218 -0
  30. package/_gaia/lifecycle/skills/memory-management.md +32 -122
  31. package/_gaia/lifecycle/templates/brownfield-scan-doc-code-prompt.md +219 -0
  32. package/_gaia/lifecycle/templates/brownfield-scan-hardcoded-prompt.md +169 -0
  33. package/_gaia/lifecycle/templates/brownfield-scan-integration-seam-prompt.md +127 -0
  34. package/_gaia/lifecycle/templates/brownfield-scan-runtime-behavior-prompt.md +141 -0
  35. package/_gaia/lifecycle/templates/brownfield-scan-security-prompt.md +212 -0
  36. package/_gaia/lifecycle/templates/gap-entry-schema.md +247 -0
  37. package/_gaia/lifecycle/templates/infra-prd-template.md +356 -0
  38. package/_gaia/lifecycle/templates/platform-prd-template.md +431 -0
  39. package/_gaia/lifecycle/templates/prd-template.md +70 -0
  40. package/_gaia/lifecycle/templates/story-template.md +1 -0
  41. package/_gaia/lifecycle/workflows/1-analysis/create-product-brief/workflow.yaml +1 -0
  42. package/_gaia/lifecycle/workflows/2-planning/create-prd/instructions.xml +4 -2
  43. package/_gaia/lifecycle/workflows/2-planning/create-prd/workflow.yaml +1 -0
  44. package/_gaia/lifecycle/workflows/2-planning/create-ux-design/workflow.yaml +1 -0
  45. package/_gaia/lifecycle/workflows/2-planning/edit-prd/instructions.xml +4 -4
  46. package/_gaia/lifecycle/workflows/2-planning/edit-prd/workflow.yaml +1 -0
  47. package/_gaia/lifecycle/workflows/2-planning/edit-ux-design/checklist.md +18 -0
  48. package/_gaia/lifecycle/workflows/2-planning/edit-ux-design/instructions.xml +66 -0
  49. package/_gaia/lifecycle/workflows/2-planning/edit-ux-design/workflow.yaml +27 -0
  50. package/_gaia/lifecycle/workflows/3-solutioning/create-architecture/instructions.xml +3 -1
  51. package/_gaia/lifecycle/workflows/3-solutioning/create-architecture/workflow.yaml +1 -0
  52. package/_gaia/lifecycle/workflows/3-solutioning/create-epics-stories/workflow.yaml +1 -0
  53. package/_gaia/lifecycle/workflows/3-solutioning/edit-architecture/instructions.xml +4 -7
  54. package/_gaia/lifecycle/workflows/3-solutioning/edit-architecture/workflow.yaml +1 -0
  55. package/_gaia/lifecycle/workflows/3-solutioning/security-threat-model/workflow.yaml +1 -0
  56. package/_gaia/lifecycle/workflows/4-implementation/add-feature/checklist.md +42 -0
  57. package/_gaia/lifecycle/workflows/4-implementation/add-feature/instructions.xml +196 -0
  58. package/_gaia/lifecycle/workflows/{cross-phase → 4-implementation}/add-feature/workflow.yaml +20 -9
  59. package/_gaia/lifecycle/workflows/4-implementation/add-stories/checklist.md +5 -0
  60. package/_gaia/lifecycle/workflows/4-implementation/add-stories/instructions.xml +73 -1
  61. package/_gaia/lifecycle/workflows/4-implementation/add-stories/workflow.yaml +1 -0
  62. package/_gaia/lifecycle/workflows/4-implementation/code-review/workflow.yaml +1 -0
  63. package/_gaia/lifecycle/workflows/4-implementation/correct-course/workflow.yaml +1 -0
  64. package/_gaia/lifecycle/workflows/4-implementation/create-story/checklist.md +1 -1
  65. package/_gaia/lifecycle/workflows/4-implementation/create-story/instructions.xml +5 -4
  66. package/_gaia/lifecycle/workflows/4-implementation/dev-story/workflow.yaml +1 -1
  67. package/_gaia/lifecycle/workflows/4-implementation/retrospective/instructions.xml +21 -1
  68. package/_gaia/lifecycle/workflows/4-implementation/retrospective/workflow.yaml +2 -1
  69. package/_gaia/lifecycle/workflows/4-implementation/sprint-planning/instructions.xml +3 -0
  70. package/_gaia/lifecycle/workflows/4-implementation/sprint-planning/workflow.yaml +2 -0
  71. package/_gaia/lifecycle/workflows/4-implementation/triage-findings/workflow.yaml +1 -0
  72. package/_gaia/lifecycle/workflows/4-implementation/val-refresh-ground-truth/checklist.md +15 -0
  73. package/_gaia/lifecycle/workflows/4-implementation/val-refresh-ground-truth/instructions.xml +153 -57
  74. package/_gaia/lifecycle/workflows/4-implementation/val-refresh-ground-truth/workflow.yaml +5 -0
  75. package/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/instructions.xml +23 -12
  76. package/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/workflow.yaml +11 -0
  77. package/_gaia/lifecycle/workflows/4-implementation/val-validate-plan/instructions.xml +0 -2
  78. package/_gaia/lifecycle/workflows/5-deployment/deployment-checklist/workflow.yaml +1 -0
  79. package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/checklist.md +12 -0
  80. package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/instructions.xml +313 -5
  81. package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/workflow.yaml +1 -0
  82. package/_gaia/lifecycle/workflows/anytime/memory-hygiene/instructions.xml +8 -18
  83. package/_gaia/testing/config.yaml +1 -1
  84. package/_gaia/testing/workflows/edit-test-plan/workflow.yaml +1 -0
  85. package/_gaia/testing/workflows/test-design/workflow.yaml +2 -0
  86. package/_gaia/testing/workflows/traceability/workflow.yaml +1 -0
  87. package/bin/gaia-framework.js +25 -9
  88. package/bin/generate-checksums.js +124 -0
  89. package/gaia-install.sh +74 -28
  90. package/package.json +5 -2
  91. package/_gaia/lifecycle/workflows/cross-phase/add-feature/checklist.md +0 -30
  92. package/_gaia/lifecycle/workflows/cross-phase/add-feature/instructions.xml +0 -85
@@ -0,0 +1,219 @@
1
+ # Documentation-Code Mismatch Scanner — Subagent Prompt
2
+
3
+ > Brownfield deep analysis scan subagent for detecting documentation-code drift: stale docs, undocumented features, version mismatches, and config option drift.
4
+ > Reference: Architecture ADR-021, Section 10.15.2, 10.15.3, 10.15.5
5
+
6
+ ## Subagent Invocation
7
+
8
+ **Input variables:**
9
+ - `{tech_stack}` — Detected technology stack from Step 1 discovery (e.g., "Java/Spring", "Node/Express", "Python/Django", "Go/Gin")
10
+ - `{project-path}` — Absolute path to the project source code directory
11
+
12
+ **Output file:** `{planning_artifacts}/brownfield-scan-doc-code.md`
13
+
14
+ **Invocation model:** Spawned via Agent tool in a single message alongside the other deep analysis scan subagents (parallel execution per architecture 10.15.2).
15
+
16
+ ## Subagent Prompt
17
+
18
+ ```
19
+ You are a Documentation-Code Mismatch Scanner for brownfield project analysis. Your task is to verify documentation claims against the actual codebase — detecting stale documentation, undocumented features, version mismatches, and configuration option drift — then produce gap entries using the standardized gap schema.
20
+
21
+ ### Inputs
22
+ - Tech stack: {tech_stack}
23
+ - Project path: {project-path}
24
+ - Gap schema reference: Read _gaia/lifecycle/templates/gap-entry-schema.md for the output format
25
+
26
+ ### Phase 1: Documentation File Discovery
27
+
28
+ Scan the project for all discoverable documentation files. Apply both generic and stack-specific discovery patterns.
29
+
30
+ **Generic documentation files (all stacks):**
31
+
32
+ | File/Pattern | Location | Description |
33
+ |-------------|----------|-------------|
34
+ | `README.md` | Project root | Primary project documentation |
35
+ | `CONTRIBUTING.md` | Project root | Contributor guidelines |
36
+ | `CHANGELOG.md` | Project root | Version history |
37
+ | `docs/` directory | Project root | Dedicated documentation directory |
38
+ | `*.md` in project root | Project root | Any markdown files at top level |
39
+ | `openapi.yaml`, `openapi.json` | Project root, `api/` | OpenAPI 3.x specification |
40
+ | `swagger.yaml`, `swagger.json` | Project root, `api/` | Swagger 2.x specification |
41
+
42
+ **Stack-Aware Documentation Patterns:**
43
+
44
+ #### Java/Spring
45
+
46
+ | File/Pattern | Location | Description |
47
+ |-------------|----------|-------------|
48
+ | Javadoc comments (`/** ... */`) | Source files | Inline API documentation and docstrings |
49
+ | `application.yml` / `application.properties` comments | `src/main/resources/` | Configuration documentation |
50
+ | `pom.xml` `<description>` elements | Project root | Maven project metadata |
51
+ | Spring REST Docs output | `build/generated-snippets/`, `target/generated-snippets/` | Auto-generated API documentation |
52
+ | `src/main/resources/static/docs/` | Resources | Bundled documentation |
53
+
54
+ #### Node/Express
55
+
56
+ | File/Pattern | Location | Description |
57
+ |-------------|----------|-------------|
58
+ | JSDoc comments (`/** ... */`) | Source files | Inline API documentation and docstrings |
59
+ | `package.json` `description`, `scripts` | Project root | Package metadata and available commands |
60
+ | `typedoc.json` or JSDoc config | Project root | Documentation generator config |
61
+ | `.env.example` | Project root | Documented environment variables |
62
+ | `docs/api/` | Documentation dir | API documentation files |
63
+
64
+ #### Python/Django
65
+
66
+ | File/Pattern | Location | Description |
67
+ |-------------|----------|-------------|
68
+ | Docstrings (`"""..."""`) | Source files | Inline documentation and docstrings |
69
+ | `pyproject.toml` `[project]` section | Project root | Package metadata |
70
+ | `requirements.txt` | Project root | Dependency documentation |
71
+ | Sphinx `conf.py` | `docs/` | Documentation generator config |
72
+ | Django `urls.py` docstrings | App directories | Route-level documentation |
73
+ | `setup.py` / `setup.cfg` metadata | Project root | Legacy package metadata |
74
+
75
+ #### Go/Gin
76
+
77
+ | File/Pattern | Location | Description |
78
+ |-------------|----------|-------------|
79
+ | Go doc comments (`// Package ...`) | Source files | Package-level documentation and docstrings |
80
+ | `go.mod` module declaration | Project root | Module metadata |
81
+ | `Makefile` targets and comments | Project root | Build command documentation |
82
+ | `cmd/` directory README files | `cmd/` subdirs | CLI command documentation |
83
+ | `internal/` package docs | `internal/` | Internal package documentation |
84
+
85
+ **Edge Case: Empty/Stub Documentation**
86
+ Skip documentation files with fewer than 2 non-empty lines after the header (title line). These are stub files that provide no actionable claims to verify. Do not generate false-positive gap entries for empty or stub documentation files.
87
+
88
+ **Edge Case: Non-UTF-8 Encoding**
89
+ Attempt to read each documentation file as UTF-8. If a decode error occurs, log a warning ("Skipping {file}: non-UTF-8 encoding detected") and skip the file gracefully without crashing. Do not generate gap entries for files that cannot be decoded.
90
+
91
+ ### Phase 2: Claim Extraction
92
+
93
+ For each discovered documentation file, extract verifiable claims organized by type:
94
+
95
+ **Claim Type 1: Endpoint Claims**
96
+ Extract documented API endpoints — method, path, description. Sources: README API sections, OpenAPI/Swagger specs, inline JSDoc/docstring route annotations.
97
+
98
+ **Claim Type 2: Configuration Option Claims**
99
+ Extract documented configuration options — environment variables, config keys, default values. Sources: README configuration sections, `.env.example` files, config documentation.
100
+
101
+ **Claim Type 3: Dependency Claims**
102
+ Extract documented dependencies — package names, version constraints, runtime requirements. Sources: README prerequisites/installation sections, documented system requirements.
103
+
104
+ **Claim Type 4: Build/Run Command Claims**
105
+ Extract documented build, test, and run commands — script names, CLI invocations, make targets. Sources: README getting started sections, CONTRIBUTING.md, Makefile documentation.
106
+
107
+ ### Phase 3: Code Verification
108
+
109
+ For each extracted claim, verify it against the actual codebase:
110
+
111
+ **Endpoint Verification:**
112
+ - Grep for route definitions matching documented paths (e.g., `app.get('/api/v1/users')`, `@GetMapping("/api/v1/users")`, `path('api/v1/users/')`, `router.GET("/api/v1/users")`)
113
+ - Match HTTP method + path pattern
114
+ - Flag documented endpoints not found in code as stale documentation
115
+ - Flag route definitions not found in documentation as undocumented features that are not documented
116
+
117
+ **Configuration Option Verification:**
118
+ - Grep for documented config key usage in source files (e.g., `process.env.MAX_RETRIES`, `@Value("${max.retries}")`, `os.environ.get('MAX_RETRIES')`, `os.Getenv("MAX_RETRIES")`)
119
+ - Check if documented defaults match actual defaults in code
120
+ - Flag documented config options not referenced anywhere in source as stale documentation
121
+
122
+ **Dependency Verification:**
123
+ - Compare documented dependencies against entries in package manifests: `package.json`, `pom.xml`, `go.mod`, `requirements.txt`, `pyproject.toml`
124
+ - Check version constraints: if README says "requires Node 16" but `engines` field says `>=20`, flag as version mismatch
125
+ - Flag documented dependencies not in manifests as stale documentation
126
+ - Flag manifest dependencies not mentioned in docs as missing documentation (low severity)
127
+
128
+ **Build Command Verification:**
129
+ - Verify documented build/run commands exist: check `scripts` in `package.json`, `Makefile` targets, `Dockerfile` commands, management commands in Django
130
+ - Flag documented commands that do not exist as stale documentation
131
+ - Flag undocumented scripts/targets as missing documentation (low severity)
132
+
133
+ ### Phase 4: OpenAPI/Swagger Auto-Generated Spec Detection
134
+
135
+ When an OpenAPI or Swagger spec file is found, determine whether it is auto-generated or hand-written:
136
+
137
+ **Auto-generated spec indicators:**
138
+ - `x-generator` field in spec root (e.g., `x-generator: swagger-codegen`)
139
+ - `info.x-generated-by` field in spec info section
140
+ - Known generator tool signatures in comments or metadata: `swagger-codegen`, `openapi-generator`, `tsoa`, `springdoc-openapi`, `drf-spectacular`, `swag` (Go)
141
+ - Presence of `@Generated` or similar annotations in companion files
142
+
143
+ **Treatment of auto-generated specs:**
144
+ - Flag auto-generated specs with lower confidence findings (INFO severity instead of WARNING/MEDIUM)
145
+ - Add a note in the gap entry description: "Source is auto-generated spec — lower confidence for drift detection"
146
+ - Still verify claims from auto-generated specs, but do not treat mismatches as high severity since the spec may be stale due to regeneration lag rather than intentional drift
147
+
148
+ ### Phase 5: Mismatch Detection and Classification
149
+
150
+ Classify each verified claim into one of three categories:
151
+
152
+ **Category A: Stale Documentation (documented but not in code)**
153
+ Features, endpoints, config options, or commands that appear in documentation but no longer exist in the codebase. These represent documentation that was not updated when code changed.
154
+ - **Default severity: medium**
155
+
156
+ **Category B: Missing Documentation (in code but not documented)**
157
+ Features, endpoints, config options, or commands that exist in the codebase but are not mentioned in any documentation file. These represent undocumented functionality.
158
+ - **Default severity: low** (unless the undocumented item is a public API endpoint, then medium)
159
+
160
+ **Category C: Version Mismatches**
161
+ Version numbers, runtime requirements, or dependency constraints in documentation that conflict with actual values in package files or code.
162
+ - **Default severity: medium**
163
+
164
+ ### Phase 6: Gap Entry Generation
165
+
166
+ For each mismatch, produce a gap entry following the standardized gap schema:
167
+
168
+ - **id:** `GAP-DOC-CODE-{seq}` where seq is zero-padded 3-digit (e.g., GAP-DOC-CODE-001, GAP-DOC-CODE-002)
169
+ - **category:** `doc-code-drift`
170
+ - **severity:** See severity mapping in Phase 5 (default medium for stale docs and version mismatches, low for missing docs, INFO for auto-generated spec findings)
171
+ - **title:** Short summary (max 80 characters)
172
+ - **description:** Include the claim type, source documentation file, and what specifically mismatches
173
+ - **evidence:** `file` (relative path to the documentation or code file) and `line` (line number or range)
174
+ - **recommendation:** Actionable guidance — update docs, remove stale references, add missing documentation
175
+ - **verified_by:** `machine-detected`
176
+ - **confidence:** `high` (exact match/mismatch confirmed), `medium` (partial match, needs human review), `low` (heuristic detection, may be false positive)
177
+
178
+ ### Token Budget Compliance (NFR-024)
179
+
180
+ Each gap entry must average approximately 100 tokens in structured YAML format:
181
+ - Use structured YAML, not prose paragraphs
182
+ - Keep `title` under 80 characters
183
+ - Keep `description` to 1-2 sentences
184
+ - Keep `recommendation` to 1-2 sentences
185
+ - Reference source via `evidence` instead of embedding code snippets
186
+
187
+ **Maximum:** 70 gap entries per scan output file.
188
+
189
+ **Truncation logic:** If total gap entries exceed 70, retain highest-severity entries first (critical > high > medium > low > info). Truncate the lowest-severity entries. Append a summary at the end of the output file:
190
+ "Truncated {N} entries of severity {severity} — {total} total doc-code mismatches found, {kept} entries retained."
191
+
192
+ ### Output Format
193
+
194
+ Write all gap entries to `{planning_artifacts}/brownfield-scan-doc-code.md` using this format:
195
+
196
+ ```markdown
197
+ # Brownfield Scan: Documentation-Code Mismatch Analysis
198
+
199
+ > Generated by: Documentation-Code Mismatch Scanner
200
+ > Tech stack: {tech_stack}
201
+ > Date: {date}
202
+ > Total findings: {count}
203
+
204
+ ## Gap Entries
205
+
206
+ \`\`\`yaml
207
+ - id: "GAP-DOC-CODE-001"
208
+ category: "doc-code-drift"
209
+ severity: "medium"
210
+ title: "README documents /api/v1/legacy endpoint that does not exist"
211
+ description: "README.md references endpoint GET /api/v1/legacy but no matching route definition found in codebase. Stale documentation."
212
+ evidence:
213
+ file: "README.md"
214
+ line: 47
215
+ recommendation: "Remove /api/v1/legacy reference from README.md or restore the endpoint if removal was unintentional."
216
+ verified_by: "machine-detected"
217
+ confidence: "high"
218
+ \`\`\`
219
+ ```
@@ -0,0 +1,169 @@
1
+ # Hard-Coded Business Logic Scanner — Subagent Prompt
2
+
3
+ > Brownfield deep analysis scan subagent. Detects hard-coded business logic values that should be externalized to configuration.
4
+ > Reference: Architecture ADR-021, Section 10.15.2, Section 10.15.5, ADR-022 §10.16.5
5
+ > Infra-awareness: E12-S6 — applies infra-specific patterns when project_type is infrastructure or platform.
6
+
7
+ ## Objective
8
+
9
+ Scan the codebase at `{project-path}` to identify hard-coded business logic values embedded in source code. These are values that represent business rules, configuration, or environment-specific settings and should be externalized to configuration files, environment variables, or feature flags.
10
+
11
+ **Input variables:**
12
+ - `{tech_stack}` — Detected technology stack from Step 1 discovery
13
+ - `{project-path}` — Absolute path to the project source code directory
14
+ - `{project_type}` — Project type: `application`, `infrastructure`, or `platform`
15
+
16
+ **Output format:** Follow the gap entry schema at `{project-root}/_gaia/lifecycle/templates/gap-entry-schema.md` exactly.
17
+
18
+ ## Detection Categories — Application Patterns
19
+
20
+ Scan for the following 6 categories of hard-coded values:
21
+
22
+ ### 1. Magic Numbers in Business Calculations
23
+
24
+ Values used in business logic that represent thresholds, limits, rates, or quantities.
25
+
26
+ **Flag these:**
27
+ - Numeric thresholds in business conditions: `if (amount > 10000)`
28
+ - Hard-coded retry counts in business logic: `maxRetries = 3`
29
+ - Hard-coded pagination limits: `const PAGE_SIZE = 50`
30
+ - Timeout values embedded in business logic: `setTimeout(callback, 30000)`
31
+
32
+ ### 2. Hard-coded URLs and Endpoints
33
+
34
+ URLs, API endpoints, and service addresses embedded directly in source code.
35
+
36
+ **Flag these:**
37
+ - Production/staging URLs: `fetch("https://api.prod.example.com/v2")`
38
+ - Hard-coded service endpoints: `const API_BASE = "https://internal.service.com"`
39
+ - Database connection strings with hostnames: `mongodb://prod-db:27017`
40
+
41
+ ### 3. Embedded SQL Queries with Business Rules
42
+
43
+ SQL queries containing hard-coded business logic values.
44
+
45
+ **Flag these:**
46
+ - Hard-coded role/status values in WHERE clauses
47
+ - Business tier filtering with literal strings
48
+ - Hard-coded date boundaries
49
+
50
+ ### 4. Date/Time Thresholds
51
+
52
+ Hard-coded dates, times, or durations that represent business policy.
53
+
54
+ ### 5. Pricing and Rate Values
55
+
56
+ Monetary values, percentages, rates, or financial thresholds embedded in code.
57
+
58
+ ### 6. Role and Permission Strings
59
+
60
+ Hard-coded role names, permission identifiers, or authorization strings.
61
+
62
+ ## Detection Categories — Infrastructure Patterns (E12-S6)
63
+
64
+ **Apply ONLY when {project_type} is `infrastructure` or `platform`.**
65
+
66
+ ### 7. Hard-Coded IP Addresses in Infrastructure Files
67
+
68
+ Detect IP addresses embedded directly in IaC, Kubernetes manifests, and network configuration.
69
+
70
+ **Flag these:**
71
+ - IPv4 addresses in Terraform configs: `cidr_block = "10.0.1.0/24"` with specific IPs (not CIDR ranges for subnets)
72
+ - Hard-coded IPs in Kubernetes Services or Endpoints: `clusterIP: "10.96.0.10"`
73
+ - Static IPs in Helm values: `loadBalancerIP: "203.0.113.50"`
74
+ - Hard-coded DNS entries: `server = "10.0.0.53"` instead of using service discovery
75
+ - IPs in security group rules: `cidr_blocks = ["203.0.113.0/32"]`
76
+
77
+ **Do NOT flag:**
78
+ - Standard CIDR ranges for VPC/subnet definitions: `10.0.0.0/16`, `172.16.0.0/12`
79
+ - Loopback addresses: `127.0.0.1`, `0.0.0.0`
80
+ - Kubernetes internal DNS: `kube-dns`, `coredns`
81
+
82
+ **Gap category:** `hard-coded-logic` with infra context in description
83
+
84
+ ### 8. Magic Port Numbers in Infrastructure
85
+
86
+ Detect non-standard or undocumented port numbers in infrastructure configuration.
87
+
88
+ **Flag these:**
89
+ - Non-standard port numbers without documentation: `containerPort: 8443`, `hostPort: 9999`
90
+ - Port numbers that differ between service and deployment: `port: 80` in Service but `containerPort: 8080` in Pod
91
+ - Hard-coded port ranges in security groups: `from_port = 30000, to_port = 32767`
92
+ - Port numbers in environment variables with literal values: `PORT=3001`
93
+
94
+ **Do NOT flag:**
95
+ - Well-known ports with standard usage: 80 (HTTP), 443 (HTTPS), 22 (SSH), 5432 (PostgreSQL), 3306 (MySQL), 6379 (Redis), 27017 (MongoDB)
96
+ - Ports defined in variables/config and referenced: `var.app_port`
97
+
98
+ **Gap category:** `hard-coded-logic` with infra context in description
99
+
100
+ ### 9. Embedded Secrets and Credential Patterns
101
+
102
+ Detect secrets, credentials, AMI IDs, and sensitive values embedded in IaC or config files.
103
+
104
+ **Flag these (critical severity):**
105
+ - AWS access keys: patterns matching `AKIA[0-9A-Z]{16}` in any file
106
+ - AWS secret keys: base64-like strings assigned to `secret_key` or `aws_secret_access_key`
107
+ - API tokens in config: `token = "ghp_..."`, `api_key = "sk-..."`
108
+ - Database passwords in plaintext: `password = "mysecretpassword"` in tfvars or values.yaml
109
+ - SSH private keys embedded in configs or user-data scripts
110
+
111
+ **Flag these (high severity):**
112
+ - AMI IDs hard-coded: `ami = "ami-0abcdef1234567890"` — should use data source or variable
113
+ - Docker image tags with specific SHA: `image: myapp@sha256:abc123` when not pinned intentionally
114
+ - Hard-coded AWS account IDs: `account_id = "123456789012"`
115
+ - Hard-coded region strings: `region = "us-east-1"` without variable reference
116
+
117
+ **Gap category:** `hard-coded-logic` (or escalate to `secret-exposure` for actual credentials)
118
+
119
+ ### 10. Hard-Coded Resource Limits in Infrastructure
120
+
121
+ Detect hard-coded CPU and memory limits in Kubernetes manifests, Terraform configs, and Docker files.
122
+
123
+ **Flag these:**
124
+ - Kubernetes resource requests/limits with literal values:
125
+ ```yaml
126
+ resources:
127
+ requests:
128
+ cpu: "500m"
129
+ memory: "512Mi"
130
+ limits:
131
+ cpu: "1000m"
132
+ memory: "1Gi"
133
+ ```
134
+ These should reference Helm values or kustomize patches for environment-specific tuning.
135
+ - Terraform instance types hard-coded: `instance_type = "t3.medium"` — should be a variable
136
+ - Docker memory limits: `--memory="2g"` in compose files without variable reference
137
+ - Auto-scaling thresholds: `min_size = 2, max_size = 10` without variables
138
+ - EBS volume sizes: `size = 100` without variable reference
139
+
140
+ **Do NOT flag:**
141
+ - Resource values defined in Helm values.yaml (already externalized)
142
+ - Resource values in Terraform variables (already parameterized)
143
+ - Default values in variable blocks with clear documentation
144
+
145
+ **Gap category:** `hard-coded-logic` with infra context in description
146
+
147
+ ## Acceptable Constant Allowlist
148
+
149
+ Do NOT flag: HTTP status codes, math constants, array indices, standard library constants, test fixture data.
150
+
151
+ ## Stack-Aware Detection Patterns
152
+
153
+ Apply framework-specific patterns based on {tech_stack} (Java/Spring, Node/Express, Python/Django, Go/Gin) as documented in the original E11-S4 specification.
154
+
155
+ ## False Positive Suppression Rules
156
+
157
+ - Configuration files (.yml, .yaml, .properties, .env) are externalized — do not flag
158
+ - Test files contain legitimate test fixtures — skip
159
+ - Framework-specific externalization patterns (Spring @Value, process.env, Django settings) — do not flag
160
+
161
+ ## Output Format
162
+
163
+ Gap entry structure uses `category: "hard-coded-logic"` with `id: "GAP-HARDCODED-{seq}"`.
164
+ For infra-specific findings, include "[INFRA]" prefix in the title for clarity.
165
+ Budget: max 70 entries, truncate low-severity if exceeded.
166
+
167
+ ## Output File
168
+
169
+ Write all findings to: `{planning_artifacts}/brownfield-scan-hardcoded.md`
@@ -0,0 +1,127 @@
1
+ # Integration Seam Analyzer — Subagent Prompt
2
+
3
+ > Brownfield deep analysis scan subagent. Traces data flows across service boundaries and detects fragile integration points.
4
+ > Reference: Architecture ADR-021, Section 10.15.2, Section 10.15.5, ADR-022 §10.16.5
5
+ > Infra-awareness: E12-S6 — applies infra-specific patterns when project_type is infrastructure or platform.
6
+
7
+ ## Objective
8
+
9
+ Scan the codebase at `{project-path}` to trace data flows across service boundaries, detect fragile integration points, tight coupling, and missing contracts. For infrastructure projects, additionally map service mesh topology, ingress/egress routes, and cross-namespace dependencies.
10
+
11
+ **Input variables:**
12
+ - `{tech_stack}` — Detected technology stack from Step 1 discovery
13
+ - `{project-path}` — Absolute path to the project source code directory
14
+ - `{project_type}` — Project type: `application`, `infrastructure`, or `platform`
15
+
16
+ **Output format:** Follow the gap entry schema at `{project-root}/_gaia/lifecycle/templates/gap-entry-schema.md` exactly.
17
+
18
+ ## Detection Categories — Application Patterns
19
+
20
+ ### 1. HTTP Client Calls (Service-to-Service)
21
+
22
+ Detect outbound HTTP/REST calls:
23
+ - **Java/Spring:** Feign clients, RestTemplate, WebClient, HttpClient
24
+ - **Node/Express:** axios, fetch, got, node-fetch, superagent
25
+ - **Python/Django:** requests, httpx, urllib3, aiohttp
26
+ - **Go:** net/http.Client, resty, go-retryablehttp
27
+
28
+ ### 2. Message Queue Integration
29
+
30
+ Detect message queue producers/consumers:
31
+ - Bull, BullMQ, RabbitMQ (amqplib), Kafka (kafkajs, confluent-kafka), Celery, SQS, NATS
32
+
33
+ ### 3. Database Shared Access
34
+
35
+ Detect multiple services or modules accessing the same database tables.
36
+
37
+ ### 4. Coupling Classification
38
+
39
+ Classify coupling issues:
40
+ - Tightly coupled: shared DB tables, direct internal API calls
41
+ - Missing circuit breaker or retry logic
42
+ - Undocumented external service dependencies
43
+ - Inconsistent serialization formats
44
+
45
+ ### 5. Dependency Graph
46
+
47
+ Generate adjacency list showing service-to-service relationships with connection type and direction.
48
+
49
+ ## Detection Categories — Infrastructure Patterns (E12-S6)
50
+
51
+ **Apply ONLY when {project_type} is `infrastructure` or `platform`.**
52
+
53
+ ### 6. Service Mesh Topology Mapping
54
+
55
+ Detect and map service mesh configurations and their routing rules.
56
+
57
+ **Scan for:**
58
+ - **Istio:** VirtualService, DestinationRule, Gateway, ServiceEntry, PeerAuthentication
59
+ - `kind: VirtualService` — extract routing rules, traffic splitting percentages, timeout configs
60
+ - `kind: DestinationRule` — extract load balancing policies, circuit breaker settings, TLS modes
61
+ - `kind: Gateway` — extract ingress listeners, TLS configuration, host matching
62
+ - `kind: ServiceEntry` — extract external service registrations
63
+ - `kind: PeerAuthentication` — extract mTLS modes (STRICT, PERMISSIVE, DISABLE)
64
+ - **Linkerd:** ServiceProfile, TrafficSplit, Server, ServerAuthorization
65
+ - **Consul Connect:** ServiceIntention, ServiceRouter, ServiceSplitter, ServiceResolver
66
+
67
+ **Flag these as gaps:**
68
+ - VirtualService without timeout configuration (unbounded request duration)
69
+ - DestinationRule without circuit breaker settings (no fault isolation)
70
+ - PeerAuthentication in PERMISSIVE mode in production (allows plaintext traffic)
71
+ - ServiceEntry for external services without failover configuration
72
+ - Traffic splitting percentages that do not sum to 100%
73
+ - Missing retryOn policies for transient failure codes (5xx, connect-failure)
74
+
75
+ **Severity:** `high` for missing circuit breakers and timeouts, `medium` for permissive mTLS
76
+
77
+ ### 7. Ingress/Egress Route Mapping
78
+
79
+ Map all ingress and egress routes to understand traffic flow in and out of the cluster.
80
+
81
+ **Scan for:**
82
+ - Kubernetes Ingress resources: hosts, paths, backend services, TLS config
83
+ - Istio Gateway + VirtualService pairs: external entry points into the mesh
84
+ - AWS ALB Ingress Controller annotations: `alb.ingress.kubernetes.io/*`
85
+ - Nginx Ingress Controller annotations: `nginx.ingress.kubernetes.io/*`
86
+ - Egress rules: NetworkPolicy egress, Istio ServiceEntry for external services, Calico GlobalNetworkPolicy
87
+ - NAT Gateway / Internet Gateway configurations in Terraform
88
+
89
+ **Flag these as gaps:**
90
+ - Ingress routes without TLS/HTTPS enforcement
91
+ - Ingress to services that are also exposed via NodePort (dual exposure)
92
+ - Missing egress restrictions (all outbound traffic allowed by default)
93
+ - External service dependencies without explicit ServiceEntry or egress policy
94
+ - Ingress paths that bypass the service mesh (direct NodePort access)
95
+
96
+ **Severity:** `high` for missing TLS and unrestricted egress, `medium` for dual exposure
97
+
98
+ ### 8. Cross-Namespace Dependency Detection
99
+
100
+ Detect service dependencies that span Kubernetes namespaces.
101
+
102
+ **Scan for:**
103
+ - Service references using FQDN: `{service}.{namespace}.svc.cluster.local`
104
+ - ExternalName services pointing to other namespaces
105
+ - NetworkPolicy rules referencing `namespaceSelector`
106
+ - Istio VirtualService/DestinationRule targeting services in other namespaces
107
+ - ConfigMap or Secret references from other namespaces (via volume mounts or env)
108
+ - ServiceAccount tokens shared across namespaces
109
+
110
+ **Flag these as gaps:**
111
+ - Cross-namespace service calls without NetworkPolicy allowing the traffic
112
+ - Cross-namespace dependencies without documented ownership or SLA
113
+ - Hardcoded namespace names in service URLs (fragile to namespace renaming)
114
+ - Cross-namespace secret sharing without RBAC scoping
115
+ - Circular cross-namespace dependencies (A -> B -> A)
116
+
117
+ **Severity:** `high` for undocumented cross-namespace dependencies, `medium` for hardcoded namespaces
118
+
119
+ ## Output Format
120
+
121
+ Gap entry structure uses `category: "integration-seam"` with `id: "GAP-INTEGRATION-{seq}"`.
122
+ For infra-specific findings, include "[INFRA]" prefix in the title for clarity.
123
+ Budget: max 70 entries, truncate low-severity if exceeded.
124
+
125
+ ## Output File
126
+
127
+ Write all findings to: `{planning_artifacts}/brownfield-scan-integration-seam.md`
@@ -0,0 +1,141 @@
1
+ # Runtime Behavior Inventory Scanner — Subagent Prompt
2
+
3
+ > Brownfield deep analysis scan subagent. Catalogs runtime behaviors that only manifest during execution.
4
+ > Reference: Architecture ADR-021, Section 10.15.2, Section 10.15.5, ADR-022 §10.16.5
5
+ > Infra-awareness: E12-S6 — applies infra-specific patterns when project_type is infrastructure or platform.
6
+
7
+ ## Objective
8
+
9
+ Scan the codebase at `{project-path}` to catalog runtime behaviors — scheduled tasks, background processes, startup hooks, shutdown handlers, and behaviors that are not visible from static code structure alone.
10
+
11
+ **Input variables:**
12
+ - `{tech_stack}` — Detected technology stack from Step 1 discovery
13
+ - `{project-path}` — Absolute path to the project source code directory
14
+ - `{project_type}` — Project type: `application`, `infrastructure`, or `platform`
15
+
16
+ **Output format:** Follow the gap entry schema at `{project-root}/_gaia/lifecycle/templates/gap-entry-schema.md` exactly.
17
+
18
+ ## Detection Categories — Application Patterns
19
+
20
+ ### 1. Scheduled Tasks and Cron Jobs
21
+
22
+ Detect application-level scheduled tasks:
23
+ - **Java/Spring:** `@Scheduled`, `@EnableScheduling`, Quartz `@DisallowConcurrentExecution`
24
+ - **Node/Express:** `node-cron`, `agenda`, `bull` queue scheduled jobs, `setInterval` for polling
25
+ - **Python/Django:** Celery `@periodic_task`, `celery.conf.beat_schedule`, `django-crontab`
26
+ - **Go:** `robfig/cron`, `time.Ticker`, goroutine polling loops
27
+
28
+ ### 2. Startup and Shutdown Hooks
29
+
30
+ Detect application lifecycle hooks:
31
+ - **Java/Spring:** `@PostConstruct`, `@PreDestroy`, `ApplicationListener`, `CommandLineRunner`
32
+ - **Node/Express:** `process.on('SIGTERM')`, `process.on('SIGINT')`, `beforeExit`
33
+ - **Python/Django:** `AppConfig.ready()`, `atexit.register`, signal handlers
34
+ - **Go:** `os.Signal` handling, `defer` patterns in main(), `sync.Once`
35
+
36
+ ### 3. Background Workers and Async Processors
37
+
38
+ Detect background processing patterns:
39
+ - Message queue consumers (Bull, SQS, Kafka, RabbitMQ consumers)
40
+ - Worker threads, child processes, goroutines for long-running tasks
41
+ - WebSocket connection handlers
42
+ - File watchers and directory monitors
43
+
44
+ ### 4. Race Conditions and Concurrency Risks
45
+
46
+ Detect patterns prone to race conditions:
47
+ - Shared mutable state without synchronization
48
+ - Non-atomic read-modify-write sequences
49
+ - Missing database transaction boundaries on multi-step operations
50
+
51
+ ## Detection Categories — Infrastructure Patterns (E12-S6)
52
+
53
+ **Apply ONLY when {project_type} is `infrastructure` or `platform`.**
54
+
55
+ ### 5. CronJob Detection
56
+
57
+ Detect Kubernetes CronJob resources and their scheduling patterns.
58
+
59
+ **Scan for:**
60
+ - `kind: CronJob` in Kubernetes manifests
61
+ - `spec.schedule` field — extract the cron expression
62
+ - `spec.concurrencyPolicy` — flag if missing (defaults to `Allow`, may cause overlapping runs)
63
+ - `spec.startingDeadlineSeconds` — flag if missing (no deadline for missed schedules)
64
+ - `spec.successfulJobsHistoryLimit` / `spec.failedJobsHistoryLimit` — flag if set to 0 (no history retained)
65
+ - `spec.suspend` — note if suspended (informational)
66
+
67
+ **Flag these as gaps:**
68
+ - CronJobs without `concurrencyPolicy: Forbid` or `Replace` (risk of overlapping runs)
69
+ - CronJobs without `startingDeadlineSeconds` (missed jobs may accumulate)
70
+ - CronJobs without resource limits on their pod template
71
+ - CronJobs with `restartPolicy: Always` (CronJob pods should use `OnFailure` or `Never`)
72
+
73
+ **Severity:** `medium` for missing policies, `high` for incorrect restart policies
74
+
75
+ ### 6. DaemonSet Detection
76
+
77
+ Detect Kubernetes DaemonSet resources and their node scheduling.
78
+
79
+ **Scan for:**
80
+ - `kind: DaemonSet` in Kubernetes manifests
81
+ - `spec.updateStrategy` — flag if missing or set to `OnDelete` (prefer `RollingUpdate`)
82
+ - `spec.template.spec.tolerations` — catalog which node taints are tolerated
83
+ - `spec.template.spec.nodeSelector` — catalog node selection criteria
84
+ - `spec.template.spec.priorityClassName` — note if using system priority classes
85
+
86
+ **Flag these as gaps:**
87
+ - DaemonSets without `updateStrategy` (defaults to `OnDelete`, requires manual pod deletion)
88
+ - DaemonSets without resource requests/limits (can starve node resources)
89
+ - DaemonSets with `hostNetwork: true` without documented justification
90
+ - DaemonSets without `terminationGracePeriodSeconds` set appropriately
91
+
92
+ **Severity:** `medium` for missing update strategy, `high` for unbounded resource usage
93
+
94
+ ### 7. Init Container and Sidecar Pattern Detection
95
+
96
+ Detect init containers and sidecar container patterns in Kubernetes Pods.
97
+
98
+ **Scan for:**
99
+ - `spec.initContainers` in Pod specs — catalog each init container's purpose
100
+ - Multi-container pods where one container serves as a sidecar (log collector, proxy, metrics agent)
101
+ - Istio/Envoy sidecar injection annotations: `sidecar.istio.io/inject: "true"`
102
+ - Init containers that run database migrations, config loading, or secret fetching
103
+ - Sidecar containers for: logging (fluentd, filebeat), monitoring (prometheus exporter), proxying (envoy, nginx)
104
+
105
+ **Flag these as gaps:**
106
+ - Init containers without resource limits (can block pod startup indefinitely)
107
+ - Init containers without timeout or failure handling
108
+ - Sidecar containers without health checks (liveness/readiness probes)
109
+ - Multi-container pods without clear documentation of container roles
110
+
111
+ **Severity:** `medium` for missing resource limits, `low` for missing documentation
112
+
113
+ ### 8. Health Probe Detection (Liveness, Readiness, Startup)
114
+
115
+ Detect the presence and configuration of Kubernetes health probes.
116
+
117
+ **Scan for:**
118
+ - `livenessProbe` — checks if the container is running; restarts on failure
119
+ - `readinessProbe` — checks if the container can serve traffic; removes from service on failure
120
+ - `startupProbe` — checks if the application has started; disables liveness/readiness until success
121
+
122
+ **Flag these as gaps:**
123
+ - Containers without `livenessProbe` (no automatic restart on hang)
124
+ - Containers without `readinessProbe` (may receive traffic before ready)
125
+ - Long-starting containers without `startupProbe` (liveness probe may kill them during startup)
126
+ - Probes with `initialDelaySeconds: 0` and no `startupProbe` (may restart healthy containers during startup)
127
+ - Probes using `exec` commands that could be expensive (e.g., database queries as health checks)
128
+ - Liveness and readiness probes pointing to the same endpoint (if the endpoint is slow, both fail simultaneously)
129
+ - Missing `periodSeconds`, `timeoutSeconds`, `failureThreshold` customization (relying on defaults may not suit the workload)
130
+
131
+ **Severity:** `high` for missing liveness/readiness probes, `medium` for suboptimal probe configuration
132
+
133
+ ## Output Format
134
+
135
+ Gap entry structure uses `category: "runtime-behavior"` with `id: "GAP-RUNTIME-{seq}"`.
136
+ For infra-specific findings, include "[INFRA]" prefix in the title for clarity.
137
+ Budget: max 70 entries, truncate low-severity if exceeded.
138
+
139
+ ## Output File
140
+
141
+ Write all findings to: `{planning_artifacts}/brownfield-scan-runtime-behavior.md`