@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.
- package/LICENSE +201 -0
- package/README.md +275 -0
- package/assets/kkt-readme-modern.png +0 -0
- package/bin/kkt-install.mjs +25 -0
- package/cmd/kkt/main.go +15 -0
- package/go.mod +3 -0
- package/internal/workflow/cli.go +349 -0
- package/internal/workflow/cli_test.go +1266 -0
- package/internal/workflow/guardrails.go +900 -0
- package/internal/workflow/init.go +164 -0
- package/internal/workflow/init_test.go +113 -0
- package/internal/workflow/operations.go +1855 -0
- package/internal/workflow/validation_commands.go +291 -0
- package/internal/workflow/workspace.go +802 -0
- package/internal/workflow/workspace_test.go +285 -0
- package/package.json +45 -0
- package/scripts/install-cli.sh +210 -0
- package/scripts/install.sh +644 -0
- package/skills/kkt/SKILL.md +74 -0
- package/skills/kkt/references/discovery-tooling.md +53 -0
- package/skills/kkt/references/feature-optimization-model.md +120 -0
- package/skills/kkt/references/kkt-kernel.md +58 -0
- package/skills/kkt/references/layered-modeling-methods.md +101 -0
- package/skills/kkt/references/plan-assimilation.md +46 -0
- package/skills/kkt/references/schemas.md +231 -0
- package/skills/kkt/references/state-contract.md +76 -0
- package/skills/kkt-loop/SKILL.md +99 -0
- package/skills/kkt-loop/references/discovery-tooling.md +53 -0
- package/skills/kkt-loop/references/feature-optimization-model.md +120 -0
- package/skills/kkt-loop/references/kkt-kernel.md +58 -0
- package/skills/kkt-loop/references/layered-modeling-methods.md +101 -0
- package/skills/kkt-loop/references/plan-assimilation.md +46 -0
- package/skills/kkt-loop/references/schemas.md +231 -0
- package/skills/kkt-loop/references/state-contract.md +76 -0
- package/skills/kkt-model/SKILL.md +76 -0
- package/skills/kkt-model/references/discovery-tooling.md +53 -0
- package/skills/kkt-model/references/feature-optimization-model.md +120 -0
- package/skills/kkt-model/references/kkt-kernel.md +58 -0
- package/skills/kkt-model/references/layered-modeling-methods.md +101 -0
- package/skills/kkt-model/references/plan-assimilation.md +46 -0
- package/skills/kkt-model/references/schemas.md +231 -0
- package/skills/kkt-model/references/state-contract.md +76 -0
- package/skills/kkt-run/SKILL.md +62 -0
- package/skills/kkt-run/references/discovery-tooling.md +53 -0
- package/skills/kkt-run/references/feature-optimization-model.md +120 -0
- package/skills/kkt-run/references/kkt-kernel.md +58 -0
- package/skills/kkt-run/references/layered-modeling-methods.md +101 -0
- package/skills/kkt-run/references/plan-assimilation.md +46 -0
- package/skills/kkt-run/references/schemas.md +231 -0
- package/skills/kkt-run/references/state-contract.md +76 -0
|
@@ -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
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# KKT State Contract
|
|
2
|
+
|
|
3
|
+
Use this when KKT state must survive across layers, turns, or coding agents. The goal is not to store everything in YAML; it is to make handoff state explicit, inspectable, and hard to confuse.
|
|
4
|
+
|
|
5
|
+
Load `schemas.md` only when a full `kkt.yaml`, layer output, or `guardrails.json` shape is needed.
|
|
6
|
+
|
|
7
|
+
## Persistence Tiers
|
|
8
|
+
|
|
9
|
+
| Tier | Skill | Durable files | Use when |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| Plan | `kkt` | none by default; optional `.kkt/kkt.yaml` | ordinary work where Markdown artifacts would be overhead. |
|
|
12
|
+
| Model | `kkt-model` | `.kkt/model/<slug>/kkt.yaml`, `intent.md`, `discovery.md`, `model.md`, `guardrails.json` | durable model or decision brief before execution. |
|
|
13
|
+
| Run | `kkt-run` | `.kkt/run/<slug>/kkt.yaml`, imported artifacts, `guardrails.json`, `plan.md`, `progress.md`, `evidence.md`, `notes.md` | completed model should be implemented now without loop state. |
|
|
14
|
+
| Loop | `kkt-loop` | `.kkt/loop/<slug>/kkt.yaml`, layer artifacts, `guardrails.json`, `plan.md`, `progress.md`, `evidence.md`, `notes.md`, `events.jsonl` | long-running or resumable execution. |
|
|
15
|
+
|
|
16
|
+
Durable `.kkt/` paths are rooted at the nearest Git/worktree root. Outside Git, the CLI falls back to the current directory.
|
|
17
|
+
|
|
18
|
+
## CLI Ownership
|
|
19
|
+
|
|
20
|
+
The `kkt` CLI is the canonical mutation interface for KKT state. Skills should use CLI commands for workspace creation, state reads, artifact recording, guardrails, approvals, progress, evidence, validation, and completion.
|
|
21
|
+
|
|
22
|
+
- `kkt.yaml`: current status, active layer, method choices, decisions, artifact references, approvals, stop conditions, and summaries.
|
|
23
|
+
- Markdown artifacts: detailed intent, discovery, modeling rationale, execution plan, progress, evidence, and notes.
|
|
24
|
+
- `guardrails.json`: modeled constraints, allowed paths, blocked paths, validation requirements, and drift policy.
|
|
25
|
+
- `events.jsonl`: loop-only append history for task transitions, evidence, approvals, blockers, validation, and completion.
|
|
26
|
+
|
|
27
|
+
Do not hand-edit `kkt.yaml` as the primary workflow operation when a CLI command exists.
|
|
28
|
+
|
|
29
|
+
## Useful Commands
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
kkt start plan "<request>"
|
|
33
|
+
kkt start model "<request>"
|
|
34
|
+
kkt run from-model [model-workspace]
|
|
35
|
+
kkt start run "<request>"
|
|
36
|
+
kkt start loop "<request>"
|
|
37
|
+
kkt intent|discovery|model --method <method> "<layer output>"
|
|
38
|
+
kkt guardrails show|set|validate
|
|
39
|
+
kkt judge --checkpoint model-ready|pre-mutation|continuation|finalize --json
|
|
40
|
+
kkt validate [--run]
|
|
41
|
+
kkt done
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Artifact Boundaries
|
|
45
|
+
|
|
46
|
+
- `intent.md`: user meaning, success, scope, examples, priority signals, explicit constraints, unresolved meaning questions.
|
|
47
|
+
- `discovery.md`: files, symbols, components, workflows, discovered constraints, validation paths, coupling, evidence, confidence, unknowns.
|
|
48
|
+
- `model.md`: method selection, objective, constraints, decision variables, candidates, feasibility, selected plan, binding constraints, validation plan, sensitivity, execution implications, residual risk.
|
|
49
|
+
- `guardrails.json`: machine-readable drift contract; run and loop execution must not proceed when modeled constraints or allowed paths are empty.
|
|
50
|
+
- `plan.md`: execution tasks, acceptance criteria, validation plan, evidence required, stop conditions, continuation policy.
|
|
51
|
+
- `progress.md`: work log, progress narrative, blocker notes.
|
|
52
|
+
- `evidence.md`: validation map, command outputs, artifacts, final certificate.
|
|
53
|
+
- `notes.md`: observations, assumptions, open questions, deferred ideas.
|
|
54
|
+
- `events.jsonl`: append-only loop event history, not a competing source of truth for current state.
|
|
55
|
+
|
|
56
|
+
When `guardrails.json` lists `validation.required_commands`, run or loop workspaces must use `kkt validate --run` to record deterministic command proof. `kkt evidence` records narrative evidence and criterion mapping only.
|
|
57
|
+
|
|
58
|
+
## Handoff Rules
|
|
59
|
+
|
|
60
|
+
1. Read `kkt.yaml` first when it exists.
|
|
61
|
+
2. Read the prior layer's artifact before acting.
|
|
62
|
+
3. Update only the current layer unless repairing a stale reference.
|
|
63
|
+
4. Append decisions instead of overwriting prior rationale.
|
|
64
|
+
5. Set `next_layer_readiness` before handing off.
|
|
65
|
+
6. Record blockers with the smallest user or system change that would unblock.
|
|
66
|
+
7. If new evidence invalidates an earlier layer, mark the active layer blocked and re-open the earlier layer instead of silently continuing.
|
|
67
|
+
|
|
68
|
+
## Judge Checkpoints
|
|
69
|
+
|
|
70
|
+
- `model-ready`: before implementation; blocks run/loop execution when model, guardrails, or allowed path bounds are incomplete.
|
|
71
|
+
- `pre-mutation`: before edits or side effects; blocks when approval is missing or explicitly blocked paths changed; unrelated dirty paths outside allowed bounds are ignored.
|
|
72
|
+
- `continuation`: before loop continuation; blocks on active stop conditions or replay drift.
|
|
73
|
+
- `finalize`: before `kkt done`; blocks when validation fails or explicitly blocked paths changed; unrelated dirty paths outside allowed bounds are ignored.
|
|
74
|
+
- `pre-tool`, `post-tool`, `pre-compact`, `post-compact`: portable hook names for adapters; enforce explicit blocked paths without requiring a clean worktree.
|
|
75
|
+
|
|
76
|
+
Treat `block` as a hard stop. Treat `warn` as a contract-quality issue to repair before risky work. Treat `allow` as permission to continue to the next workflow step.
|