Repository navigation
feat(planner): implement phase 3b planner, playbooks, and inverse synthesis - #28
Merged
Merged
Conversation
Establish the candidate-generation prompt engine and response schemas for the Phase 3B remediation pipeline over the closed ActionType enum. The planner needs to generate diverse, viable, and reversible remediation plans from serialized incident diagnostics while strictly adhering to safety invariants and closed action boundaries. This commit provides structured context formatters, system and user prompt builders, JSON schema extraction, response parsing with markdown fence stripping, contract conversion adapters, and the PlannerError error type. Implements build-plan step B3.1.
…lans Implement schema validation with retry <= 2, commit SHA and image digest resolution, cluster workload verification, and graph blast-set validation. Enforce drop, never repair for invalid plans. Implements build-plan step B3.2.
Synthesize and append a compliant, typed NO_ACTION remediation candidate when absent from surviving candidate plans, guaranteeing that baseline non-intervention is always evaluated on tournament ballots. Provides create_no_action_plan and ensure_no_action_candidate in the planner validation engine, integrating with generate_candidates_with_retry, LLMPlanner, and FakePlanner. Introduces the ust plan CLI entrypoint and fixtures/context_bad_deploy.json for checkpoint plan inspection. Implements build-plan step B3.3.
Synthesize inverse remediation plans deterministically for all action types rather than relying on unverified LLM generation, ensuring strict reversibility per ADR-016 and formal invariant K9. Supports rollback roll-forward inversion, scale inverse delta, replica restoration, flag toggles, and config reversion. Implements build-plan step B3.4.
Add deterministic playbook signature synthesis, 1024-dimension OpenRouter embedding client, pgvector cosine similarity retrieval in both Postgres and in-memory stores, and safety-constrained LLM confirmation with rejection of hallucinated IDs. Register CLI subcommands for seed, match, and list, and add seed fixture library. Implements build-plan step B3.5.
…counters Add playbook write-back mechanism (write_playbook and PlaybookWriter) keyed by deterministic incident signature, updating success/failure counters and atomically appending resolved run IDs to evidence_refs. Wire into record_run orchestrator node when prod_outcome is resolved or failed. Expose ust playbook write CLI subcommand and implement in-memory and PostgreSQL store persistence. Implements build-plan step B3.6.
Address all 13 code review findings across standards and spec axes for build-plan step B3 (Planner, Playbooks, and Inverse Synthesis). - Graph: Expose live cluster workload discovery in k8s.py. - Planner API & Orchestrator: Thread playbook candidate into planner prompt candidate generation; retrieve playbook before planning. - Fake Planner: Emit 3 active candidates plus NO_ACTION (N+1 = 4 plans total) per Checkpoint B3 requirements. - Schema Validation: Replace ActionType if-elif ladders with table dispatch; handle typed GraphError in blast set computation. - Inverse Synthesis: Eliminate hardcoded configuration defaults and avoid trusting attached inverse plans; resolve prior state deterministically. - Playbook Write: Prioritize exact signature lookup before playbook ID, and catch PlaybookEmbeddingError explicitly. - Store & CLI: Deduplicate SQL counter increment logic and CLI planner runs; fall back to dependency graph nodes when cluster is unreachable. Implements build-plan step B3.
Reflect verified Checkpoint B3 items for phase 3b. Leave live cluster resolution box unchecked as cluster was offline during local test run. Implements build-plan step B3.
# Conflicts: # CHECKLIST.md # src/understudy/cli.py # src/understudy/common/errors.py # tests/unit/test_cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build-Plan Step Implemented
Checkpoint Execution & Output
ADRs Relied On
Mock Registry Disclosures
Documentation Updates
CHECKLIST.mdticking verified Checkpoint B3 criteria (steps B3.1–B3.6 and verified Checkpoint B3 items).Definition of Done
make checkgreen (ruff, mypy --strict, import-linter, pytest)# MOCKED:marker without a row in docs/MOCKS.md