@dannylee1020/kkt 0.5.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 (50) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +275 -0
  3. package/assets/kkt-readme-modern.png +0 -0
  4. package/bin/kkt-install.mjs +25 -0
  5. package/cmd/kkt/main.go +15 -0
  6. package/go.mod +3 -0
  7. package/internal/workflow/cli.go +349 -0
  8. package/internal/workflow/cli_test.go +1266 -0
  9. package/internal/workflow/guardrails.go +900 -0
  10. package/internal/workflow/init.go +164 -0
  11. package/internal/workflow/init_test.go +113 -0
  12. package/internal/workflow/operations.go +1855 -0
  13. package/internal/workflow/validation_commands.go +291 -0
  14. package/internal/workflow/workspace.go +802 -0
  15. package/internal/workflow/workspace_test.go +285 -0
  16. package/package.json +45 -0
  17. package/scripts/install-cli.sh +210 -0
  18. package/scripts/install.sh +644 -0
  19. package/skills/kkt/SKILL.md +74 -0
  20. package/skills/kkt/references/discovery-tooling.md +53 -0
  21. package/skills/kkt/references/feature-optimization-model.md +120 -0
  22. package/skills/kkt/references/kkt-kernel.md +58 -0
  23. package/skills/kkt/references/layered-modeling-methods.md +101 -0
  24. package/skills/kkt/references/plan-assimilation.md +46 -0
  25. package/skills/kkt/references/schemas.md +231 -0
  26. package/skills/kkt/references/state-contract.md +76 -0
  27. package/skills/kkt-loop/SKILL.md +99 -0
  28. package/skills/kkt-loop/references/discovery-tooling.md +53 -0
  29. package/skills/kkt-loop/references/feature-optimization-model.md +120 -0
  30. package/skills/kkt-loop/references/kkt-kernel.md +58 -0
  31. package/skills/kkt-loop/references/layered-modeling-methods.md +101 -0
  32. package/skills/kkt-loop/references/plan-assimilation.md +46 -0
  33. package/skills/kkt-loop/references/schemas.md +231 -0
  34. package/skills/kkt-loop/references/state-contract.md +76 -0
  35. package/skills/kkt-model/SKILL.md +76 -0
  36. package/skills/kkt-model/references/discovery-tooling.md +53 -0
  37. package/skills/kkt-model/references/feature-optimization-model.md +120 -0
  38. package/skills/kkt-model/references/kkt-kernel.md +58 -0
  39. package/skills/kkt-model/references/layered-modeling-methods.md +101 -0
  40. package/skills/kkt-model/references/plan-assimilation.md +46 -0
  41. package/skills/kkt-model/references/schemas.md +231 -0
  42. package/skills/kkt-model/references/state-contract.md +76 -0
  43. package/skills/kkt-run/SKILL.md +62 -0
  44. package/skills/kkt-run/references/discovery-tooling.md +53 -0
  45. package/skills/kkt-run/references/feature-optimization-model.md +120 -0
  46. package/skills/kkt-run/references/kkt-kernel.md +58 -0
  47. package/skills/kkt-run/references/layered-modeling-methods.md +101 -0
  48. package/skills/kkt-run/references/plan-assimilation.md +46 -0
  49. package/skills/kkt-run/references/schemas.md +231 -0
  50. package/skills/kkt-run/references/state-contract.md +76 -0
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: kkt
3
+ description: Constrained optimization workflow for ordinary coding requests. Use when a coding agent should capture user meaning, discover repo constraints and validation paths, build a mathematical-style optimization model, derive an execution contract, select a feasible implementation plan, execute the change, validate with evidence, and finish with a constraint audit.
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # KKT
8
+
9
+ Use this skill for ordinary coding work that needs stricter planning than default plan mode. Apply constrained optimization as a discipline: choose the best feasible implementation given what must stay true.
10
+
11
+ Read `references/kkt-kernel.md` before acting. Read `references/feature-optimization-model.md` when building the compact model. Read `references/state-contract.md` only when durable state is useful. Read `references/plan-assimilation.md` only when prior plan text exists. Read `references/discovery-tooling.md` during non-trivial discovery or structural search. Read `references/layered-modeling-methods.md` only when method selection beyond the plan profile is needed. Read `references/schemas.md` only when a full copyable state, guardrail, or layer-output shape is needed.
12
+
13
+ ## Core Rule
14
+
15
+ Intake before modeling. Discovery before asking for repo facts. Model before editing. Show the final modeling result and get explicit user approval before implementation. Finish only with validation evidence or an explicit blocker.
16
+
17
+ ## CLI-First Workflow
18
+
19
+ Use the `kkt` CLI whenever durable state is useful. The skill owns reasoning policy; the CLI owns state creation, reads, mutation, approval, evidence, validation, and completion.
20
+
21
+ ```text
22
+ kkt start plan "<user request>"
23
+ kkt status [--json]
24
+ kkt next
25
+ kkt model "<objective_function, files_to_modify, constraint_functions, decision_variables, validation_proof, and selected compact model>"
26
+ kkt approve "<approved scope>"
27
+ kkt evidence "<validation evidence>"
28
+ kkt validate [--run]
29
+ kkt done
30
+ ```
31
+
32
+ If `kkt` is missing and durable state is needed, stop and ask the user to install or upgrade KKT. Do not hand-write replacement state. Use `kkt validate --run` when guardrails define required commands; `kkt evidence` alone is narrative evidence, not command proof.
33
+
34
+ ## Workflow
35
+
36
+ 1. Capture intent: user goal, desired behavior, user-visible success, scope boundary, examples, priority signals, and explicit user constraints.
37
+ 2. If prior plan text exists, assimilate it as untrusted scaffold: extract signals, classify claims, verify discoverable facts, and keep unverified claims as assumptions or candidates.
38
+ 3. Apply the owner-decision filter before asking: inspect discoverable facts locally, assume low-risk reversible defaults, ask only for owner decisions, and stop for blocking unknowns.
39
+ 4. Inspect relevant code, docs, tests, config, schemas, routes, UI, infra, logs, or issues before forming the model. Use `rg` directly for broad text and file discovery, `ast-grep` directly for structural search when syntax matters, `git` for repository state, and language-native commands when they provide stronger evidence.
40
+ 5. Separate explicit user statements, prior-plan assumptions, discovered facts, inferred constraints, assumptions, unknowns, and owner decisions.
41
+ 6. Build a compact model: objective function, system state, files to modify, constraint functions, decision variables, hard/soft constraints, feasible plans, selected plan, binding constraints, and sensitivity.
42
+ 7. Derive the execution contract: acceptance criteria, validation plan, evidence required, and stop conditions.
43
+ 8. Reject infeasible plans, then choose the best feasible plan by this order: user request, correctness/security/data/public contracts, blast radius, existing architecture, maintainability, validation clarity.
44
+ 9. Show the final modeling result and wait for approval before editing.
45
+ 10. Execute the approved plan with focused edits, then validate with evidence and finish with a constraint audit.
46
+
47
+ ## Output Discipline
48
+
49
+ For small tasks, keep the model brief and avoid durable state unless it helps. For durable plan-tier state, use project-root `.kkt/kkt.yaml` through `kkt` commands; do not hand-edit `kkt.yaml` as the primary workflow operation. Load full schemas only when writing or auditing durable state. Switch to `$kkt-model` for deeper non-mutating modeling, `$kkt-run` to implement a completed model with guardrails, or `$kkt-loop` for long-running continuation.
50
+
51
+ Before implementation, expose a compact optimized plan: objective function, known constraints, files to modify, constraint functions, decision variables, selected plan, rejected alternatives, binding constraints, validation proof plan, and residual risk. Keep formal method names hidden unless they explain a material tradeoff.
52
+
53
+ Final audit shape:
54
+
55
+ ```text
56
+ Objective: satisfied / not satisfied
57
+ Hard constraints: satisfied / violations listed
58
+ Binding constraints: respected / changed
59
+ Validation evidence: commands, checks, artifacts, or reason validation was not possible
60
+ Residual risk: concise notes
61
+ ```
62
+
63
+ ## Stop Conditions
64
+
65
+ Stop and ask before continuing when no feasible plan satisfies hard constraints, approval is missing, destructive action is required, credentials/secrets/external access/paid services are required, feasible plans differ mainly by product intent, or continuing expands scope.
66
+
67
+ ## Do Not
68
+
69
+ - Do not use fake numeric scores for subjective qualities.
70
+ - Do not treat the first plausible plan as selected before feasibility checks.
71
+ - Do not edit before the final modeling result is approved.
72
+ - Do not silently follow existing patterns that appear wrong; flag them.
73
+ - Do not make broad refactors unless required by the model.
74
+ - Do not finish without validation evidence or an explicit validation limitation.
@@ -0,0 +1,53 @@
1
+ # Discovery Tooling
2
+
3
+ Use this during discovery to prove repo facts accurately with direct agent tool calls.
4
+
5
+ ## Rule
6
+
7
+ Use the lightest reliable tool that can prove the needed fact. Start with `rg` for broad text/file discovery, then use `ast-grep` for structural questions. Prefer exact, inspectable evidence over broad inference. Record important negative searches when they shape the model.
8
+
9
+ Discovery tools are read-only during planning and modeling. Rewrite, update, or codegen modes belong to approved execution.
10
+
11
+ Do not route discovery through `kkt` CLI commands. The CLI owns deterministic workflow state; the agent owns repo inspection.
12
+
13
+ ## Tool Ladder
14
+
15
+ - Core: `git` for repository boundary, tracked files, status, diffs, history, and changed-path scope.
16
+ - Core: `rg` for strings, filenames, config keys, docs, tests, shell scripts, and negative searches.
17
+ - Core structural: `ast-grep` for syntax-aware search when call sites, imports, handlers, declarations, components, error handling, or API shapes matter.
18
+ - Optional: `fd`, `ctags`, `tokei`, `scc`, and repo-native commands when they add confidence.
19
+ - Language-native: `go list`, `go test`, `cargo metadata`, `npm` scripts, `tsc`, `pytest --collect-only`, Gradle, Maven, Rails, Django, or equivalent repo tooling.
20
+
21
+ ## Selection Rules
22
+
23
+ - Use `git ls-files` or `rg --files` before broad recursive scans.
24
+ - Use `rg` for text and file discovery.
25
+ - Use `ast-grep` when syntax matters and text evidence would be noisy or ambiguous.
26
+ - Use language-native tooling for package boundaries, route maps, type contracts, test commands, or generated-code boundaries.
27
+ - If `ast-grep` is unavailable, record the setup gap and fall back only as far as the evidence supports. Do not claim AST-level certainty from text search alone.
28
+
29
+ ## Ast-Grep Policy
30
+
31
+ Allowed during discovery:
32
+
33
+ ```text
34
+ ast-grep --pattern '<pattern>' --lang <language>
35
+ ast-grep --pattern '<pattern>' --lang <language> --json
36
+ ast-grep scan --config sgconfig.yml --json
37
+ ```
38
+
39
+ Forbidden during planning or modeling:
40
+
41
+ ```text
42
+ ast-grep --rewrite ...
43
+ ast-grep scan --update-all
44
+ ast-grep scan --interactive
45
+ ```
46
+
47
+ Rewrites require the execution layer, approval, and normal KKT guardrails.
48
+
49
+ ## Guardrails
50
+
51
+ - Do not add a KKT discovery command as a substitute for direct `rg` and `ast-grep` use.
52
+ - Do not claim structural certainty from plain text search when AST search or language-native tools are needed and available.
53
+ - Do not use generated, vendored, or build-output files as primary evidence unless the task explicitly targets them.
@@ -0,0 +1,120 @@
1
+ # Feature Optimization Model
2
+
3
+ Use this reference when building or reviewing a KKT model. Keep the active model compact; load `schemas.md` only when a full copyable shape is needed.
4
+
5
+ ## Intake
6
+
7
+ Start with user meaning, then let discovery fill in repo facts.
8
+
9
+ Capture:
10
+
11
+ - user goal;
12
+ - desired behavior;
13
+ - user-visible success;
14
+ - scope boundary;
15
+ - examples or counterexamples, if supplied;
16
+ - priority signals;
17
+ - explicit user constraints;
18
+ - execution mode: `implement`, `model_only`, `run`, or `loop`.
19
+
20
+ When prior plan text exists, read `plan-assimilation.md` first. Preserve the user's original request, classify prior-plan claims, verify discoverable facts, and keep unverified claims as assumptions or candidates.
21
+
22
+ Do not ask the user for repo facts that local discovery can verify. Use the question filter in `kkt-kernel.md`.
23
+
24
+ ## Model Shape
25
+
26
+ Treat the task as:
27
+
28
+ ```text
29
+ choose implementation decisions
30
+ that best satisfy the user's objective
31
+ subject to project, architecture, security, data, UI, infrastructure, validation, and scope constraints
32
+ ```
33
+
34
+ Build the model around:
35
+
36
+ - `objective_function`: ordered terms used to compare feasible plans.
37
+ - `system_state`: inspected facts plus labeled assumptions.
38
+ - `decision_variables`: choices the agent may make, each with an allowed domain.
39
+ - `files_to_modify`: expected files, modules, APIs, workflows, migrations, docs, or operational surfaces.
40
+ - `constraint_contract`: hard predicates for feasibility and soft preferences for ranking.
41
+ - `feasible_region`: candidate plans that satisfy all hard constraints.
42
+ - `selected_plan`: chosen feasible plan and why it wins.
43
+ - `binding_constraints`: active constraints that shape the selected plan.
44
+ - `validation_proof`: commands, checks, artifacts, or explicit limitations needed before completion.
45
+
46
+ ## Method Profiles
47
+
48
+ - Plan profile (`kkt`): compact intake, local discovery, hard-constraint feasibility, lexicographic ranking, approval before edits, validation certificate.
49
+ - Deep profile (`kkt-model`): layered method selection, candidate comparison, binding constraints, sensitivity, guardrail variables, and user tradeoff questions when needed.
50
+ - Run profile (`kkt-run`): import a completed model, validate guardrails, run deterministic checkpoints, execute only the selected plan.
51
+ - Loop profile (`kkt-loop`): durable model plus continuation state, task/criteria tracking, evidence-backed continuation, and re-optimization only on material new evidence.
52
+
53
+ Read `layered-modeling-methods.md` for deep or loop modeling choices. Do not expose formal method names in ordinary `$kkt` output unless they explain a material tradeoff.
54
+
55
+ ## Decision Variables
56
+
57
+ Decision variables are implementation choices with explicit domains. Common variables include:
58
+
59
+ - files or modules to modify;
60
+ - endpoint, CLI, schema, or event shape;
61
+ - data storage or migration strategy;
62
+ - state ownership;
63
+ - UI placement;
64
+ - validation strategy;
65
+ - compatibility strategy;
66
+ - dependency strategy;
67
+ - rollout or fallback strategy.
68
+
69
+ Poor: `database: decide storage`
70
+
71
+ Better: `persistence_strategy: add nullable fields to existing table`, with allowed and disallowed options recorded.
72
+
73
+ ## Constraints
74
+
75
+ Hard constraints make a plan infeasible when violated:
76
+
77
+ - explicit user constraints and non-goals;
78
+ - correctness, security, privacy, and data integrity;
79
+ - public API or persisted-data compatibility;
80
+ - framework, runtime, infrastructure, or deployment limits;
81
+ - no destructive action, credentials, paid services, or external side effects without approval.
82
+
83
+ Soft constraints rank feasible plans:
84
+
85
+ - minimal diff and blast radius;
86
+ - existing style and architecture fit;
87
+ - readability, maintainability, reversibility, and validation clarity.
88
+
89
+ Use lexicographic priority instead of fake numeric scores:
90
+
91
+ 1. Satisfy the user request.
92
+ 2. Preserve correctness, security, data integrity, and public contracts.
93
+ 3. Minimize blast radius.
94
+ 4. Match existing architecture and conventions.
95
+ 5. Improve maintainability where cheap.
96
+ 6. Prefer validation clarity over elegance.
97
+
98
+ ## Selected Plan Contract
99
+
100
+ An approval-ready plan or selected model must include:
101
+
102
+ - objective function;
103
+ - known constraints by source: explicit, discovered, inferred, assumptions;
104
+ - decision variables and chosen values;
105
+ - affected files or surfaces;
106
+ - feasible and rejected candidates;
107
+ - selected plan;
108
+ - binding constraints;
109
+ - validation plan and proof required;
110
+ - execution implications;
111
+ - guardrail variables when durable run or loop state will enforce scope;
112
+ - residual risk.
113
+
114
+ If a field is irrelevant, say `none` or give a short reason. Do not hide constraints inside prose.
115
+
116
+ ## Re-Optimization
117
+
118
+ Re-optimize when new evidence changes system state, feasible region, hard constraints, selected-plan binding constraints, selected decisions, or validation feasibility.
119
+
120
+ Do not re-optimize merely because another plan feels more elegant.
@@ -0,0 +1,58 @@
1
+ # KKT Kernel
2
+
3
+ This is the mandatory operating contract for every KKT skill. It should stay short enough to read on every invocation.
4
+
5
+ ## Invariants
6
+
7
+ - Capture user meaning before modeling.
8
+ - Discover repo facts before asking the user for file names, routes, schemas, tests, commands, or config.
9
+ - Treat prior host-agent or plan-mode output as scaffold, not truth.
10
+ - Check hard constraints before comparing plans.
11
+ - Pick the smallest feasible plan that satisfies the user's objective and protects existing contracts.
12
+ - Get approval before mutation when the skill is in a planning, model, run, or loop gate.
13
+ - Validate with evidence before completion.
14
+ - Re-optimize only when new evidence changes facts, constraints, feasible plans, selected decisions, or validation feasibility.
15
+
16
+ ## Question Filter
17
+
18
+ Before asking, classify the unknown:
19
+
20
+ - `discoverable_fact`: inspect the repo, docs, tests, config, schemas, routes, logs, or issues.
21
+ - `reversible_default`: choose the conservative low-risk default and label it as an assumption.
22
+ - `owner_decision`: ask when the answer changes product behavior, scope, risk, approval, destructive actions, external dependencies, credentials, paid services, or execution mode.
23
+ - `blocking_unknown`: stop when no conservative default keeps the hard constraints feasible.
24
+
25
+ ## Core Model
26
+
27
+ Every KKT model or approval-ready plan needs:
28
+
29
+ - objective function;
30
+ - known constraints, with explicit, discovered, inferred, and assumed sources separated;
31
+ - decision variables with allowed domains and chosen values;
32
+ - files, modules, APIs, workflows, docs, migrations, or operational surfaces expected to change;
33
+ - candidate plans, with infeasible options rejected before comparison;
34
+ - selected feasible plan and why it dominates alternatives;
35
+ - binding constraints that shaped the selected plan;
36
+ - validation plan and evidence required;
37
+ - residual risk.
38
+
39
+ ## Discovery Rules
40
+
41
+ - Use `git` for repository boundaries, status, diffs, history, and changed-path scope.
42
+ - Use `rg` immediately for broad text and file discovery.
43
+ - Use `ast-grep` immediately when syntax matters and text search would be ambiguous.
44
+ - Use language-native tools when they reveal package boundaries, types, route maps, generated-code boundaries, or test contracts.
45
+ - If `ast-grep` is unavailable in an already-installed environment, record the setup gap and do not claim AST-level certainty from text search alone.
46
+ - Record important negative searches when they shape the selected plan.
47
+
48
+ ## Completion Certificate
49
+
50
+ Finish with:
51
+
52
+ ```text
53
+ Objective: satisfied / not satisfied
54
+ Hard constraints: satisfied / violations listed
55
+ Binding constraints: respected / changed
56
+ Validation evidence: commands, checks, artifacts, or reason validation was not possible
57
+ Residual risk: concise notes
58
+ ```
@@ -0,0 +1,101 @@
1
+ # Layered Modeling Methods
2
+
3
+ Use this catalog for `$kkt-model`, `$kkt-loop`, or unusually complex `$kkt` work. Do not apply every method to every request.
4
+
5
+ Every layer must produce enough output for the next layer to continue without hidden session context. Load `schemas.md` only when a copyable layer-contract shape is needed.
6
+
7
+ ## Profiles
8
+
9
+ ### Plan Profile
10
+
11
+ Use for ordinary `$kkt` implementation work:
12
+
13
+ - compact intent frame;
14
+ - local discovery with `git`, `rg`, and structural search when useful;
15
+ - hard-constraint feasibility gate;
16
+ - lexicographic ranking of feasible plans;
17
+ - approval before implementation;
18
+ - validation certificate.
19
+
20
+ Keep formal method names out of normal output unless they explain a material tradeoff.
21
+
22
+ ### Deep Profile
23
+
24
+ Use for `$kkt-model` and complex planning:
25
+
26
+ - ask targeted owner-decision questions after quick inspection;
27
+ - build a discovery map with evidence confidence;
28
+ - select and record one intent, discovery, and modeling method;
29
+ - compare candidate models and reject infeasible options first;
30
+ - explain binding constraints, sensitivity, and execution implications.
31
+
32
+ Fallback set: `goal_anti_goal`, `traceability_matrix`, `lexicographic`. Use it when specialized methods do not materially improve reliability.
33
+
34
+ ### Loop Profile
35
+
36
+ Use for `$kkt-loop`:
37
+
38
+ - front-load deeper modeling before execution;
39
+ - write durable state through the CLI;
40
+ - require approval before workspace execution or goal launch;
41
+ - continue from CLI state and evidence;
42
+ - re-optimize only when new evidence changes feasibility, constraints, objective fit, or validation feasibility.
43
+
44
+ ## Intent Methods
45
+
46
+ Purpose: turn rough user input into a meaning frame discovery can test against the repo.
47
+
48
+ - Goal / anti-goal: desired outcome and explicit non-goals.
49
+ - WHY / HOW ladder: find the real objective; ask HOW only when it clarifies desired behavior.
50
+ - Obstacle questions: identify interpretations that would be unacceptable, too broad, or aimed at the wrong workflow.
51
+ - Example / counterexample: use when examples would prevent a materially wrong interpretation.
52
+ - Tradeoff prompt: ask only when competing priorities change the model.
53
+ - Owner-decision filter: classify possible questions as discoverable facts, reversible defaults, owner decisions, or blocking unknowns.
54
+
55
+ Question budget:
56
+
57
+ - clear task: 0-1 questions;
58
+ - medium ambiguity: 1-3 targeted questions;
59
+ - large, high-risk, or ambiguous work: short Socratic pass after quick inspection.
60
+
61
+ ## Discovery Methods
62
+
63
+ Purpose: convert intent into inspected facts and traceable system context.
64
+
65
+ - Naive/local discovery: direct `git`, `rg`, file reads, and tests for obvious locality.
66
+ - Traceability matrix: map intent to files, modules, routes, schemas, tests, docs, config, and runtime boundaries.
67
+ - Coupling map: identify callers, public interfaces, state owners, side effects, and downstream contracts.
68
+ - DSM-lite: use a small dependency matrix when several modules/workflows make blast radius unclear.
69
+ - Structural discovery: use `ast-grep` when syntax matters.
70
+
71
+ Discovery output must distinguish observed facts, inferred constraints, assumptions, unknowns, validation paths, unavailable preferred tools, fallback notes, and important negative searches.
72
+
73
+ ## Modeling Methods
74
+
75
+ Always apply the hard-constraint feasibility gate before ranking.
76
+
77
+ | Decision shape | Method | Use when |
78
+ | --- | --- | --- |
79
+ | Normal implementation choice | Lexicographic ranking | Priorities are clear and correctness / safety / contracts outrank lower preferences. |
80
+ | Branching facts determine feasibility | Decision tree | Repo facts eliminate paths. |
81
+ | Staged transition or rollout | Shortest path | There are real states, transitions, costs, and forbidden states. |
82
+ | Comparable feasible options | Ordinal MCDA | Alternatives differ across blast radius, maintainability, validation clarity, speed, or reversibility. |
83
+ | User priorities are unclear | AHP-style pairwise questions | Risk, speed, migration, or architecture preference determines the choice. |
84
+ | No feasible option clearly dominates | Outranking shortlist | Architecture choices need a defensible shortlist rather than a forced winner. |
85
+
86
+ Do not invent numeric scores for subjective criteria. Prefer ordinal labels unless the user supplies actual weights.
87
+
88
+ ## Execution Methods
89
+
90
+ - Smallest feasible step: edit only the surfaces selected by the model.
91
+ - Contract-preserving change: preserve public APIs, data contracts, security boundaries, and user non-goals unless approval changed them.
92
+ - Re-optimization trigger: stop when new evidence changes feasibility, selected decisions, or validation feasibility.
93
+
94
+ ## Validation Methods
95
+
96
+ - Acceptance-criteria map: map each criterion to evidence.
97
+ - Hard-constraint audit: explicitly check feasibility constraints.
98
+ - Binding-constraint audit: verify the selected plan still respects the constraints that shaped it.
99
+ - Residual-risk register: list claims not proven by validation.
100
+
101
+ Final validation must include commands, checks, artifacts, unavailable checks, residual risk, and a completion certificate.
@@ -0,0 +1,46 @@
1
+ # Plan Assimilation
2
+
3
+ Use this only when KKT is invoked after a host agent or default plan mode has already produced a plan.
4
+
5
+ ## Rule
6
+
7
+ Prior plan text is an untrusted scaffold. Consume whatever exists, extract useful signals, verify discoverable claims, and rebuild the KKT model from KKT's own intent, discovery, constraints, decision variables, selected plan, and validation proof.
8
+
9
+ Do not ask the user to reformat prior plan output.
10
+
11
+ ## Checklist
12
+
13
+ 1. Preserve the original user request and explicit user constraints.
14
+ 2. Extract signals from the prior plan:
15
+ - proposed goal and steps;
16
+ - suspected files, modules, APIs, schemas, routes, tests, docs, or operational surfaces;
17
+ - stated or implied constraints;
18
+ - validation suggestions;
19
+ - open questions and risk signals.
20
+ 3. Classify each signal:
21
+ - `explicit_user_input`;
22
+ - `plan_assumption`;
23
+ - `discoverable_fact`;
24
+ - `candidate_decision`;
25
+ - `candidate_constraint`;
26
+ - `candidate_validation`;
27
+ - `unknown_or_ambiguous`.
28
+ 4. Verify discoverable facts through repo inspection before using them as facts.
29
+ 5. Keep unverified claims as assumptions or candidates, never as discovered facts.
30
+ 6. Add missing KKT structure: objective, constraints, decision variables, candidate feasibility, selected plan, binding constraints, guardrails, and validation proof.
31
+ 7. Reject or revise the prior plan when it violates hard constraints, skips cheaper feasible paths, or names validation that does not exist.
32
+
33
+ ## Anti-Anchoring Checks
34
+
35
+ - Which prior-plan claims were verified?
36
+ - Which claims remain assumptions?
37
+ - Which constraints or decision variables did the plan miss?
38
+ - What smaller or safer feasible plan exists?
39
+ - What validation proof would certify the selected plan?
40
+
41
+ ## Guardrails
42
+
43
+ - Do not enforce a schema on host plan-mode output.
44
+ - Do not treat prior-plan file names, routes, commands, or architecture claims as facts before inspection.
45
+ - Do not rubber-stamp the prior plan as the selected KKT plan.
46
+ - Do not ask the user for repo facts the discovery layer can verify.
@@ -0,0 +1,231 @@
1
+ # KKT Schemas
2
+
3
+ Optional reference for copyable shapes. Do not load this on every invocation; use it when writing or auditing durable KKT state, layer contracts, plan-assimilation output, discovery tooling output, or guardrails.
4
+
5
+ ## Layer Contract
6
+
7
+ ```yaml
8
+ layer_contract:
9
+ layer:
10
+ status: pending | complete | blocked
11
+ method_used:
12
+ inputs_consumed:
13
+ outputs:
14
+ decisions:
15
+ assumptions:
16
+ unknowns:
17
+ artifact_refs:
18
+ next_layer_readiness:
19
+ ```
20
+
21
+ ## Optimized Plan
22
+
23
+ ```yaml
24
+ optimized_plan:
25
+ objective_function:
26
+ known_constraints:
27
+ explicit:
28
+ discovered:
29
+ inferred:
30
+ assumptions:
31
+ decision_variables:
32
+ - name:
33
+ allowed_domain:
34
+ chosen_value:
35
+ rationale:
36
+ files_to_modify:
37
+ - path_or_surface:
38
+ change_type:
39
+ rationale:
40
+ constraint_functions:
41
+ hard:
42
+ - name:
43
+ predicate:
44
+ source:
45
+ status:
46
+ soft:
47
+ - name:
48
+ preference:
49
+ source:
50
+ status:
51
+ candidates:
52
+ feasible:
53
+ rejected:
54
+ selected_plan:
55
+ binding_constraints:
56
+ validation_plan:
57
+ validation_proof:
58
+ execution_implications:
59
+ guardrail_variables:
60
+ residual_risk:
61
+ ```
62
+
63
+ ## Plan Assimilation
64
+
65
+ ```yaml
66
+ plan_assimilation:
67
+ source:
68
+ original_request:
69
+ prior_plan_text:
70
+ extracted_signals:
71
+ proposed_goal:
72
+ proposed_steps:
73
+ suspected_surfaces:
74
+ implied_constraints:
75
+ validation_suggestions:
76
+ open_questions:
77
+ risk_signals:
78
+ classification:
79
+ explicit_user_input:
80
+ plan_assumption:
81
+ discoverable_fact:
82
+ candidate_decision:
83
+ candidate_constraint:
84
+ candidate_validation:
85
+ unknown_or_ambiguous:
86
+ verification:
87
+ verified_facts:
88
+ rejected_claims:
89
+ assumptions_carried:
90
+ searches_or_evidence:
91
+ next_layer_readiness:
92
+ ```
93
+
94
+ ## Discovery Tooling
95
+
96
+ ```yaml
97
+ discovery_tooling:
98
+ available:
99
+ core:
100
+ preferred:
101
+ optional:
102
+ language_native:
103
+ unavailable:
104
+ searches:
105
+ - tool:
106
+ purpose:
107
+ query_or_pattern:
108
+ paths:
109
+ result_summary:
110
+ confidence:
111
+ negative_searches:
112
+ - tool:
113
+ query_or_pattern:
114
+ paths:
115
+ implication:
116
+ fallback_notes:
117
+ ```
118
+
119
+ ## Execution Contract
120
+
121
+ ```yaml
122
+ execution_contract:
123
+ acceptance_criteria:
124
+ validation_plan:
125
+ evidence_required:
126
+ stop_conditions:
127
+ continuation_policy:
128
+ ```
129
+
130
+ ## kkt.yaml
131
+
132
+ ```yaml
133
+ schema_version: 1
134
+ workspace_type: plan | model | run | loop
135
+ profile: plan | model | run | loop
136
+ status: initialized | modeling | approved | executing | validating | complete | blocked
137
+ active_layer: intent | discovery | modeling | execution | validation
138
+ layers:
139
+ intent:
140
+ status: pending | complete | blocked
141
+ method: pending | goal_anti_goal | why_how | obstacle_questions | pairwise_questions
142
+ summary: ""
143
+ artifact: intent.md
144
+ discovery:
145
+ status: pending | complete | blocked
146
+ method: pending | naive | traceability_matrix | coupling_map | dsm_lite
147
+ summary: ""
148
+ artifact: discovery.md
149
+ modeling:
150
+ status: pending | complete | blocked
151
+ method: pending | lexicographic | decision_tree | shortest_path | ordinal_mcda | pairwise_ahp | outranking
152
+ summary: ""
153
+ artifact: model.md
154
+ execution:
155
+ status: pending | complete | blocked
156
+ method: pending | smallest_feasible_step | contract_preserving_change
157
+ summary: ""
158
+ artifact: plan.md
159
+ validation:
160
+ status: pending | complete | blocked
161
+ method: pending | acceptance_map | hard_constraint_audit | binding_constraint_audit
162
+ summary: ""
163
+ artifact: evidence.md
164
+ method_invocations: []
165
+ decision_log: []
166
+ planning_contract:
167
+ objective_function:
168
+ files_to_modify:
169
+ constraint_functions:
170
+ decision_variables:
171
+ validation_proof:
172
+ artifact_refs:
173
+ approval:
174
+ required: true
175
+ status: not_required | pending | approved | rejected
176
+ approved_scope:
177
+ stop_conditions: []
178
+ loop_state:
179
+ current_task: ""
180
+ tasks: []
181
+ acceptance_criteria: []
182
+ evidence: []
183
+ stop_conditions: []
184
+ ```
185
+
186
+ ## guardrails.json
187
+
188
+ ```json
189
+ {
190
+ "schema_version": 1,
191
+ "source": {
192
+ "workspace_type": "model",
193
+ "workspace": ".kkt/model/<slug>",
194
+ "request": ""
195
+ },
196
+ "constraints": [
197
+ {
198
+ "id": "stable-contract",
199
+ "kind": "architecture",
200
+ "severity": "block",
201
+ "statement": "Preserve the selected model's public contract.",
202
+ "allowed_paths": ["internal/workflow/**"],
203
+ "blocked_paths": ["dist/**"]
204
+ }
205
+ ],
206
+ "change_bounds": {
207
+ "allowed_paths": ["internal/workflow/**"],
208
+ "blocked_paths": [".git/**", ".env*", "dist/**"],
209
+ "require_explicit_approval_outside_allowed": true
210
+ },
211
+ "workflow": {
212
+ "execution_mode": "run",
213
+ "requires_approval_before_mutation": true,
214
+ "requires_validation_before_done": true
215
+ },
216
+ "validation": {
217
+ "acceptance_criteria": [],
218
+ "required_commands": [],
219
+ "evidence_required": ["scope audit confirms only allowed paths changed"]
220
+ },
221
+ "drift_policy": {
222
+ "block_on": [
223
+ "missing_approval",
224
+ "empty_allowed_paths",
225
+ "changed_blocked_path",
226
+ "validation_failed"
227
+ ],
228
+ "warn_on": []
229
+ }
230
+ }
231
+ ```