Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
7ea3aa7
docs: start milestone v1.5 MCP Integration
SoulKyu Jul 20, 2026
b5b8d0e
docs(v1.5): research synthesis (stack/features/arch/pitfalls)
SoulKyu Jul 20, 2026
c8104a3
docs: define milestone v1.5 requirements
SoulKyu Jul 20, 2026
2657644
docs: create milestone v1.5 roadmap (4 phases)
SoulKyu Jul 20, 2026
b373979
docs(16): capture phase context
SoulKyu Jul 20, 2026
a39d61a
docs(state): record phase 16 context session
SoulKyu Jul 20, 2026
ec9cbdd
docs(16): research MCP server foundation & write safety
SoulKyu Jul 20, 2026
e58f438
docs(phase-16): add validation strategy
SoulKyu Jul 20, 2026
0667263
docs(16): add pattern map
SoulKyu Jul 20, 2026
7175618
docs(16): create phase plan (3 plans, 2 waves)
SoulKyu Jul 20, 2026
d320e9a
docs(16): revise phase 16 plan/research per checker feedback
SoulKyu Jul 20, 2026
b74a218
docs(16): create phase plan
SoulKyu Jul 20, 2026
55f7cc2
feat(16-01): atomic temp+rename write in pkg/output/writer.go
SoulKyu Jul 20, 2026
1e354a2
test(16-01): add atomicity and concurrent-reader tests for pkg/output…
SoulKyu Jul 20, 2026
09d9e96
feat(16-02): pin github.com/modelcontextprotocol/go-sdk v1.6.1
SoulKyu Jul 20, 2026
01f432c
docs(16-01): complete atomic policy writer plan
SoulKyu Jul 20, 2026
afd1eec
docs(16-01): append self-check results to plan summary
SoulKyu Jul 20, 2026
ed046a4
docs(16-02): complete go-sdk dependency provisioning plan
SoulKyu Jul 20, 2026
8dea8b0
Merge branch 'worktree-agent-ab48a4de1036bb030'
SoulKyu Jul 20, 2026
bd29530
docs(phase-16): update tracking after wave 1
SoulKyu Jul 20, 2026
93e7b3e
feat(16-03): create cpg mcp server skeleton and register command
SoulKyu Jul 20, 2026
4568c19
test(16-03): add reusable in-memory stdout-purity harness
SoulKyu Jul 20, 2026
2f19514
test(16-03): add seam-audit, cobra flag-error, and zapslog-bridge tests
SoulKyu Jul 20, 2026
09c3845
docs(16-03): complete MCP server skeleton plan
SoulKyu Jul 20, 2026
c32d914
docs(phase-16): update tracking after wave 2
SoulKyu Jul 20, 2026
aff69e8
docs(16): add code review report
SoulKyu Jul 20, 2026
2389f2f
fix(16): WR-01 check cleanup error returns in atomic write path
SoulKyu Jul 20, 2026
4fb7ba2
fix(16): WR-02 stop swallowing cpg mcp startup/runtime errors
SoulKyu Jul 20, 2026
da4a22f
docs(16): add code review fix report
SoulKyu Jul 20, 2026
2cf0754
fix(16): make seam-audit test immune to global stdout swaps
SoulKyu Jul 20, 2026
ab665c5
fix(16): guard seam-audit identity assertion against test2json stderr…
SoulKyu Jul 20, 2026
c5ec29a
docs(phase-16): complete phase execution
SoulKyu Jul 20, 2026
e5bdfcf
docs(phase-16): evolve PROJECT.md after phase completion
SoulKyu Jul 20, 2026
3c9d632
chore(planning): normalize config.json trailing newline
SoulKyu Jul 20, 2026
dff0b81
docs(17): capture phase context
SoulKyu Jul 20, 2026
e061bf9
docs(state): record phase 17 context session
SoulKyu Jul 20, 2026
637103d
docs(17): research session lifecycle phase domain
SoulKyu Jul 20, 2026
e2fb7bb
docs(phase-17): add validation strategy
SoulKyu Jul 20, 2026
4d250ad
docs(17): create phase plan (session lifecycle, 4 plans / 4 waves)
SoulKyu Jul 20, 2026
f28199a
docs(17): add pattern map
SoulKyu Jul 20, 2026
3626ef0
docs(17): revise plan 17-03 for concurrency blockers
SoulKyu Jul 20, 2026
0927ab1
docs(17): add setup-window race + rollback tests to plan 17-03
SoulKyu Jul 20, 2026
83b6890
docs(17): create phase plan
SoulKyu Jul 20, 2026
507d0b3
feat(17-01): add nil-safe OnFinal hook to PipelineConfig
SoulKyu Jul 21, 2026
d1e43a4
test(17-01): add OnFinal fires-once and nil-safe coverage
SoulKyu Jul 21, 2026
7f7f64c
docs(17-01): add plan SUMMARY
SoulKyu Jul 21, 2026
53bf905
docs(17-01): finalize plan SUMMARY self-check
SoulKyu Jul 21, 2026
91e60de
docs(phase-17): update tracking after wave 1
SoulKyu Jul 21, 2026
5fd92f7
feat(17-02): add pkg/session state model + result shapes
SoulKyu Jul 21, 2026
c3b233e
feat(17-02): add pkg/session pipeline config builder + crash guard
SoulKyu Jul 21, 2026
5c86740
docs(17-02): add plan 17-02 execution summary
SoulKyu Jul 21, 2026
3f669ba
docs(17-02): append self-check results to plan summary
SoulKyu Jul 21, 2026
b8bbbbd
docs(phase-17): update tracking after wave 2
SoulKyu Jul 21, 2026
6674d8b
feat(17-03): create pkg/session/manager.go single-slot state machine
SoulKyu Jul 21, 2026
9e8168e
test(17-03): add -race suite for pkg/session/manager.go
SoulKyu Jul 21, 2026
7ee848c
docs(17-03): add plan summary
SoulKyu Jul 21, 2026
ad6ee5c
docs(phase-17): update tracking after wave 3
SoulKyu Jul 21, 2026
83f70c0
feat(17-04): register session MCP tools and wire Manager into runMCPS…
SoulKyu Jul 21, 2026
c9eaf0c
test(17-04): add cluster-free MCP session tool integration tests
SoulKyu Jul 21, 2026
a799add
docs(17-04): complete MCP session tools plan
SoulKyu Jul 21, 2026
15b36dd
docs(phase-17): update tracking after wave 4
SoulKyu Jul 21, 2026
68c2dd5
docs(17): add code review report
SoulKyu Jul 21, 2026
f74f462
docs(17): add phase verification report (gaps_found)
SoulKyu Jul 21, 2026
3bd61f1
docs(17): add gap-closure plans for WR-01, WR-02/WR-03, D-02 reconcil…
SoulKyu Jul 21, 2026
7b6f03b
docs(17): finalize gap-closure planning (checker fix, state)
SoulKyu Jul 21, 2026
62a9588
docs(17-07): reconcile SC5/SESS-06 wording with D-02 retained-session…
SoulKyu Jul 21, 2026
4bf0063
feat(17-05): add terminal-error data layer to pkg/session
SoulKyu Jul 21, 2026
e0ce76d
feat(17-05): autonomously transition State on genuine pipeline failure
SoulKyu Jul 21, 2026
3f953d2
docs(17-07): complete D-02 documentation reconciliation plan
SoulKyu Jul 21, 2026
934369e
test(17-05): prove genuine pipeline errors autonomously stop sessions
SoulKyu Jul 21, 2026
335e524
docs(17-05): reference pipelineErr in the new test's doc comment
SoulKyu Jul 21, 2026
74706a5
docs(17-05): complete WR-01 gap-closure plan (SESS-03 truthful get_st…
SoulKyu Jul 21, 2026
9f330c3
Merge branch 'worktree-agent-ad9055130a8d0e6ac'
SoulKyu Jul 21, 2026
ced76db
Merge branch 'worktree-agent-aabf6e6363469dc5e'
SoulKyu Jul 21, 2026
9e5c089
docs(phase-17): update tracking after gap-closure wave 1
SoulKyu Jul 21, 2026
f8f9bdd
feat(17-06): merge sessionCtx into setupCtx so Shutdown aborts mid-se…
SoulKyu Jul 21, 2026
9147a2e
test(17-06): prove Shutdown cancels mid-setup with ctx-inspecting -ra…
SoulKyu Jul 21, 2026
bf3012c
feat(17-06): bound MCP-supplied timeout/flush_interval above 24h (WR-03)
SoulKyu Jul 21, 2026
e8e0f69
docs(17-06): complete setup-phase shutdown cancellation + duration ce…
SoulKyu Jul 21, 2026
07dee4c
Merge branch 'worktree-agent-aa1f2180fc057a92a'
SoulKyu Jul 21, 2026
dc090de
docs(phase-17): update tracking after gap-closure wave 2
SoulKyu Jul 21, 2026
1e37ef9
docs(17): update code review report after gap-closure waves
SoulKyu Jul 21, 2026
738dcd5
docs(17): update phase verification report after gap-closure (gaps_fo…
SoulKyu Jul 21, 2026
0fdf386
docs(17): create gap-closure plan 17-08 (WR-01 crash classification, …
SoulKyu Jul 21, 2026
f47b837
test(17-08): add failing test for scoped dial-timeout misclassificati…
SoulKyu Jul 21, 2026
cca60a1
feat(17-08): classify genuine crash on sessionCtx cancellation, not e…
SoulKyu Jul 21, 2026
0690fd8
test(17-08): add failing test for first-stop-after-crash already_stop…
SoulKyu Jul 21, 2026
0159b66
feat(17-08): track explicit-stop separately from State via atomic Swa…
SoulKyu Jul 21, 2026
7ecc562
docs(17-08): add plan 08 execution summary (WR-01, WR-02 gap closure)
SoulKyu Jul 21, 2026
515e132
docs(17-08): complete crash-classification and already-stopped gap cl…
SoulKyu Jul 21, 2026
dfe68be
docs(17): update code review report after 17-08 gap closure
SoulKyu Jul 21, 2026
ca69703
docs(17): update phase verification report after 17-08 gap closure (g…
SoulKyu Jul 21, 2026
3cef6e7
docs(17-09): plan clean/nil-exit autonomous stop gap closure (WR-01, …
SoulKyu Jul 21, 2026
fc04f02
docs(17): record 17-09 gap-closure planning in STATE
SoulKyu Jul 21, 2026
a185b9f
test(17-09): add failing regression for clean-nil-exit autonomous stop
SoulKyu Jul 21, 2026
d4fdbb1
feat(17-09): broaden autonomous-exit guard to fire on clean nil drain
SoulKyu Jul 21, 2026
eb40580
test(17-09): pin D-03 already_stopped contract for clean-exit path
SoulKyu Jul 21, 2026
d37ced3
docs(17-09): add plan 09 execution summary
SoulKyu Jul 21, 2026
35504f5
docs(17-09): append self-check results to SUMMARY
SoulKyu Jul 21, 2026
8275ef6
docs(phase-17): update tracking after wave 1
SoulKyu Jul 21, 2026
9546775
docs(17): update code review report after 17-09 gap closure
SoulKyu Jul 21, 2026
e77be42
docs(phase-17): complete phase execution
SoulKyu Jul 21, 2026
e196aad
docs(phase-17): evolve PROJECT.md after phase completion
SoulKyu Jul 21, 2026
bd9fbd3
docs(18): capture phase context
SoulKyu Jul 21, 2026
4043201
docs(state): record phase 18 context session
SoulKyu Jul 21, 2026
8853108
docs(18): research query-tools phase domain
SoulKyu Jul 21, 2026
02cb483
docs(phase-18): add validation strategy
SoulKyu Jul 21, 2026
e1f2a52
docs(18): create phase plan (5 plans, 4 waves — query tools)
SoulKyu Jul 21, 2026
48a31d2
docs(18): revise plans per checker (ParsePeerLabel export, get_eviden…
SoulKyu Jul 21, 2026
38d1ed0
docs(18): finalize planning artifacts (state, roadmap annotations, do…
SoulKyu Jul 21, 2026
2c57c07
docs(phase-18): begin phase execution tracking
SoulKyu Jul 21, 2026
7ace14c
feat(18-02): export output.ReadPolicyFile with wrapped-not-exist cont…
SoulKyu Jul 21, 2026
3215c25
test(18-01): add relocated pkg/explain filter/render tests (RED)
SoulKyu Jul 21, 2026
667f5ba
feat(18-01): implement pkg/explain with exported Filter/Output/Render…
SoulKyu Jul 21, 2026
7dabea1
feat(18-02): export cluster-health types and add hubble.ReadClusterHe…
SoulKyu Jul 21, 2026
9dde6e5
test(18-01): delete promoted-out explain files, align tests to pkg/ex…
SoulKyu Jul 21, 2026
ca5b920
feat(18-01): thin cmd/cpg/explain.go to call pkg/explain (GREEN)
SoulKyu Jul 21, 2026
8281adc
docs(18-01): add plan SUMMARY
SoulKyu Jul 21, 2026
41923ff
test(18-02): prove finalize() writes cluster-health.json on pipeline …
SoulKyu Jul 21, 2026
c78223c
docs(18-01): append self-check and document REQUIREMENTS.md correction
SoulKyu Jul 21, 2026
2379cc0
docs(18-01): log out-of-scope flaky pkg/session test to deferred-items
SoulKyu Jul 21, 2026
fb36fc3
style(18-02): simplify embedded ObjectMeta selector in ReadPolicyFile…
SoulKyu Jul 21, 2026
b36bf92
docs(18-02): complete query tool read-side exports plan
SoulKyu Jul 21, 2026
9912e13
Merge branch 'worktree-agent-aa828f579e6d29348'
SoulKyu Jul 21, 2026
1956b0b
docs(phase-18): update tracking after wave 1
SoulKyu Jul 21, 2026
f9b3298
test(18-03): add failing tests for list_policies and get_policy
SoulKyu Jul 21, 2026
ee6a6c1
feat(18-03): implement list_policies and get_policy query tools
SoulKyu Jul 21, 2026
7037e07
test(18-03): add failing 4-branch test for get_cluster_health
SoulKyu Jul 21, 2026
1576330
feat(18-03): implement get_cluster_health with D-13 3-way branch
SoulKyu Jul 21, 2026
889d133
test(18-03): add tool-listing and error-text coverage for query tools
SoulKyu Jul 21, 2026
79163a5
style(18-03): simplify embedded ObjectMeta.Name selector
SoulKyu Jul 21, 2026
78ae7c5
docs(18-03): add plan SUMMARY
SoulKyu Jul 21, 2026
0845015
docs(18-03): append self-check and mark QRY-02/QRY-04/QRY-05 complete
SoulKyu Jul 21, 2026
c899244
docs(phase-18): update tracking after wave 2 (QRY-05 kept pending unt…
SoulKyu Jul 21, 2026
9b8db7b
test(18-04): add failing tests for pagination + enum-schema infra
SoulKyu Jul 21, 2026
2b722b0
feat(18-04): implement pagination + enum-schema infra (mustQuerySchem…
SoulKyu Jul 21, 2026
4af5513
test(18-04): add failing tests for get_evidence (QRY-03)
SoulKyu Jul 21, 2026
dd6d39f
feat(18-04): implement get_evidence — paginated pkg/explain evidence …
SoulKyu Jul 21, 2026
3fb35d7
style(18-04): suppress unused-lint on flow-scale pagination consts
SoulKyu Jul 21, 2026
14d5c9c
docs(18-04): complete pagination + get_evidence plan
SoulKyu Jul 21, 2026
8ac783a
docs(phase-18): update tracking after wave 3
SoulKyu Jul 21, 2026
5a7773a
test(18-05): add failing tests for list_dropped_flows (QRY-01)
SoulKyu Jul 21, 2026
9836802
feat(18-05): implement list_dropped_flows composed view (QRY-01)
SoulKyu Jul 21, 2026
18c5ec7
docs(18-05): log pre-existing commonflags.go gofmt debt
SoulKyu Jul 21, 2026
76983cc
test(18-05): final 8-tool integration test + QRY-05 contract (closes …
SoulKyu Jul 21, 2026
f33c8da
style(18-05): remove now-unneeded nolint:unused on flow-scale paginat…
SoulKyu Jul 21, 2026
f9cbaf0
docs(18-05): complete list_dropped_flows + phase-close plan
SoulKyu Jul 21, 2026
6f10b6a
docs(phase-18): update tracking after wave 4
SoulKyu Jul 21, 2026
9bc1baf
docs(18): add code review report
SoulKyu Jul 21, 2026
8ea5a42
fix(18): WR-01 classify DROP_REASON_UNKNOWN evidence samples as unkno…
SoulKyu Jul 21, 2026
afab493
fix(18): WR-02 paginate list_policies and cap get_cluster_health brea…
SoulKyu Jul 21, 2026
794175a
fix(18): WR-03 read policy file once in get_policy to avoid metadata/…
SoulKyu Jul 21, 2026
d733cbb
fix(18): WR-04 add session.DeriveSessionPaths as single source of tru…
SoulKyu Jul 21, 2026
f585d7b
docs(18): add code review fix report
SoulKyu Jul 21, 2026
cf1b081
docs(phase-18): complete phase execution
SoulKyu Jul 21, 2026
a851f7c
docs(phase-18): evolve PROJECT.md after phase completion
SoulKyu Jul 21, 2026
142d94f
docs(19): capture phase context
SoulKyu Jul 21, 2026
8ba7134
docs(state): record phase 19 context session
SoulKyu Jul 21, 2026
b5c618c
docs(19): research phase domain
SoulKyu Jul 21, 2026
a935caf
docs(phase-19): add validation strategy
SoulKyu Jul 21, 2026
1b786fa
docs(19): create phase plan (4 plans, 2 waves)
SoulKyu Jul 21, 2026
356e50c
fix(19): address plan-checker findings (dropclass scope, k8s-verb heu…
SoulKyu Jul 21, 2026
a6ab6ab
fix(19): correct D-10 dropclass scope in context/research/patterns + …
SoulKyu Jul 21, 2026
b8115d9
docs(19): create phase plan
SoulKyu Jul 21, 2026
b2562df
docs(19-03): document MCP server harness config, secrets posture, exe…
SoulKyu Jul 21, 2026
d922eb7
docs(19-03): complete MCP server README section plan
SoulKyu Jul 21, 2026
600b281
docs(19-03): append self-check results to SUMMARY.md
SoulKyu Jul 21, 2026
258decc
feat(19-01): SEC-01 RTA reachability + direct-call-scan audit test
SoulKyu Jul 21, 2026
2648732
feat(19-02): build e2e infra - fake Hubble relay, -race build helper,…
SoulKyu Jul 21, 2026
3c91e0b
chore(19-01): promote golang.org/x/tools to direct test-only dependency
SoulKyu Jul 21, 2026
b6fcb6c
docs(19-01): complete SEC-01 structural readonly audit plan
SoulKyu Jul 21, 2026
cade360
feat(19-02): add graceful e2e lifecycle test + SRV-01 handshake/schem…
SoulKyu Jul 21, 2026
2dbd915
docs(19-02): complete e2e stdio infrastructure + graceful lifecycle plan
SoulKyu Jul 21, 2026
6119fc2
merge(19): plan 19-01 SEC-01 structural readonly audit
SoulKyu Jul 21, 2026
4720df0
merge(19): plan 19-02 e2e stdio infra + graceful lifecycle
SoulKyu Jul 21, 2026
a21b23a
merge(19): plan 19-03 README MCP server section
SoulKyu Jul 21, 2026
4f9348c
docs(phase-19): update tracking after wave 1
SoulKyu Jul 21, 2026
140d25f
feat(19-04): add ungraceful-disconnect e2e variant (SRV-04/D-08/D-09)
SoulKyu Jul 21, 2026
244af33
docs(19-04): complete ungraceful-disconnect e2e variant plan
SoulKyu Jul 21, 2026
bf912fa
docs(19-04): append self-check results to plan summary
SoulKyu Jul 21, 2026
aefad69
merge(19): plan 19-04 ungraceful-disconnect e2e variant
SoulKyu Jul 21, 2026
d52912a
docs(phase-19): update tracking after wave 2
SoulKyu Jul 21, 2026
c729fe4
docs(19): add code review report
SoulKyu Jul 21, 2026
7665120
fix(19): WR-01 replace tautological BFS self-check with real reachabi…
SoulKyu Jul 21, 2026
37dbea4
fix(19): WR-02 extend disallowedFSWrite watchlist with metadata/link/…
SoulKyu Jul 21, 2026
e92669f
fix(19): WR-03 add DeleteCollection/UpdateStatus/ApplyStatus to k8sWr…
SoulKyu Jul 21, 2026
5b5d5c7
fix(19): WR-04 add t.Cleanup to guarantee e2e subprocess termination
SoulKyu Jul 21, 2026
8c9e6f5
fix(19): IN-01 acknowledge func-value call dispatch is unchecked by S…
SoulKyu Jul 21, 2026
f0d706e
fix(19): IN-02 soften README exec-plugin timeout claim, note kubeconf…
SoulKyu Jul 21, 2026
bfe69e7
docs(19): add code review fix report
SoulKyu Jul 21, 2026
99e08f3
docs(19): mark SEC-03 complete in requirements ledger (verification g…
SoulKyu Jul 21, 2026
574b3ac
docs(phase-19): complete phase execution
SoulKyu Jul 21, 2026
8b141ef
docs(phase-19): evolve PROJECT.md after phase completion
SoulKyu Jul 21, 2026
a5ec2ec
docs: capture v1.6 candidate — audit-mode onboarding (include-audit +…
SoulKyu Jul 22, 2026
4df99ee
docs: add v1.6 ideation draft (audit-mode onboarding + cpg-dedicated …
SoulKyu Jul 22, 2026
ba6bd83
docs: add Cilium version compatibility (COMPAT-01/02) to v1.6 ideatio…
SoulKyu Jul 22, 2026
bbce104
fix(deps): bump golang.org/x/text to v0.39.0 (GO-2026-5970)
SoulKyu Jul 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions .planning/PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ A Go CLI tool that connects directly to Hubble Relay via gRPC, observes dropped/

Automatically generate correct CiliumNetworkPolicies from observed Hubble denials so that SREs spend zero time manually writing network policies in default-deny environments.

## Current Milestone: v1.5 MCP Integration

**Goal:** Expose cpg as a readonly MCP server (stdio) so an LLM harness can run a live Hubble capture session, analyze dropped flows, and review generated policies — the LLM brings the intelligence, cpg stays deterministic.

**Target features:**
- `cpg mcp` subcommand — MCP server over stdio transport (the harness spawns the process)
- Session tools: start_session / status / stop_session — background Hubble capture
- Ephemeral session tmpdir (`os.MkdirTemp`, respects `$TMPDIR`): policies YAML + evidence + cluster-health.json written via the existing writers with existing FIFO caps — flat memory profile, no parallel in-memory path
- Query tools: dropped flows (dropclass-classified), generated policies, explain/evidence, cluster health — all implemented as readers over the session tmpdir artifacts
- Readonly guarantee: never mutates the cluster, never writes outside the session tmpdir; tmpdir cleaned at stop_session and server shutdown

## Requirements

### Validated
Expand Down Expand Up @@ -47,17 +58,32 @@ Automatically generate correct CiliumNetworkPolicies from observed Hubble denial
- ✓ Zero reachable vulnerabilities: cilium v1.19.4, x/net v0.55.0, `toolchain go1.25.12` (govulncheck clean in CI) — v1.4
- ✓ Genuine stream failures exit non-zero; LostEvents/PoliciesFailed counted; `--timeout` actually applied — v1.4
- ✓ Policy-ref validation (empty/traversal) on evidence and output writers — v1.4
- ✓ `cpg mcp` protocol-safe stdio skeleton: pure JSON-RPC stdout (IOTransport pre-swap capture + global os.Stdout→stderr backstop), zero tools registered (SRV-02) — v1.5 Phase 16
- ✓ Unified stderr logging: zap + go-sdk logs bridged via zapslog (SRV-03) — v1.5 Phase 16
- ✓ Atomic temp+rename policy writes in `pkg/output/writer.go` (torn-read safe for future concurrent MCP readers, SEC-02) — v1.5 Phase 16
- ✓ `pkg/session` single-slot Manager: `capturing → stopped → gone` lifecycle with retention, idempotent stop, autonomous transition on both crash and clean pipeline exit (SESS-02, SESS-03) — v1.5 Phase 17
- ✓ `start_session`/`get_status`/`stop_session` MCP tools wired into `cpg mcp`, opaque session_id, "session not found or expired" contract with D-02 stopped-session queryability (SESS-01, SESS-04, SESS-06) — v1.5 Phase 17
- ✓ Bounded transport-kill cleanup: `Shutdown()` cancels session + setup contexts, per-step deadlines so one wedged cleanup cannot block process exit, tmpdir removal (SESS-05) — v1.5 Phase 17
- ✓ `list_dropped_flows`: paginated composed view (`samples[]` live from evidence + `aggregates[]` from cluster-health.json with `available_after_stop` marker mid-capture), explicit "sampled/aggregated view, not a raw flow log" description (QRY-01) — v1.5 Phase 18
- ✓ `list_policies` (paginated metadata) + `get_policy` (full CNP YAML + absolute tmpdir path, single atomic read) keyed by namespace+workload (QRY-02) — v1.5 Phase 18
- ✓ `get_evidence`: paginated per-rule attribution byte-identical to `cpg explain --output json` via promoted `pkg/explain` (Filter/Output/Render*/ParsePeerLabel exported, flowsource-style promotion) (QRY-03) — v1.5 Phase 18
- ✓ `get_cluster_health`: typed passthrough via `pkg/hubble.ReadClusterHealth`, 4-state branch (capturing → `available_after_stop`; stopped+absent+no-error → "zero drops"; crash → isError citing pipeline error), remediation URLs intact (QRY-04) — v1.5 Phase 18
- ✓ QRY-05 contract on all 8 tools: `structuredContent`+`outputSchema` (explicit `*jsonschema.Schema` dropclass enum — go-sdk has no enum tags), truthful annotations, taxonomy-teaching descriptions, actionable `isError`; opaque fail-closed cursor; `session.DeriveSessionPaths` single source of truth for tmpdir layout — v1.5 Phase 18
- ✓ SEC-01 structural readonly audit: `TestMCPAuditReadonlyReachability` — SSA/RTA callgraph from `runMCPServer`, BFS-filtered to cpg-owned functions, direct-call scan; K8s write verbs (incl. DeleteCollection/UpdateStatus/ApplyStatus) fail unconditionally, fs writes (incl. Chmod/Truncate/Symlink/…) gated by an exact 5-function allowlist; mutation-tested diagnostic (function symbol + call path) — v1.5 Phase 19
- ✓ SRV-01 + SRV-04: real-subprocess stdio e2e — `-race`-built `cpg mcp` driven over real pipes against an in-process fake Hubble observer relay; graceful lifecycle (initialize → 8-tool handshake/schema/annotation proof → session + 5 query tools → stop → clean exit, byte-pure stdout) and ungraceful-disconnect variant (stdin kill → bounded self-exit, tmpdir removed, relay stream cancelled; 5/5 stability under `-race`) — v1.5 Phase 19
- ✓ SEC-03 README `## MCP Server (cpg mcp)` section: harness `env` block (KUBECONFIG/PATH/TMPDIR + why), secrets posture (L7 paths/labels reach the LLM; headers never captured), exec-credential-plugin non-interactive caveat + credential-persistence note, session model — v1.5 Phase 19

### Active

<!-- Awaiting v1.5 scoping via /gsd-new-milestone. -->
<!-- v1.5 MCP Integration — requirements being defined via /gsd-new-milestone. -->

- _(defined during `/gsd-new-milestone`)_
- _(being defined — see REQUIREMENTS.md once written)_

### Planned

<!-- v1.5 candidates: lint/release debt from the v1.4 audit + feature candidates carried over from earlier deferrals. -->

- [ ] Audit-mode onboarding (default-deny sans casse) + cpg-dedicated skills/agents — v1.6 candidate — **full ideation doc: `.planning/drafts/v1.6-audit-onboarding-and-cpg-agent-tooling.md`** (verified code refs, design, open decision, research questions, candidate REQ IDs AUD-01..04 / SKL-01..05): (a) `--include-audit`/`include_audit` — étendre le filtre de verdict à `Verdict_AUDIT` (client.go:198/209/213, file.go:116, aggregator.go:417 — flows AUDIT portent le drop reason, vérifié parser threefour); (b) bootstrap: génération default-deny CNP (`enableDefaultDeny`, Cilium ≥1.15) + activation PolicyAuditMode per-endpoint namespace-scoped; (c) DÉCISION OUVERTE: mutation pilotée par cpg (flag serveur `cpg mcp --enable-audit-bootstrap`, audit = propriété de session, revert lifecycle-bound via fan-out SESS-05, watcher nouveaux pods, revert-only-ours + TTL, SEC-01 évolue en preuve 2-modes, RBAC pods/exec à documenter) vs CLI-only `cpg audit` (MCP reste readonly pur). Discuté 2026-07-22.
- [ ] Lint debt zero: 16 errcheck + 10 staticcheck SA1019 + drop CI `only-new-issues` flag — v1.5 candidate (LINT-01..03, archived in milestones/v1.4-REQUIREMENTS.md)
- [ ] Release hardening: `release.yml` minimal permissions review, govulncheck job pinning follow-through — v1.5 candidate (RELSEC-01..02)
- [ ] `cpg replay` exit-code parity on truncated input (currently logs Error but exits 0; live stream exits non-zero) — v1.5 candidate (conscious call from PR #16 review)
Expand Down Expand Up @@ -141,14 +167,17 @@ Automatically generate correct CiliumNetworkPolicies from observed Hubble denial
| GitHub Actions pinned to release-tag SHAs (verified via `git ls-remote`) | Mutable tags are a supply-chain risk; one agent-suggested pin pointed at an untagged branch commit — verification against real tags is part of the pin | ✓ Good — shipped v1.4 |
| Stream failure ⇒ non-zero exit (behavior change) | Debug-logged clean exits hid mid-capture relay crashes; operators/CI must see failure | ✓ Good — shipped v1.4; replay truncation exit parity deferred (v1.5 candidate) |
| Milestone executed via direct multi-agent workflow (no gsd plans) | Audit remediation with a complete findings inventory doesn't benefit from per-phase planning ceremony; review→verify→fix→PR pipeline replaces it | ✓ Good — v1.4 shipped same-day; keep gsd plans for feature milestones |
| `mcp.IOTransport` with pre-swap stdout capture, never `mcp.StdioTransport{}` | StdioTransport reads package-level os.Stdout lazily inside Connect() — combined with the D-01 global swap it would bind the JSON-RPC wire to stderr and hang the server | ✓ Good — shipped v1.5 Phase 16; acceptance criteria forbid StdioTransport |
| `go.uber.org/zap/exp` v0.3.0 as separate direct dependency | zapslog is NOT bundled in zap v1.27.1 (independently versioned module) — corrected a locked research claim via operator-approved legitimacy gate | ✓ Good — shipped v1.5 Phase 16 |
| Seam-audit identity assertion guarded against test2json aliasing | `go test -json` makes the testing framework alias os.Stderr = os.Stdout in-process; unguarded global-identity assertions flake by mode, not by race | ✓ Good — root-caused and guarded v1.5 Phase 16 |

## Current State

**Shipped:** v1.0 (2026-03-08), v1.1 (2026-04-24), v1.2 (2026-04-25), v1.3 (2026-04-26), and v1.4 (2026-07-20).

**Codebase:** 10 packages (`pkg/{labels,policy,output,hubble,k8s,dedup,flowsource,evidence,diff,dropclass}` + `cmd/`). **484 tests passing with `-race`** across 10 packages (up from 418 at v1.3 close). CI green and operational for the first time (build + race tests + lint + govulncheck). Deps: cilium v1.19.4, toolchain go1.25.12. Known debt: 26 lint issues (16 errcheck + 10 SA1019) gated by `only-new-issues`, scoped to v1.5. Release-please continues to handle product SemVer tagging.
**Codebase:** 12 packages (`pkg/{labels,policy,output,hubble,k8s,dedup,flowsource,evidence,diff,dropclass,session,explain}` + `cmd/`). **607 tests passing with `-race`** across 12 packages (up from 539 at Phase 17 close). CI green and operational (build + race tests + lint + govulncheck). Deps: cilium v1.19.4, go-sdk v1.6.1, jsonschema-go v0.4.3 (direct since Phase 18), toolchain go1.25.12. Known debt: 26 lint issues (16 errcheck + 10 SA1019) gated by `only-new-issues`, scoped to v1.5; pre-existing `pkg/session` shared-`/tmp` test flake documented in `phases/18-query-tools/deferred-items.md`. Release-please continues to handle product SemVer tagging.

**Next milestone:** v1.5 — awaiting scoping. Candidates: lint debt zero, release hardening, replay exit parity, plus feature candidates in Planned.
**Current milestone:** v1.5 MCP Integration — ALL 4 PHASES COMPLETE (16-19, 2026-07-20 → 2026-07-21). Phase 19 (Security Hardening & End-to-End Validation) closed 2026-07-21: SEC-01 audit (mutation-tested), SRV-01/SRV-04 real-stdio e2e both variants green under `-race`, SEC-03 README harness docs; verified 5/5 (one tracking-only gap closed same-day); code review (0 critical, 4 warnings) fixed same-day (audit self-check de-tautologized, verb/fs watchlists extended, subprocess t.Cleanup kill-guard). All 18 v1.5 requirements complete — milestone ready for `/gsd-complete-milestone`. Tests: 610 across 12 packages (607 at Phase 18 close + audit + 2 e2e variants), all `-race`.

## Evolution

Expand All @@ -168,4 +197,4 @@ This document evolves at phase transitions and milestone boundaries.
4. Update Context with current state

---
*Last updated: 2026-07-20 after v1.4 Audit Fable5 milestone (29 findings landed via PR #16, first green CI, 484 tests).*
*Last updated: 2026-07-21 — v1.5 Phase 19 (Security Hardening & End-to-End Validation) completed, verified 5/5, review findings fixed; all v1.5 phases (16-19) done.*
103 changes: 103 additions & 0 deletions .planning/REQUIREMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Requirements: CPG — Cilium Policy Generator

**Defined:** 2026-07-20
**Milestone:** v1.5 MCP Integration
**Core Value:** Automatically generate correct CiliumNetworkPolicies from observed Hubble denials so that SREs spend zero time manually writing network policies in default-deny environments.

## v1 Requirements

Requirements for milestone v1.5. Each maps to roadmap phases.

### MCP Server Core

- [x] **SRV-01**: SRE can register cpg in an MCP harness (`cpg mcp`, stdio transport) and the initialize handshake succeeds with all tools listed
- [x] **SRV-02**: stdout carries only JSON-RPC frames across a full session lifecycle — enforced by explicit wiring of every stdout-defaulting seam (`PipelineConfig.Stdout`, dry-run `diffOut`, cobra `SilenceUsage`/`SilenceErrors`) and verified by an automated stdout-purity test on an in-memory transport
- [x] **SRV-03**: All server logs go to stderr through the existing zap logger; go-sdk internal logging is bridged into it via `zap/exp/zapslog` (one unified log stream)
- [x] **SRV-04**: An end-to-end stdio integration test drives `initialize → start_session → get_status → each query tool → stop_session → exit` under `-race`, plus an ungraceful-disconnect variant proving port-forward and tmpdir are cleaned up within a bounded deadline

### Session Lifecycle

- [x] **SESS-01**: LLM can `start_session` (namespace / all-namespaces + existing generate filters) and receives an opaque `session_id`; the capture pipeline runs in a background goroutine on a detached cancellable context, writing all artifacts to an ephemeral session tmpdir (`os.MkdirTemp`)
- [x] **SESS-02**: Exactly one concurrent session: a second `start_session` while one is active is rejected with an actionable error naming the active `session_id` — never queued, never silently replaced
- [x] **SESS-03**: LLM can `get_status(session_id)` and gets coarse state — capturing/stopped, elapsed time, artifact file counts on disk (no live pipeline counters in v1.5; documented behavior)
- [x] **SESS-04**: LLM can `stop_session(session_id)`: pipeline context cancelled, artifacts finalized (cluster-health.json, session stats), final summary returned
- [x] **SESS-05**: Transport termination for any reason (stdin EOF, harness crash) triggers full cleanup fan-out — cancel session context, close port-forward, remove tmpdir — each step with a bounded deadline so one wedged cleanup cannot block process exit
- [x] **SESS-06**: Any session-scoped tool called with an unknown, purged, or replaced `session_id` returns a crisp "session not found or expired" error (SEP-2567 handle semantics); a retained STOPPED session stays queryable per D-02 (17-CONTEXT.md), resolving the SESS-06 ↔ QRY-04 (Phase 18) tension

### Query Tools

- [x] **QRY-01**: LLM can `list_dropped_flows(session_id, …filters)` as a composed view over the existing capped evidence samples + aggregate health counts, paginated (`limit`/`cursor`/`total_count`/`has_more`); the tool description explicitly states it is a sampled/aggregated view, not a raw flow log
- [x] **QRY-02**: LLM can `list_policies(session_id)` (metadata: name, workload, direction, rule counts) and `get_policy(session_id, name)` (full CNP YAML + absolute tmpdir path); reads are torn-read safe against the writing pipeline
- [x] **QRY-03**: LLM can `get_evidence(session_id, …filters)` for per-rule flow attribution, reusing the promoted `pkg/explain` JSON renderer verbatim, paginated
- [x] **QRY-04**: LLM can `get_cluster_health(session_id)`: passthrough of cluster-health.json including per-reason Cilium remediation URLs; while the session is still capturing it returns an explicit "available after stop_session" result (not an error)
- [x] **QRY-05**: Every data-returning tool ships `structuredContent` + `outputSchema` (typed Go structs), truthful annotations (`readOnlyHint` etc.), a description that teaches the dropclass taxonomy (policy-actionable vs infra/transient), and `isError` errors with specific actionable text

### Security & Hardening

- [x] **SEC-01**: Readonly guarantee is structural: the MCP composition root registers only read-path handlers — no K8s write verb reachable from `cpg mcp`, no filesystem write outside the session tmpdir — verified by an audit test, re-runnable for every future tool
- [x] **SEC-02**: `pkg/output/writer.go` writes policy YAML atomically (temp+rename, same pattern as the evidence and health writers) — landed as an early standalone change before any query tool reads that directory
- [x] **SEC-03**: README MCP section documents harness configuration (explicit `env` block: `KUBECONFIG`/`PATH`/`TMPDIR` — MCP hosts don't inherit the shell env), the secrets posture (HTTP paths/labels reach the LLM context; headers are never captured), and the exec-credential-plugin non-interactive hang caveat

## v2 Requirements

Deferred to future milestones. Tracked but not in current roadmap.

### MCP Enhancements

- **FLOW-01**: Dedicated flow-sample writer (4th pipeline tee target with its own FIFO cap) for a full-fidelity `list_dropped_flows` — fast-follow if the composed view proves insufficient
- **LIVE-01**: Live mid-session counters (periodic health flush or `*SessionStats` hook on `PipelineConfig`) for `get_status`/`get_cluster_health`
- **REDACT-01**: Best-effort redaction of HTTPPath query strings / token-like values before tool results reach the LLM

### Debt (carried from v1.4 audit)

- **LINT-01..03**: Lint debt zero — 16 errcheck + 10 SA1019 + drop CI `only-new-issues` flag
- **RELSEC-01..02**: Release hardening — `release.yml` minimal permissions, govulncheck job pinning follow-through
- **REPLAY-01**: `cpg replay` exit-code parity on truncated input

## Out of Scope

Explicitly excluded. Documented to prevent scope creep.

| Feature | Reason |
|---------|--------|
| Mutating `apply_policy` tool | Breaks the readonly guarantee outright; no `cpg apply` CLI exists to wrap; structural exclusion is the SEC-01 mechanism |
| MCP resources for policy YAML | Real client-support gap (Claude Code surfaces resources only via manual @mention); plain absolute tmpdir paths are strictly better for stdio same-filesystem deployment |
| Elicitation & sampling | Sampling would be a new transport for the AI-plausibility feature explicitly shelved 2026-04-25; elicitation's statefulness is disproportionate for a single-user local process |
| MCP prompt templates | No validated use case; tool descriptions carry the guidance instead |
| Progress notifications | Correlate to a blocking request; start/poll/stop design has no blocking call to attach them to |
| HTTP/SSE transport + OAuth | Spec scopes authorization to HTTP transports; v1.5 is stdio-only local |
| Multi-session capacity | Single concurrent session by design (flat memory profile); `session_id` schema stays forward-compatible if this ever changes |

## Traceability

Which phases cover which requirements. Updated during roadmap creation.

| Requirement | Phase | Status |
|-------------|-------|--------|
| SRV-01 | Phase 19 | Complete |
| SRV-02 | Phase 16 | Complete |
| SRV-03 | Phase 16 | Complete |
| SRV-04 | Phase 19 | Complete |
| SESS-01 | Phase 17 | Complete |
| SESS-02 | Phase 17 | Complete |
| SESS-03 | Phase 17 | Complete |
| SESS-04 | Phase 17 | Complete |
| SESS-05 | Phase 17 | Complete |
| SESS-06 | Phase 17 | Complete |
| QRY-01 | Phase 18 | Complete |
| QRY-02 | Phase 18 | Complete |
| QRY-03 | Phase 18 | Complete |
| QRY-04 | Phase 18 | Complete |
| QRY-05 | Phase 18 | Complete |
| SEC-01 | Phase 19 | Complete |
| SEC-02 | Phase 16 | Complete |
| SEC-03 | Phase 19 | Complete |

**Coverage:**
- v1 requirements: 18 total
- Mapped to phases: 18
- Unmapped: 0 ✓

---
*Requirements defined: 2026-07-20*
*Last updated: 2026-07-21 after Phase 19 (security-hardening-end-to-end-validation) completion — SRV-01, SRV-04, SEC-01, SEC-03 all complete; all 18 v1.5 requirements closed*
Loading
Loading