@aiwg/flue 2026.11.1 → 2026.11.3

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 (66) hide show
  1. package/package.json +9 -1
  2. package/skills/add-template/SKILL.md +4 -4
  3. package/skills/address-issues/SKILL.md +25 -19
  4. package/skills/address-issues/references/milestone.md +208 -0
  5. package/skills/address-issues/scripts/milestone-plan.mjs +109 -0
  6. package/skills/aiwg-delivery-pr/SKILL.md +6 -0
  7. package/skills/aiwg-issue/SKILL.md +44 -7
  8. package/skills/aiwg-pr/SKILL.md +9 -3
  9. package/skills/approval-workflow/SKILL.md +1 -1
  10. package/skills/architecture-evolution/SKILL.md +3 -3
  11. package/skills/audience-synthesis/SKILL.md +1 -1
  12. package/skills/brand-compliance/SKILL.md +1 -1
  13. package/skills/checkpoint/SKILL.md +31 -3
  14. package/skills/competitive-intel/SKILL.md +2 -2
  15. package/skills/config-validator/SKILL.md +2 -2
  16. package/skills/decision-support/SKILL.md +2 -2
  17. package/skills/deploy-gen/SKILL.md +3 -3
  18. package/skills/devkit-create-framework/SKILL.md +1 -1
  19. package/skills/exposure-analysis/SKILL.md +144 -0
  20. package/skills/exposure-analysis/SKILL.md.d.ts +3 -0
  21. package/skills/exposure-analysis/scripts/analyze.mjs +133 -0
  22. package/skills/exposure-analysis/scripts/firewall.mjs +113 -0
  23. package/skills/flow-architecture-evolution/SKILL.md +9 -9
  24. package/skills/flow-change-control/SKILL.md +10 -10
  25. package/skills/flow-compliance-validation/SKILL.md +6 -6
  26. package/skills/flow-concept-to-inception/SKILL.md +3 -3
  27. package/skills/flow-cross-team-sync/SKILL.md +6 -6
  28. package/skills/flow-deploy-to-production/SKILL.md +10 -10
  29. package/skills/flow-discovery-track/SKILL.md +12 -12
  30. package/skills/flow-elaboration-to-construction/SKILL.md +5 -5
  31. package/skills/flow-hypercare-monitoring/SKILL.md +4 -4
  32. package/skills/flow-inception-to-elaboration/SKILL.md +4 -4
  33. package/skills/flow-incident-response/SKILL.md +4 -4
  34. package/skills/flow-iteration-dual-track/SKILL.md +2 -2
  35. package/skills/flow-knowledge-transfer/SKILL.md +8 -8
  36. package/skills/flow-performance-optimization/SKILL.md +5 -5
  37. package/skills/flow-requirements-evolution/SKILL.md +3 -3
  38. package/skills/flow-retrospective-cycle/SKILL.md +4 -4
  39. package/skills/flow-risk-management-cycle/SKILL.md +3 -3
  40. package/skills/flow-team-onboarding/SKILL.md +5 -5
  41. package/skills/forensics-profile/SKILL.md +1 -1
  42. package/skills/forensics-quickref/SKILL.md +17 -0
  43. package/skills/forensics-report/SKILL.md +1 -1
  44. package/skills/forensics-timeline/SKILL.md +1 -1
  45. package/skills/forensics-triage/SKILL.md +1 -1
  46. package/skills/hook-regenerate/SKILL.md +2 -2
  47. package/skills/host-hardening/SKILL.md +150 -0
  48. package/skills/host-hardening/SKILL.md.d.ts +3 -0
  49. package/skills/host-hardening/scripts/bindings.mjs +48 -0
  50. package/skills/host-hardening/scripts/check.mjs +71 -0
  51. package/skills/incident-triage/SKILL.md +2 -2
  52. package/skills/intake-wizard/SKILL.md +1 -1
  53. package/skills/issue-create/SKILL.md +13 -13
  54. package/skills/issue-create/references/provider-writes.md +27 -0
  55. package/skills/issue-update/SKILL.md +4 -0
  56. package/skills/qa-protocol/SKILL.md +2 -2
  57. package/skills/regression-report/SKILL.md +5 -5
  58. package/skills/research-document/SKILL.md +1 -1
  59. package/skills/review-synthesis/SKILL.md +1 -1
  60. package/skills/sdlc-quickref/SKILL.md +7 -0
  61. package/skills/sdlc-reports/SKILL.md +4 -4
  62. package/skills/security-engineering-quickref/SKILL.md +20 -0
  63. package/skills/soul-create/SKILL.md +1 -1
  64. package/skills/test-coverage/SKILL.md +1 -1
  65. package/skills/traceability-check/SKILL.md +1 -1
  66. package/specialists.js +1 -1
@@ -2,7 +2,7 @@
2
2
  namespace: aiwg
3
3
  name: checkpoint
4
4
  platforms: [flue]
5
- description: Create, list, or recover mid-workflow checkpoints so interrupted work resumes from a known-good position
5
+ description: Create, list, or recover workflow checkpoints and prepare a handoff for a new session so interrupted work resumes from a known-good position
6
6
  ---
7
7
 
8
8
  # Checkpoint
@@ -18,6 +18,10 @@ Alternate expressions and non-obvious activations (primary phrases are matched a
18
18
  - "pick up where we left off" → recover from most recent checkpoint
19
19
  - "what checkpoints exist" → list checkpoints
20
20
  - "resume from checkpoint" → recover from specified or latest checkpoint
21
+ - "handoff" → create a checkpoint with session handoff documents
22
+ - "hand off to a new session" → create a checkpoint with session handoff documents
23
+ - "split this session" → create a checkpoint with session handoff documents
24
+ - "prepare a handoff for a new session" → create a checkpoint with session handoff documents
21
25
 
22
26
  ## Trigger Patterns Reference
23
27
 
@@ -25,6 +29,7 @@ Alternate expressions and non-obvious activations (primary phrases are matched a
25
29
  |---------|---------|--------|
26
30
  | Create (named) | "checkpoint this as iteration-3-complete" | Run `aiwg checkpoint create --name iteration-3-complete` |
27
31
  | Create (anonymous) | "create a checkpoint" | Run `aiwg checkpoint create` |
32
+ | Handoff | "hand off to a new session" | Run `aiwg checkpoint create --handoff` with explicit context flags |
28
33
  | List | "show available checkpoints" | Run `aiwg checkpoint list` |
29
34
  | Recover (latest) | "recover from the last checkpoint" | Run `aiwg checkpoint recover` |
30
35
  | Recover (specific) | "recover checkpoint ckpt_7b2f1a" | Run `aiwg checkpoint recover ckpt_7b2f1a` |
@@ -47,6 +52,13 @@ When triggered:
47
52
  # Create — named
48
53
  aiwg checkpoint create --name <name>
49
54
 
55
+ # Prepare a new session, with ordered tasks and binding constraints
56
+ aiwg checkpoint create --handoff --name tests-next \
57
+ --scope "Checkpoint implementation; next session owns verification" \
58
+ --phase construction --step verification --note "Implementation complete; tests pending" \
59
+ --todo "Run focused tests" --todo "Review the diff" \
60
+ --constraint "Do not commit or push" --artifact docs/cli-reference.md
61
+
50
62
  # List all checkpoints
51
63
  aiwg checkpoint list
52
64
 
@@ -68,7 +80,23 @@ When triggered:
68
80
 
69
81
  4. **Automatic creation**: Agent loops create checkpoints automatically between iterations. Manual `create` supplements this for critical workflow milestones.
70
82
 
71
- 5. **Storage**: Checkpoints are stored in `.aiwg/checkpoints/` as lightweight JSON files.
83
+ 5. **Storage**: Resolve the configured artifact root with `aiwg artifacts path --json --check-write`.
84
+ Plain checkpoints use `<artifact_root>/checkpoints/<id>.json`. Handoff checkpoints use
85
+ `<artifact_root>/checkpoints/<id>/checkpoint.json`, with sibling `handoff.md` and
86
+ `next-session-prompt.md`. The record includes `handoffPath` and `nextSessionPromptPath`.
87
+ The shipped template is `agentic/code/addons/aiwg-utils/templates/checkpoint-handoff.md`.
88
+ Existing flat records remain readable. This checkpoint format has inline validation,
89
+ with no governed schema in the schema catalog.
90
+
91
+ `--scope` fills Scope and ownership, `--note` plus `--phase`/`--step` fills State at handoff,
92
+ repeatable `--todo` fills To do (ordered), repeatable `--constraint` fills Binding constraints,
93
+ and repeatable `--artifact` fills Links. Omitted context stays as explicit `[TODO: ...]`
94
+ placeholders. `--scope`, `--todo`, and `--constraint` require `--handoff`; every value
95
+ flag requires a nonempty value. Creation is headless and never asks questions.
96
+
97
+ List marks handoffs in its Handoff column. Recover prints the next-session prompt
98
+ text and both document paths without writing files or restoring artifacts.
99
+ `list --json` and `recover --json` return checkpoint records, including the document paths.
72
100
 
73
101
  6. **Report the result** — on create, confirm the checkpoint ID and position; on recover, confirm which step the workflow will resume from.
74
102
 
@@ -117,7 +145,7 @@ ckpt_7b2f1a iteration-3-complete 2026-03-30 09:55:02 Construction / iter
117
145
  aiwg checkpoint recover
118
146
  ```
119
147
 
120
- **Response**: "Recovering from most recent checkpoint `iteration-3-complete` (ckpt_7b2f1a). Resuming Construction phase, iteration 3, step 12/15. In-progress artifact `.aiwg/working/tests/integration-plan-draft.md` reloaded. Ready to continue."
148
+ **Response**: "Checkpoint `iteration-3-complete` (ckpt_7b2f1a) records Construction phase, iteration 3, step 12/15 and artifact `.aiwg/working/tests/integration-plan-draft.md`. Inspect the current state before continuing."
121
149
 
122
150
  ### Example 4: Recover from a specific checkpoint
123
151
 
@@ -621,6 +621,6 @@ alerts:
621
621
 
622
622
  ## References
623
623
 
624
- - Competitor template: templates/marketing/competitor-profile.md
625
- - Battle card template: templates/marketing/battle-card.md
624
+ - Competitor template: templates/strategy/competitive-analysis-template.md
625
+ - Battle card template: templates/sales-enablement/battlecard-template.md
626
626
  - Intelligence sources: .aiwg/marketing/config/intel-sources.yaml
@@ -261,10 +261,10 @@ phase: inception
261
261
 
262
262
  **Current**:
263
263
  ```yaml
264
- template: templates/custom/my-template.md
264
+ template: templates/custom/<template>.md
265
265
  ```
266
266
 
267
- **Problem**: File `templates/custom/my-template.md` not found
267
+ **Problem**: File `templates/custom/<template>.md` not found
268
268
 
269
269
  **Fix Options**:
270
270
  1. Create the missing template file
@@ -462,6 +462,6 @@ thresholds:
462
462
 
463
463
  ## References
464
464
 
465
- - ADR template: templates/analysis-design/adr-template.md
466
- - Decision matrix template: templates/management/decision-matrix.md
465
+ - ADR template: agentic/code/frameworks/sdlc-complete/templates/governance/adr-template.md
466
+ - Decision matrix template: agentic/code/frameworks/sdlc-complete/templates/governance/decision-matrix-template.md
467
467
  - Trade-off catalog: docs/common-tradeoffs.md
@@ -73,9 +73,9 @@ Choose appropriate templates based on analysis:
73
73
 
74
74
  | Runtime | Template |
75
75
  |---------|----------|
76
- | Node.js | `templates/deploy/docker/node.Dockerfile` |
77
- | Python | `templates/deploy/docker/python.Dockerfile` |
78
- | Go | `templates/deploy/docker/go.Dockerfile` |
76
+ | Node.js | generated node.Dockerfile (use the Dockerfile example below) |
77
+ | Python | generated python.Dockerfile (use the Dockerfile example below) |
78
+ | Go | generated go.Dockerfile (use the Dockerfile example below) |
79
79
 
80
80
  ### 3. Configuration Generation
81
81
 
@@ -116,7 +116,7 @@ Created:
116
116
  ✓ actors-and-templates.md
117
117
  ✓ agents/manifest.md
118
118
  ✓ commands/manifest.md
119
- ✓ templates/manifest.json
119
+ ✓ <framework-root>/templates/manifest.json
120
120
  ✓ flows/<phase>.md (for each phase)
121
121
  ✓ metrics/tracking-catalog.md
122
122
  ✓ config/models.json
@@ -0,0 +1,144 @@
1
+ ---
2
+ namespace: aiwg
3
+ name: exposure-analysis
4
+ platforms: [flue]
5
+ description: Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.
6
+ triggers:
7
+ - "firewall analysis"
8
+ - "docker published ports"
9
+ - "what is reachable from the internet"
10
+ - "reconstruct host exposure"
11
+ tools: Read, Bash, Write
12
+ requires:
13
+ - operator-named host and authorized local or SSH read-only collection
14
+ - sanitized timestamped listener, Docker and firewall captures
15
+ ensures:
16
+ - effective exposure report with evidence hashes, limitations and pass/fail/unknown summary
17
+ invariants:
18
+ - never changes host firewall rules, services, containers or credentials
19
+ - unknown or incomplete evidence never proves a port closed
20
+ ---
21
+
22
+ # Exposure Analysis
23
+
24
+ ## Purpose
25
+
26
+ Relate listener inventory from `sys-host-audit` / Sys Host Profiler to host
27
+ firewall and Docker paths. Explain why a port is exposed, rather than trusting
28
+ `ufw status`. Use `container-forensics` for compromise indicators. This skill
29
+ produces reports and recommendations only, locally or over explicitly authorized
30
+ SSH. Do not install tools, elevate privileges, alter rules or probe unnamed hosts.
31
+
32
+ ## Triggers
33
+
34
+ - "firewall analysis"
35
+ - "docker published ports"
36
+ - "UFW says closed but Docker publishes it"
37
+ - "CDN origin exposure" / "stale firewall rules"
38
+
39
+ ## Behavior
40
+
41
+ 1. Confirm host, interface/address inventory, capture time in UTC, permitted
42
+ collection scope and artifact destination (`aiwg artifacts path --json --check-write`).
43
+ Load `evidence-integrity`, `non-destructive`, `ops-safety` and
44
+ `ops-information-governance` before collection. Keep this workflow read-only
45
+ even when a caller asks to fix findings.
46
+ 2. Reuse the existing host inventory when available. Within authorized scope,
47
+ collect bounded metadata using `ss -ltnup`, `ip -j address show`,
48
+ `iptables-save`, `ip6tables-save`, `ufw status numbered`,
49
+ `nft -j list ruleset` or `firewall-cmd --list-all-zones` as applicable.
50
+ Review runtime and persistent firewalld configuration separately. Record
51
+ permission failures as UNKNOWN; never interpret a failed command as no rules.
52
+ For SSH use the operator-named host with batch mode and a bounded connect
53
+ timeout; no fleet expansion or private configuration searches.
54
+ 3. Narrow Docker inspection to Name, NetworkMode, PortBindings,
55
+ NetworkSettings.Ports and Networks. NEVER capture full `docker inspect`,
56
+ process environments, datastore secrets, private keys or container Env.
57
+ Route collected bytes through the existing information-governance boundary
58
+ before terminal, artifact or report emission. Operator-held raw evidence is
59
+ hashed at acquisition; sanitized derivatives have separate hashes and custody
60
+ links. The helper only accepts already sanitized snapshots.
61
+ 4. Classify every listener by address family, protocol and bind scope:
62
+ loopback, private, named VPN address, all interfaces, public or unknown.
63
+ Record owning process/PID from ss and correlate its unit/container using
64
+ approved inventory metadata. Missing process/unit ownership stays unknown.
65
+ 5. Trace new inbound traffic in actual rule order. Docker rootful bridge traffic
66
+ normally traverses PREROUTING DNAT → FORWARD → DOCKER-USER → DOCKER.
67
+ INPUT/UFW denies do not protect this forwarding path. Include earlier raw,
68
+ mangle and native nft hooks, interface matches, conntrack and default policies.
69
+ Record each rule's listener/publish match; flag missing bind addresses, empty
70
+ DOCKER-USER guards, unused allows, earlier covering terminal rules, public-IP
71
+ allow-all and CDN ranges permitting ports beyond the reviewed 80/443 scope.
72
+ A stale rule is a review candidate: check socket activation, maintenance and
73
+ standby services before recommending removal.
74
+ 6. Review IPv4 and IPv6 independently, including IPv6 Docker publishing,
75
+ wildcard dual-stack sockets and differing defaults. Different family rules
76
+ are a review signal, not proof of equivalent reachability. Never infer IPv6
77
+ closure from an IPv4-only capture.
78
+ 7. External verification is optional and requires the operator to name the
79
+ vantage, source addresses, target and bounded port set. Compare the probe's
80
+ actual public egress/NAT source to all source allowlists, including CDN/VPN
81
+ and both address families. If the source matches an allow rule, explicitly
82
+ warn that a closed result proves nothing about ordinary internet sources.
83
+ A clean probe is still limited to that vantage/protocol/time. The helper
84
+ consumes supplied results; it never launches probes.
85
+ 8. Hash-check evidence before analysis and again before report finalization.
86
+ Include capture times, commands, collection failures, custody links and
87
+ rule paths. For "reachable on date X", use dated config history/backups
88
+ with their own hashes and distinguish reconstructed historical configuration
89
+ from observed reachability; today's captures cannot establish past exposure.
90
+
91
+ ## Offline helper
92
+
93
+ Run the bundled helper against an operator-supplied JSON snapshot:
94
+
95
+ ```bash
96
+ node "$AIWG_ROOT/agentic/code/frameworks/forensics-complete/skills/exposure-analysis/scripts/analyze.mjs" --snapshot sanitized-snapshot.json
97
+ ```
98
+
99
+ Required metadata: `host`, `capturedAt` (ISO UTC). Capture fields are strings:
100
+ `ss`, `docker` (JSON array of narrowed inspect records), `iptables4`,
101
+ `iptables6`, `ufw`. Supply `ingressInterface`, `vpnAddresses`, `cdnRanges`
102
+ (operator-reviewed CIDRs), and `hashes` mapping capture names to acquisition
103
+ SHA-256 values. Omitted hashes are explicitly unverified; a supplied mismatch
104
+ stops analysis. Optional `external` entries contain `source`, `port`, `protocol`,
105
+ `result`, capture time and vantage identity.
106
+
107
+ The helper supports ordered iptables/ip6tables filter and DNAT paths with
108
+ simple source/destination, protocol, port, interface and NEW-state selectors.
109
+ Unsupported selectors/chains, extra hook tables, native nftables/firewalld,
110
+ rootless/userland proxies and routed/host networks require manual analysis;
111
+ helper verdicts remain UNKNOWN. A host-path verdict never establishes upstream
112
+ internet routing or cloud controls. Do not represent the helper as a complete
113
+ Linux firewall evaluator. Cloud/Kubernetes controls are out of scope; attach
114
+ separately reviewed adapter findings to the existing network-audit report.
115
+
116
+ ## Examples
117
+
118
+ Input: `-p 6379:6379`, UFW deny 6379, matching DNAT and forwarding accepts,
119
+ empty DOCKER-USER. Output: **internet-reachable via Docker** on the captured
120
+ host path; `docker-ufw-bypass`, `missing-bind`, `empty-docker-user` findings.
121
+ A DOCKER-USER DROP before the Docker accept instead reports the captured path
122
+ blocked. An unused 5432 allow is stale; a CDN source allowing all ports is
123
+ `over-broad-cdn`. See sanitized fixtures in `test/fixtures/host-exposure/`.
124
+
125
+ ## Output and recurring checks
126
+
127
+ Use the existing `network-audit-report` template for the human report, storing
128
+ it under the resolved `.aiwg/forensics/reports/` and evidence/custody under
129
+ `.aiwg/forensics/evidence/`. The helper writes JSON only to stdout; caller owns
130
+ sanitization and artifact routing. Include a compact operations-log record:
131
+ `host, capturedAt, status, failed, unknown, report reference`.
132
+ Exit codes: 0 PASS, 2 FAIL, 3 UNKNOWN, 1 input/integrity error. Alert on any
133
+ nonzero result, not only FAIL. Post-deploy and monthly callers use existing
134
+ operator scheduling; every run needs fresh captures. No timer or service is
135
+ installed by this skill.
136
+
137
+ ## References
138
+
139
+ - ../../rules/evidence-integrity.md
140
+ - ../../rules/non-destructive.md
141
+ - ../../../ops-complete/rules/ops-safety.md
142
+ - ../container-forensics/SKILL.md
143
+ - ../../../../extensions/net/templates/network-audit-report.md
144
+ - ../../../security-engineering/skills/host-hardening/SKILL.md
@@ -0,0 +1,3 @@
1
+ import type { SkillReference } from '@flue/runtime';
2
+ declare const skill: SkillReference;
3
+ export default skill;
@@ -0,0 +1,133 @@
1
+ // Reconstruct exposure from operator-supplied sanitized captures without host access.
2
+ import { readFileSync } from 'node:fs';
3
+ import { createHash } from 'node:crypto';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { isIP } from 'node:net';
6
+ import { inRange, scope, parseFirewall, trace, listeners } from './firewall.mjs';
7
+
8
+ export function analyze(data) {
9
+ if (!data.host || !Number.isFinite(Date.parse(data.capturedAt))) throw new Error('host and ISO capturedAt are required');
10
+ const findings = [];
11
+ const add = (code, detail, extra = {}) => findings.push({ code, detail, ...extra });
12
+ const evidence = {};
13
+ for (const key of ['ss', 'docker', 'iptables4', 'iptables6', 'ufw', 'nftables', 'firewalld']) {
14
+ if (typeof data[key] === 'string') {
15
+ const sha256 = createHash('sha256').update(data[key]).digest('hex');
16
+ if (data.hashes?.[key] && data.hashes[key] !== sha256) throw new Error(`Integrity mismatch for ${key}`);
17
+ evidence[key] = { sha256, verification: data.hashes?.[key] ? 'matched supplied collection hash' : 'collection hash not supplied' };
18
+ }
19
+ }
20
+ const sockets = listeners(data.ss, data.vpnAddresses ?? []);
21
+ const firewalls = { 4: parseFirewall(data.iptables4, 4), 6: parseFirewall(data.iptables6, 6) };
22
+ const rules = Object.values(firewalls).flatMap(firewall => firewall.rules);
23
+ for (const [key, code] of [['ss', 'missing-listener-evidence'], ['docker', 'missing-docker-evidence'],
24
+ ['iptables4', 'missing-ipv4-evidence'], ['iptables6', 'missing-ipv6-evidence']]) {
25
+ if (!data[key]) add(code, `${key} unavailable; absence is not proof of closure`);
26
+ }
27
+ if (data.nftables || data.firewalld) add('manual-backend-review', 'Native nftables/firewalld order and hook priorities need manual correlation; automated verdicts are unknown');
28
+ const containers = JSON.parse(data.docker ?? '[]');
29
+ const exposures = [];
30
+ for (const container of containers) {
31
+ for (const [containerPort, bindings] of Object.entries(container.NetworkSettings?.Ports ?? {})) {
32
+ if (!bindings) continue;
33
+ const [targetPort, protocol] = containerPort.split('/');
34
+ for (const binding of bindings) {
35
+ const address = binding.HostIp ?? '';
36
+ const family = isIP(address) || 4;
37
+ const port = Number(binding.HostPort);
38
+ const firewall = firewalls[family];
39
+ const bindScope = scope(address, data.vpnAddresses ?? []);
40
+ const requested = container.HostConfig?.PortBindings?.[containerPort] ?? [];
41
+ if (!address || requested.some(entry => !entry.HostIp)) add('missing-bind', 'Publish omitted a bind address', { port, family });
42
+ const guard = firewall.tables.filter?.['DOCKER-USER'];
43
+ if (!guard || guard.rules.every(rule => rule.target === 'RETURN')) add('empty-docker-user', 'DOCKER-USER has no effective guard', { family, port });
44
+ const packet = { port, protocol, source: '*', destination: scope(address) === 'all-interfaces' ? '*' : address, input: data.ingressInterface };
45
+ const nat = trace(firewall, 'nat', 'PREROUTING', packet);
46
+ const translated = nat.rule?.dnat?.match(/^(?:\[([^\]]+)\]|([^:]+)):(\d+)$/);
47
+ const destination = translated?.[1] ?? translated?.[2];
48
+ const networkAddresses = Object.values(container.NetworkSettings?.Networks ?? {}).flatMap(network => [network.IPAddress, network.GlobalIPv6Address]);
49
+ const forward = trace(firewall, 'filter', 'FORWARD', { ...packet, destination, port: Number(translated?.[3]) });
50
+ let verdict = 'unknown';
51
+ const unsupported = data.nftables || data.firewalld || Object.keys(firewall.tables).some(table => !['filter', 'nat'].includes(table));
52
+ if (!unsupported && nat.verdict === 'DNAT' && Number(translated?.[3]) === Number(targetPort) && networkAddresses.includes(destination)) {
53
+ if (['DROP', 'REJECT'].includes(forward.verdict)) verdict = 'blocked on captured host path';
54
+ if (forward.verdict === 'ACCEPT' && ['all-interfaces', 'public'].includes(bindScope)) verdict = 'internet-reachable via Docker';
55
+ if (forward.verdict === 'ACCEPT' && ['private', 'vpn', 'loopback'].includes(bindScope)) verdict = 'restricted bind; routing requires review';
56
+ }
57
+ const entry = { container: container.Name, port, protocol, address, family, scope: bindScope,
58
+ verdict, path: [...nat.path, ...forward.path], limitation: 'Captured host path only; upstream routing and cloud controls unverified' };
59
+ exposures.push(entry);
60
+ const input = trace(firewall, 'filter', 'INPUT', packet);
61
+ const ufwDeny = (data.ufw ?? '').split('\n').some(line => new RegExp(`^${port}(?:/${protocol})?\\s+DENY`).test(line));
62
+ if (verdict === 'internet-reachable via Docker' && (ufwDeny || ['DROP', 'REJECT'].includes(input.verdict))) {
63
+ add('docker-ufw-bypass', 'UFW/INPUT deny is bypassed by Docker DNAT and FORWARD', { port, family });
64
+ }
65
+ }
66
+ }
67
+ }
68
+ for (const rule of rules) {
69
+ if (rule.target === 'ACCEPT' && rule.port && /^\d+$/.test(rule.port) && rule.chain === 'INPUT' && data.ss) {
70
+ const active = sockets.some(socket => (socket.family === rule.family || socket.family === 0) && socket.port === Number(rule.port)
71
+ && (!rule.protocol || socket.protocol === rule.protocol));
72
+ const published = exposures.some(entry => entry.family === rule.family && entry.port === Number(rule.port));
73
+ if (!active && !published) add('stale-rule', 'No captured listener or publish; validate standby/activation before removal', { port: Number(rule.port), family: rule.family, rule: rule.raw });
74
+ }
75
+ if (rule.target === 'ACCEPT' && rule.source && !rule.port && !rule.unknown) {
76
+ if ((data.cdnRanges ?? []).includes(rule.source)) add('over-broad-cdn', 'CDN source range permits all ports; recommend reviewed 80/443 scope', { rule: rule.raw });
77
+ else if (['public', 'all-interfaces'].includes(scope(rule.source.split('/')[0]))) add('over-broad-source', 'Public source permits all ports', { rule: rule.raw });
78
+ }
79
+ const chainRules = firewalls[rule.family].tables[rule.table][rule.chain].rules;
80
+ const earlier = chainRules.slice(0, chainRules.indexOf(rule));
81
+ const selectors = ['source', 'destination', 'protocol', 'port', 'input', 'output', 'state', 'dstType'];
82
+ if (!rule.unknown && earlier.some(first => !first.unknown && ['ACCEPT', 'DROP', 'REJECT'].includes(first.target)
83
+ && selectors.every(key => !first[key] || first[key] === rule[key]))) add('shadowed-rule', 'Earlier terminal rule covers these selectors', { family: rule.family, rule: rule.raw });
84
+ }
85
+ if (data.iptables4 && data.iptables6) {
86
+ const signature = family => JSON.stringify({ policy: firewalls[family].tables.filter?.INPUT?.policy,
87
+ rules: rules.filter(rule => rule.family === family && rule.table === 'filter').map(rule => rule.raw) });
88
+ if (signature(4) !== signature(6)) add('v4-v6-asymmetry', 'IPv4/IPv6 policy or rule coverage differs; review family-specific listener reachability');
89
+ }
90
+ const hostExposures = sockets.flatMap(socket => {
91
+ const families = socket.family ? [socket.family] : [4, 6];
92
+ return families.map(family => {
93
+ const firewall = firewalls[family];
94
+ const packet = { port: socket.port, protocol: socket.protocol, source: '*',
95
+ destination: socket.scope === 'all-interfaces' ? '*' : socket.address, input: data.ingressInterface };
96
+ const result = trace(firewall, 'filter', 'INPUT', packet);
97
+ const unsupported = data.nftables || data.firewalld || Object.keys(firewall.tables).some(table => !['filter', 'nat'].includes(table));
98
+ const verdict = unsupported ? 'unknown' : ['loopback', 'vpn', 'private'].includes(socket.scope) ? 'restricted bind; routing requires review'
99
+ : result.verdict === 'ACCEPT' ? 'accepted on captured host path'
100
+ : ['DROP', 'REJECT'].includes(result.verdict) ? 'blocked on captured host path' : 'unknown';
101
+ return { ...socket, family, verdict, path: result.path };
102
+ });
103
+ });
104
+ const policies = Object.entries(firewalls).flatMap(([family, firewall]) => Object.entries(firewall.tables).flatMap(([table, chains]) =>
105
+ Object.entries(chains).filter(([, body]) => body.policy !== '-').map(([chain, body]) =>
106
+ ({ family: Number(family), table, chain, type: 'policy', target: body.policy }))));
107
+ const mappedRules = rules.map(rule => ({ ...rule, listenerMatches: sockets.filter(socket =>
108
+ (socket.family === rule.family || !socket.family) && (!rule.port || Number(rule.port) === socket.port)
109
+ && (!rule.protocol || rule.protocol === socket.protocol)).map(socket => `${socket.address}:${socket.port}/${socket.protocol}`) }));
110
+ const external = (data.external ?? []).map(probe => {
111
+ const family = isIP(probe.source);
112
+ const allow = rules.find(rule => rule.family === family && rule.target === 'ACCEPT' && rule.source
113
+ && !['0.0.0.0/0', '::/0'].includes(rule.source) && inRange(probe.source, rule.source));
114
+ if (allow) add('allowlisted-vantage', 'Probe source matches an allowlist; external coverage is unrepresentative', { family, port: probe.port });
115
+ return { ...probe, provesClosed: false, reason: allow
116
+ ? 'Probe source matches an allowlist; closed result proves nothing about ordinary internet sources'
117
+ : 'Result is limited to this vantage, protocol, port and capture time; it cannot prove general closure' };
118
+ });
119
+ const unknown = findings.filter(finding => /missing-.*evidence|manual-backend/.test(finding.code)).length + exposures.filter(entry => entry.verdict === 'unknown').length;
120
+ const failed = findings.length - findings.filter(finding => /missing-.*evidence|manual-backend/.test(finding.code)).length;
121
+ return { host: data.host, capturedAt: data.capturedAt, mode: 'read-only', evidence,
122
+ listeners: sockets, rules: [...mappedRules, ...policies], exposures, hostExposures, findings, external,
123
+ summary: { status: failed ? 'FAIL' : unknown ? 'UNKNOWN' : 'PASS', failed, unknown } };
124
+ }
125
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
126
+ try {
127
+ const args = process.argv.slice(2);
128
+ if (args.length !== 2 || args[0] !== '--snapshot') throw new Error('Usage: analyze.mjs --snapshot sanitized-snapshot.json');
129
+ const report = analyze(JSON.parse(readFileSync(args[1], 'utf8')));
130
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
131
+ process.exitCode = report.summary.status === 'FAIL' ? 2 : report.summary.status === 'UNKNOWN' ? 3 : 0;
132
+ } catch (error) { process.stderr.write(`${error.message}\n`); process.exitCode = 1; }
133
+ }
@@ -0,0 +1,113 @@
1
+ // Parse captured iptables rules and conservatively trace a new inbound packet.
2
+ import { isIP } from 'node:net';
3
+
4
+ function addressNumber(address) {
5
+ if (isIP(address) === 4) return address.split('.').reduce((n, part) => (n << 8n) + BigInt(part), 0n);
6
+ if (isIP(address) !== 6) return undefined;
7
+ let text = address;
8
+ if (text.includes('.')) {
9
+ const split = text.lastIndexOf(':');
10
+ const v4 = addressNumber(text.slice(split + 1));
11
+ text = `${text.slice(0, split)}:${(v4 >> 16n).toString(16)}:${(v4 & 65535n).toString(16)}`;
12
+ }
13
+ const halves = text.split('::');
14
+ const left = halves[0] ? halves[0].split(':') : [];
15
+ const right = halves[1] ? halves[1].split(':') : [];
16
+ const groups = halves.length === 2 ? [...left, ...Array(8 - left.length - right.length).fill('0'), ...right] : left;
17
+ return groups.reduce((n, group) => (n << 16n) + BigInt(`0x${group}`), 0n);
18
+ }
19
+ export function inRange(address, cidr) {
20
+ const [base, mask] = cidr.split('/');
21
+ const family = isIP(base);
22
+ if (!family || isIP(address) !== family) return false;
23
+ const bits = family === 4 ? 32 : 128;
24
+ const prefix = mask === undefined ? bits : Number(mask);
25
+ if (!Number.isInteger(prefix) || prefix < 0 || prefix > bits) return false;
26
+ const shift = BigInt(bits - prefix);
27
+ return addressNumber(address) >> shift === addressNumber(base) >> shift;
28
+ }
29
+ export function scope(address, vpn = []) {
30
+ if (vpn.includes(address)) return 'vpn';
31
+ if (['*', '0.0.0.0', '::', ''].includes(address)) return 'all-interfaces';
32
+ if (inRange(address, '127.0.0.0/8') || address === '::1') return 'loopback';
33
+ if (['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '169.254.0.0/16', 'fc00::/7', 'fe80::/10'].some(range => inRange(address, range))) return 'private';
34
+ return isIP(address) ? 'public' : 'unknown';
35
+ }
36
+ export function parseFirewall(raw, family) {
37
+ const tables = {};
38
+ const rules = [];
39
+ let table;
40
+ for (const line of (raw ?? '').split('\n')) {
41
+ if (line.startsWith('*')) { table = line.slice(1); tables[table] = {}; }
42
+ if (line.startsWith(':') && table) {
43
+ const [name, policy] = line.slice(1).split(/\s+/);
44
+ tables[table][name] = { policy, rules: [] };
45
+ }
46
+ if (!line.startsWith('-A ') || !table) continue;
47
+ const tokens = line.match(/"[^"]*"|\S+/g) ?? [];
48
+ const rule = { family, table, chain: tokens[1], raw: line, unknown: false };
49
+ for (let i = 2; i < tokens.length; i++) {
50
+ const token = tokens[i];
51
+ const fields = { '-s': 'source', '-d': 'destination', '-p': 'protocol', '--dport': 'port',
52
+ '-j': 'target', '--to-destination': 'dnat', '-i': 'input', '-o': 'output', '--ctstate': 'state', '--dst-type': 'dstType' };
53
+ if (fields[token]) rule[fields[token]] = tokens[++i];
54
+ else if (token === '-m') { if (!['tcp', 'udp', 'conntrack', 'addrtype', 'comment'].includes(tokens[++i])) rule.unknown = true; }
55
+ else if (token === '--comment') i++;
56
+ else rule.unknown = true;
57
+ }
58
+ if (!tables[table][rule.chain]) tables[table][rule.chain] = { policy: '-', rules: [] };
59
+ tables[table][rule.chain].rules.push(rule);
60
+ rules.push(rule);
61
+ }
62
+ return { tables, rules };
63
+ }
64
+ function match(rule, packet) {
65
+ let unknown = rule.unknown;
66
+ for (const key of ['source', 'destination']) {
67
+ if (!rule[key] || ['0.0.0.0/0', '::/0'].includes(rule[key])) continue;
68
+ if (!packet[key] || packet[key] === '*') unknown = true;
69
+ else if (!inRange(packet[key], rule[key])) return false;
70
+ }
71
+ if (rule.protocol && rule.protocol !== 'all' && rule.protocol !== packet.protocol) return false;
72
+ if (rule.port) {
73
+ if (!/^\d+$/.test(rule.port)) unknown = true;
74
+ else if (Number(rule.port) !== packet.port) return false;
75
+ }
76
+ for (const key of ['input', 'output']) {
77
+ if (!rule[key]) continue;
78
+ if (!packet[key]) unknown = true;
79
+ else if (rule[key] !== packet[key]) return false;
80
+ }
81
+ if (rule.state && !rule.state.split(',').includes('NEW')) return false;
82
+ if (rule.dstType && rule.dstType !== 'LOCAL') unknown = true;
83
+ return unknown ? 'unknown' : true;
84
+ }
85
+ export function trace(firewall, table, chain, packet, seen = []) {
86
+ const name = `${table}/${chain}`;
87
+ const path = [name];
88
+ const body = firewall.tables[table]?.[chain];
89
+ if (!body || seen.includes(name)) return { verdict: 'UNKNOWN', path };
90
+ for (const rule of body.rules) {
91
+ const matches = match(rule, packet);
92
+ if (matches === false) continue;
93
+ if (matches === 'unknown') return { verdict: 'UNKNOWN', path };
94
+ const target = rule.target;
95
+ if (['ACCEPT', 'DROP', 'REJECT', 'RETURN', 'DNAT'].includes(target)) return { verdict: target, path, rule };
96
+ if (['LOG', 'NFLOG'].includes(target)) continue;
97
+ const nested = trace(firewall, table, target, packet, [...seen, name]);
98
+ path.push(...nested.path);
99
+ if (nested.verdict !== 'RETURN') return { ...nested, path };
100
+ }
101
+ return { verdict: body.policy === '-' ? 'RETURN' : body.policy, path };
102
+ }
103
+ export function listeners(raw, vpn) {
104
+ return (raw ?? '').split('\n').flatMap(line => {
105
+ const columns = line.trim().split(/\s+/);
106
+ if (!['tcp', 'udp'].includes(columns[0]) || !['LISTEN', 'UNCONN'].includes(columns[1])) return [];
107
+ const endpoint = columns[4]?.match(/^(?:\[([^\]]+)\]|(.+)):(\d+)$/);
108
+ if (!endpoint) return [];
109
+ const address = endpoint[1] ?? endpoint[2];
110
+ return [{ protocol: columns[0], address, port: Number(endpoint[3]), family: isIP(address) || 0,
111
+ scope: scope(address, vpn), owner: line.match(/users:\(\((.*)\)\)/)?.[1] ?? 'unknown' }];
112
+ });
113
+ }
@@ -214,7 +214,7 @@ Based on your answers, I'll adjust:
214
214
  - Business risks
215
215
  - Timeline risks
216
216
 
217
- Use template: $AIWG_ROOT/templates/management/impact-assessment-template.md
217
+ Use template: agentic/code/frameworks/sdlc-complete/templates/configuration/change-request-card.md
218
218
 
219
219
  Save to: .aiwg/working/architecture-evolution/impact-assessment-draft.md
220
220
  """
@@ -297,7 +297,7 @@ Based on your answers, I'll adjust:
297
297
  - Feasibility assessment
298
298
 
299
299
  Create option matrix using template:
300
- $AIWG_ROOT/templates/intake/option-matrix-template.md
300
+ agentic/code/frameworks/sdlc-complete/templates/intake/option-matrix-template.md
301
301
 
302
302
  Score each option on:
303
303
  - Cost (1-5, lower is better)
@@ -339,7 +339,7 @@ Task(
339
339
  - Option matrix (preferred option)
340
340
 
341
341
  Create comprehensive ADR using template:
342
- $AIWG_ROOT/templates/analysis-design/architecture-decision-record-template.md
342
+ agentic/code/frameworks/sdlc-complete/templates/governance/adr-template.md
343
343
 
344
344
  Structure:
345
345
  1. Title: Clear, descriptive (e.g., "Migration from PostgreSQL to DynamoDB")
@@ -440,7 +440,7 @@ Task(
440
440
  prompt="""
441
441
  Based on breaking changes and chosen architecture option.
442
442
 
443
- Use template: $AIWG_ROOT/templates/deployment/migration-plan-template.md
443
+ Use the inline format: migration plan fields in this skill
444
444
 
445
445
  Define migration strategy:
446
446
  - Pattern (Strangler Fig, Blue-Green, Canary, Big Bang)
@@ -473,7 +473,7 @@ Task(
473
473
  prompt="""
474
474
  Based on migration plan.
475
475
 
476
- Use template: $AIWG_ROOT/templates/deployment/rollback-plan-template.md
476
+ Use the inline format: rollback steps in this skill
477
477
 
478
478
  Document:
479
479
  1. Rollback Triggers
@@ -880,10 +880,10 @@ This orchestration succeeds when:
880
880
  ## References
881
881
 
882
882
  **Templates** (via $AIWG_ROOT):
883
- - ADR: `templates/analysis-design/architecture-decision-record-template.md`
884
- - Impact Assessment: `templates/management/impact-assessment-template.md`
885
- - Migration Plan: `templates/deployment/migration-plan-template.md`
886
- - Rollback Plan: `templates/deployment/rollback-plan-template.md`
883
+ - ADR: `agentic/code/frameworks/sdlc-complete/templates/governance/adr-template.md`
884
+ - Impact Assessment: `agentic/code/frameworks/sdlc-complete/templates/configuration/change-request-card.md`
885
+ - Migration Plan: migration plan fields in this skill
886
+ - Rollback Plan: rollback steps in this skill
887
887
  - Option Matrix: `templates/intake/option-matrix-template.md`
888
888
 
889
889
  **Related Flows**: