@hassangameryt/freeflow 0.7.1 → 0.7.2

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 (122) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.cursor-plugin/plugin.json +1 -1
  5. package/README.md +28 -23
  6. package/capabilities/cognitive-routing/SKILL.md +94 -311
  7. package/command-surface.json +7 -1
  8. package/gemini-extension.json +1 -1
  9. package/package.json +4 -4
  10. package/pi-extension/dist/cognitive-routing-v2/budget.js +42 -0
  11. package/pi-extension/dist/cognitive-routing-v2/config.js +120 -0
  12. package/pi-extension/dist/cognitive-routing-v2/projection.js +321 -0
  13. package/pi-extension/dist/cognitive-routing-v2/render.js +231 -0
  14. package/pi-extension/dist/cognitive-routing-v2/runtime.js +1585 -0
  15. package/pi-extension/dist/cognitive-routing-v2/schemas.js +107 -0
  16. package/pi-extension/dist/cognitive-routing-v2/state.js +612 -0
  17. package/pi-extension/dist/cognitive-routing-v2/tools.js +91 -0
  18. package/pi-extension/dist/cognitive-routing-v2/types.js +44 -0
  19. package/pi-extension/dist/freeflow-context/tool.js +5 -0
  20. package/pi-extension/dist/index.js +279 -624
  21. package/pi-extension/dist/runtime/runtime-context.js +63 -13
  22. package/pi-extension/dist/session-sources/events.js +195 -0
  23. package/pi-extension/dist/session-sources/read-only-session.js +148 -0
  24. package/pi-extension/dist/session-sources/sources.js +233 -0
  25. package/pi-extension/dist/settings/settings-ui.js +44 -117
  26. package/pi-extension/src/cognitive-routing-v2/budget.ts +42 -0
  27. package/pi-extension/src/cognitive-routing-v2/config.ts +143 -0
  28. package/pi-extension/src/cognitive-routing-v2/projection.ts +365 -0
  29. package/pi-extension/src/cognitive-routing-v2/render.ts +256 -0
  30. package/pi-extension/src/cognitive-routing-v2/runtime.ts +1634 -0
  31. package/pi-extension/src/cognitive-routing-v2/schemas.ts +109 -0
  32. package/pi-extension/src/cognitive-routing-v2/state.ts +622 -0
  33. package/pi-extension/src/cognitive-routing-v2/tools.ts +93 -0
  34. package/pi-extension/src/cognitive-routing-v2/types.ts +222 -0
  35. package/pi-extension/src/freeflow-context/tool.ts +5 -0
  36. package/pi-extension/src/index.ts +285 -674
  37. package/pi-extension/src/runtime/runtime-context.ts +75 -14
  38. package/pi-extension/src/session-sources/events.ts +208 -0
  39. package/pi-extension/src/session-sources/read-only-session.ts +170 -0
  40. package/pi-extension/src/session-sources/sources.ts +263 -0
  41. package/pi-extension/src/settings/settings-ui.ts +54 -131
  42. package/pi-extension/tests/cognitive-routing-v2/communication.test.js +484 -0
  43. package/pi-extension/tests/cognitive-routing-v2/compaction-input.test.js +183 -0
  44. package/pi-extension/tests/cognitive-routing-v2/native.test.js +441 -0
  45. package/pi-extension/tests/cognitive-routing-v2/performance.test.js +87 -0
  46. package/pi-extension/tests/cognitive-routing-v2/persistence.test.js +245 -0
  47. package/pi-extension/tests/cognitive-routing-v2/projection.test.js +241 -0
  48. package/pi-extension/tests/cognitive-routing-v2/recovery.test.js +236 -0
  49. package/pi-extension/tests/cognitive-routing-v2/render.test.js +230 -0
  50. package/pi-extension/tests/cognitive-routing-v2/runtime.test.js +153 -0
  51. package/pi-extension/tests/cognitive-routing-v2/stabilization.test.js +521 -0
  52. package/pi-extension/tests/cognitive-routing-v2/state.test.js +275 -0
  53. package/pi-extension/tests/context-virtualization/extension.test.js +16 -0
  54. package/pi-extension/tests/fixtures/routing-native.js +188 -0
  55. package/pi-extension/tests/integration/mode-free-core.test.js +3 -2
  56. package/pi-extension/tests/integration/pi-extension.test.js +154 -37
  57. package/pi-extension/tests/integration/prompt-architecture.test.js +87 -6
  58. package/pi-extension/tests/integration/unaffected-regressions.test.js +77 -10
  59. package/plugin.json +1 -1
  60. package/runtime/prompts/cognitive-routing.md +4 -5
  61. package/runtime/prompts/core.md +51 -45
  62. package/runtime/prompts/interaction-contract.md +5 -5
  63. package/skills/action-selection/SKILL.md +57 -97
  64. package/skills/design-for-depth/SKILL.md +58 -193
  65. package/skills/design-for-depth/references/implementation-decisions.md +76 -0
  66. package/skills/diagnose-failure/SKILL.md +64 -196
  67. package/skills/discuss/SKILL.md +64 -123
  68. package/skills/discuss/references/discussion-continuity.md +7 -3
  69. package/skills/execute-work/SKILL.md +69 -88
  70. package/skills/execute-work/references/execute-work-edges.md +9 -3
  71. package/skills/handoff/SKILL.md +44 -54
  72. package/skills/handoff/references/handoff-templates.md +15 -6
  73. package/skills/review-artifact/SKILL.md +80 -127
  74. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +1 -1
  75. package/skills/review-work/SKILL.md +65 -115
  76. package/skills/review-work/references/independent-work-reviewer-contract.md +1 -1
  77. package/skills/simplify-code/SKILL.md +47 -100
  78. package/skills/track-work/SKILL.md +128 -119
  79. package/skills/track-work/references/working-record-format.md +14 -2
  80. package/skills/verify-work/SKILL.md +58 -62
  81. package/skills/verify-work/references/integration-evidence.md +4 -2
  82. package/skills/verify-work/references/test-design.md +89 -0
  83. package/skills/workflow/SKILL.md +73 -119
  84. package/skills/write-plan/SKILL.md +46 -77
  85. package/skills/write-plan/references/plan-shapes.md +5 -5
  86. package/skills/write-spec/SKILL.md +51 -63
  87. package/skills/write-spec/references/artifact-standards.md +2 -2
  88. package/skills/write-spec/references/decision-records.md +3 -2
  89. package/skills/write-spec/references/spec-shapes.md +15 -0
  90. package/pi-extension/dist/cognitive-routing/commands.js +0 -96
  91. package/pi-extension/dist/cognitive-routing/config.js +0 -232
  92. package/pi-extension/dist/cognitive-routing/controller.js +0 -1292
  93. package/pi-extension/dist/cognitive-routing/history.js +0 -451
  94. package/pi-extension/dist/cognitive-routing/host.js +0 -188
  95. package/pi-extension/dist/cognitive-routing/pi-routing-session.js +0 -414
  96. package/pi-extension/dist/cognitive-routing/pi-session-control.js +0 -320
  97. package/pi-extension/dist/cognitive-routing/runtime.js +0 -43
  98. package/pi-extension/dist/cognitive-routing/tool.js +0 -212
  99. package/pi-extension/dist/cognitive-routing/types.js +0 -6
  100. package/pi-extension/src/cognitive-routing/commands.ts +0 -129
  101. package/pi-extension/src/cognitive-routing/config.ts +0 -303
  102. package/pi-extension/src/cognitive-routing/controller.ts +0 -1628
  103. package/pi-extension/src/cognitive-routing/history.ts +0 -650
  104. package/pi-extension/src/cognitive-routing/host.ts +0 -266
  105. package/pi-extension/src/cognitive-routing/pi-routing-session.ts +0 -538
  106. package/pi-extension/src/cognitive-routing/pi-session-control.ts +0 -444
  107. package/pi-extension/src/cognitive-routing/runtime.ts +0 -57
  108. package/pi-extension/src/cognitive-routing/tool.ts +0 -273
  109. package/pi-extension/src/cognitive-routing/types.ts +0 -89
  110. package/pi-extension/tests/cognitive-routing/commands.test.js +0 -134
  111. package/pi-extension/tests/cognitive-routing/controller.test.js +0 -1128
  112. package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +0 -1142
  113. package/pi-extension/tests/cognitive-routing/history.test.js +0 -274
  114. package/pi-extension/tests/cognitive-routing/host-identity.test.js +0 -63
  115. package/pi-extension/tests/cognitive-routing/pi-normal-lifecycle.test.js +0 -434
  116. package/pi-extension/tests/cognitive-routing/pi-session-control.test.js +0 -174
  117. package/pi-extension/tests/cognitive-routing/pi-session-history.test.js +0 -91
  118. package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +0 -279
  119. package/pi-extension/tests/cognitive-routing/tool.test.js +0 -230
  120. package/skills/tdd/SKILL.md +0 -143
  121. package/skills/tdd/references/test-design.md +0 -96
  122. /package/pi-extension/tests/{cognitive-routing/host-fixture.js → fixtures/pi-host.js} +0 -0
@@ -8,7 +8,7 @@ import { promisify } from "node:util";
8
8
 
9
9
  import freeflowExtension from "../../dist/index.js";
10
10
  import { resetSessionOverrides, setSessionCoreOverride } from "../../dist/runtime/runtime-context.js";
11
- import { PIFLOW_HOST } from "../cognitive-routing/host-fixture.js";
11
+ import { PIFLOW_HOST } from "../fixtures/pi-host.js";
12
12
 
13
13
  const execFileAsync = promisify(execFile);
14
14
 
@@ -51,12 +51,12 @@ function context(cwd, options = {}) {
51
51
  };
52
52
  }
53
53
 
54
- function loadExtension() {
54
+ function loadExtension(host = PIFLOW_HOST, runtimeApi = {}) {
55
55
  const handlers = new Map();
56
56
  const commands = [];
57
57
  const tools = [];
58
58
  const pi = {
59
- host: PIFLOW_HOST,
59
+ host,
60
60
  registerTool(tool) {
61
61
  tools.push(tool);
62
62
  },
@@ -77,6 +77,7 @@ function loadExtension() {
77
77
  },
78
78
  setActiveTools() {},
79
79
  };
80
+ Object.assign(pi, runtimeApi);
80
81
  freeflowExtension(pi);
81
82
  return { handlers, commands, pi };
82
83
  }
@@ -263,14 +264,22 @@ test("Cognitive Routing preset cancellation preserves the previous repository va
263
264
  cognitiveRouting: {
264
265
  enabled: true,
265
266
  profiles: {
266
- standard: { provider: "test", model: "model-a", thinkingLevel: "low" },
267
- reasoning: { provider: "test", model: "model-b", thinkingLevel: "high" },
267
+ coordinator: { provider: "test", model: "model-a", thinking: "low" },
268
+ executor: { provider: "test", model: "model-b", thinking: "high" },
268
269
  },
269
270
  },
270
271
  });
271
272
  const original = await readFile(join(cwd, ".freeflow/config.json"), "utf8");
272
273
  try {
273
- const { commands } = loadExtension();
274
+ const { commands } = loadExtension(
275
+ {},
276
+ {
277
+ setModel() {
278
+ return true;
279
+ },
280
+ setThinkingLevel() {},
281
+ },
282
+ );
274
283
  const command = freeflowCommand(commands);
275
284
  const settings = context(cwd, { isIdle: () => true });
276
285
  settings.modelRegistry = cognitiveRoutingModelRegistry();
@@ -300,13 +309,21 @@ test("Cognitive Routing settings refresh after enabling the capability", async (
300
309
  cognitiveRouting: {
301
310
  enabled: false,
302
311
  profiles: {
303
- standard: { provider: "test", model: "model-a", thinkingLevel: "low" },
304
- reasoning: { provider: "test", model: "model-b", thinkingLevel: "high" },
312
+ coordinator: { provider: "test", model: "model-a", thinking: "low" },
313
+ executor: { provider: "test", model: "model-b", thinking: "high" },
305
314
  },
306
315
  },
307
316
  });
308
317
  try {
309
- const { commands } = loadExtension();
318
+ const { commands } = loadExtension(
319
+ {},
320
+ {
321
+ setModel() {
322
+ return true;
323
+ },
324
+ setThinkingLevel() {},
325
+ },
326
+ );
310
327
  const command = freeflowCommand(commands);
311
328
  const settings = context(cwd, { isIdle: () => true });
312
329
  settings.modelRegistry = cognitiveRoutingModelRegistry();
@@ -322,13 +339,63 @@ test("Cognitive Routing settings refresh after enabling the capability", async (
322
339
  component.handleInput("\r");
323
340
  await component.waitForWrites();
324
341
  component.handleInput("\u001b");
325
- assert.match(component.render(120).join("\n"), /Cognitive Routing\s+enabled \(5\) configured/);
342
+ assert.match(component.render(120).join("\n"), /Cognitive Routing\s+enabled \(4\) configured/);
343
+ component.handleInput("\u001b");
344
+ return result;
345
+ };
346
+ await command.definition.handler("settings repo", settings);
347
+ const saved = JSON.parse(await readFile(join(cwd, ".freeflow/config.json"), "utf8"));
348
+ assert.equal(saved.cognitiveRouting.enabled, true);
349
+ assert.equal(settings.reloads.length, 1);
350
+ } finally {
351
+ await rm(cwd, { recursive: true, force: true });
352
+ }
353
+ });
354
+
355
+ test("Cognitive Routing settings can disable projection without disabling routing", async () => {
356
+ const cwd = await configuredRepo({
357
+ cognitiveRouting: {
358
+ enabled: true,
359
+ projection: true,
360
+ profiles: {
361
+ coordinator: { provider: "test", model: "model-a", thinking: "low" },
362
+ executor: { provider: "test", model: "model-b", thinking: "high" },
363
+ },
364
+ },
365
+ });
366
+ try {
367
+ const { commands } = loadExtension(
368
+ {},
369
+ {
370
+ setModel() {
371
+ return true;
372
+ },
373
+ setThinkingLevel() {},
374
+ },
375
+ );
376
+ const command = freeflowCommand(commands);
377
+ const settings = context(cwd, { isIdle: () => true });
378
+ settings.modelRegistry = cognitiveRoutingModelRegistry();
379
+ settings.ui.custom = async (factory) => {
380
+ let result;
381
+ const component = factory({ requestRender() {} }, theme, {}, (value) => {
382
+ result = value;
383
+ });
384
+ component.handleInput("\u001b[B");
385
+ component.handleInput("\r");
386
+ for (let index = 0; index < 3; index += 1) component.handleInput("\u001b[B");
387
+ component.handleInput("\r");
388
+ component.handleInput("\u001b[B");
389
+ component.handleInput("\r");
390
+ await component.waitForWrites();
391
+ component.handleInput("\u001b");
326
392
  component.handleInput("\u001b");
327
393
  return result;
328
394
  };
329
395
  await command.definition.handler("settings repo", settings);
330
396
  const saved = JSON.parse(await readFile(join(cwd, ".freeflow/config.json"), "utf8"));
331
397
  assert.equal(saved.cognitiveRouting.enabled, true);
398
+ assert.equal(saved.cognitiveRouting.projection ?? false, false);
332
399
  assert.equal(settings.reloads.length, 1);
333
400
  } finally {
334
401
  await rm(cwd, { recursive: true, force: true });
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "freeflow",
4
- "version": "0.7.1",
4
+ "version": "0.7.2",
5
5
  "description": "Feedback-based control system for coding agents.",
6
6
  "author": {
7
7
  "name": "Hassan Mohiddin"
@@ -1,10 +1,9 @@
1
1
  ## Cognitive Routing Cue
2
2
 
3
- Cognitive Routing changes compute only; it never changes Workflow ownership or authority. `Control` and `Profile` in the latest Runtime State report current compute state, not Yield, Delegate, `ACT_BOUNDED`, or boundary state. A Runtime State refresh is host context, not a user interruption, and does not end an active route or `ACT_BOUNDED` scope unless contradicted. Recover routing state from visible records; never infer `Boundary state: NONE`.
3
+ Cognitive Routing uses Coordinator and Executor in one agent/session to improve quality, continuity, responsiveness, and total cost together. Coordinator guides and assesses Executor's bounded work.
4
4
 
5
- - **Manual:** the held profile runs the ordinary unsplit Workflow; do not request switching.
6
- - **Automatic:** each user interaction begins in Reasoning, which owns conversational and user-facing analysis, discussion, decisions, questions, assessment, and reporting. This work needs no route marker.
5
+ Use the latest Runtime State for control, profile, and current responsibility. Under Manual or inactive routing, stop applying the automatic split and follow ordinary Workflow.
7
6
 
8
- If the full Cognitive Routing skill is not visible, read it before interpreting or acting on the request. Make that read the only environment call; it is not a route transition. If the read fails or is unavailable, stop and report missing context.
7
+ Before relying on automatic routing, read the complete cognitive-routing skill if its body is absent. This bootstrap read is the only environment call in that response. If unavailable, stop and report the missing method. Reload it after context loss before applying remembered routing rules.
9
8
 
10
- Once visible, follow the skill's boundary-first execution model. Automatic Standard only executes active Yield or Delegate contracts; at every return condition it writes `YIELD HANDOFF` or `RETURN` and switches to Reasoning. Standard never handles substantive user-facing interaction.
9
+ When projection is on, Executor must project every completed skill and instructional-reference read, including this bootstrap read. Follow the skill for tool access, execution, evidence, handoffs, context cleaning, and recovery.
@@ -1,84 +1,90 @@
1
1
  # Freeflow Stable Guidance
2
2
 
3
- Freeflow is a workflow layer for one active coding agent. These instructions establish the minimum language and first cues needed before deeper methods are discovered. They do not override user instructions, repository policy, host safety, or tool permissions, and they do not create authority.
3
+ Freeflow is a workflow layer for one active coding agent. It does not override user instructions, repository policy, host safety, or tool permissions, and it creates no authority. Core guidance and the separately editable Interaction Contract are delivered together whenever Freeflow is enabled.
4
4
 
5
- Use the latest Freeflow Runtime State supplied by the host. It refreshes at session start, after context loss, or when displayed state changes; otherwise the existing snapshot may remain visible without re-emission. Treat earlier state as history and use only the Freeflow guidance, skills, and tools exposed for this request.
6
-
7
- Freeflow's core guidance and the separate Interaction Contract are always delivered together whenever Freeflow is enabled. The Interaction Contract remains a separately editable prompt fragment; it is not an optional capability.
5
+ Use the latest Freeflow Runtime State and only the guidance, skills, and tools exposed for this request. State refreshes at session start, after context loss, or when displayed facts change; an unchanged snapshot may remain visible. Earlier snapshots are history.
8
6
 
9
7
  ## Shared Terms
10
8
 
11
9
  - **Authority envelope:** the requested outcome, permitted effects, covered active evidence generation, and stop condition established by a direct request or still-valid approval.
12
- - **Passive observation:** inspecting existing evidence or sources without exercising target behavior or intentionally changing task state.
13
- - **Active evidence generation:** exercising target behavior to produce new evidence, including tests, reproductions, benchmarks, prototypes, instrumentation, and runtime probes.
14
- - **Mutation or delivery:** changing the repository, durable task or session, or external state.
15
- - **Bounded activity:** one coherent unit of discussion, preservation, execution, evidence, or judgment that ends in one assessable result.
16
- - **Current owner:** the one Freeflow activity responsible for carrying the current bounded activity to an assessable result. Methods, lenses, references, domain guidance, tools, and reviewers may support it without taking ownership automatically.
17
- - **Slice:** one coherent outcome that may span several bounded activities and methods. Track Work gives it durable identity when task memory is needed.
18
- - **Evidence boundary:** the strongest claim current direct evidence can support. It is established by the observing mechanism, not by intent, authority, or confidence.
19
- - **Self-review:** after fresh evidence initially supports a bounded result, the producing agent silently checks that supported state once for alignment, correctness, suitability, and unnecessary complexity before accepting or reusing it. A corrected state receives only the affected recheck. Self-review is not independent review.
20
- - **Independent review:** separately selected judgment from a context that did not produce the reviewed state. It reports without editing and does not authorize correction.
21
- - **Checkpoint:** a deliberately selected boundary that dependent work must not cross unresolved. It may require a decision, review, preservation action, or delivery result. An activity ending or work pausing does not create one automatically.
22
- - **Re-entry:** return only to the narrowest current owner whose responsibility changed, preserving valid work, decisions, and evidence.
23
- - **Supported Exit:** the justified end of the current Interaction Lifecycle: an evidence-supported answer, wait, pause, handoff, deferment, controlled boundary, stop, or completion, with material limits and unresolved state made explicit.
24
-
25
- One Interaction Lifecycle may contain several bounded activities. A Slice may span several bounded activities and methods. Each bounded activity has one current owner and may contain several environment interactions.
10
+ - **Work agreement:** the user-established outcome, scope, and user-facing return condition. It may include figuring out the approach; it is not a mandatory artifact or another authority source.
11
+ - **Passive observation:** inspecting existing sources or evidence without exercising target behavior or intentionally changing task state.
12
+ - **Active evidence generation:** exercising behavior to produce evidence, including tests, reproductions, benchmarks, prototypes, instrumentation, and runtime probes.
13
+ - **Mutation or delivery:** changing repository, durable task/session, or external state.
14
+ - **Bounded activity:** coherent discussion, preservation, execution, evidence, or judgment ending in one assessable result.
15
+ - **Current owner:** the one activity responsible for that result. Supporting methods, lenses, tools, references, and reviewers do not automatically take ownership.
16
+ - **Slice:** one coherent outcome that may span several bounded activities. Track Work gives it durable identity when task memory is needed.
17
+ - **Evidence boundary:** the strongest claim directly supported by the observing mechanism—not by intent, authority, or confidence.
18
+ - **Self-review:** the producer silently checks an initially supported result for alignment, correctness, suitability, and unnecessary complexity before accepting or reusing it. Corrected work receives only the affected recheck.
19
+ - **Independent review:** separately selected judgment from a context that did not produce the reviewed state. It reports without editing or authorizing correction.
20
+ - **Checkpoint:** a deliberately selected boundary that dependent work must not cross unresolved. An activity ending or pausing does not create one automatically.
21
+ - **Re-entry:** return only to the owner whose responsibility changed, preserving unaffected work, decisions, and evidence.
22
+ - **Supported Exit:** an answer, wait, pause, handoff, deferment, controlled boundary, stop, or completion justified by current evidence and authority.
23
+
24
+ ## Load The Selected Method
25
+
26
+ Before applying a selected skill, read its current body when its exact method is absent from context. Descriptions select methods; they do not replace them. Reuse still-visible guidance instead of rereading each turn.
27
+
28
+ Read dependencies at their declared conditions, not the whole catalogue. Loading guidance neither changes ownership nor authorizes effects. Required reads still follow active capability bootstrap and routing rules.
26
29
 
27
30
  ## Recover After Context Loss
28
31
 
29
- After compaction, summarization, clear, resume, session navigation, handoff, or uncertain continuity, pause task-directed work. Until recovery is complete, use the environment only for bounded reads needed to recover current state.
30
-
31
- Treat summaries, records, prior skill reads, transition results, and historical messages as memory. They may preserve still-valid context and authority, but they do not create or widen authority, prove live state, keep a method active, or settle current ownership. Current user direction, live source truth, and the latest Freeflow Runtime State take precedence when they conflict.
32
+ After compaction, context-replacing summarization, clear, session resume/navigation, transfer into another context, or uncertain continuity, pause task work. Use only necessary recovery reads until state is coherent; recovery is not a bypass of authority, capabilities, or host permissions.
32
33
 
33
- Before continuing:
34
+ - Require the latest Freeflow Runtime State; do not infer missing or contradictory state.
35
+ - Reload relevant active capability methods before relying on them.
36
+ - When a Working Record exists or may exist, load Track Work and read the complete `full` record. A summary or `resume` projection is not full recovery. Stop affected work if recovery is incomplete or unavailable.
37
+ - Identify the current owner and reload its method if absent. Use Workflow when authority, ownership, or continuation is unclear.
38
+ - Reconcile the agreement, current work, dependencies, evidence limits, partial effects, and stop conditions with current user direction and relevant live sources.
34
39
 
35
- - Require the latest Freeflow Runtime State. If it is absent, stale, conflicting, or inconsistent with the exposed skills and tools, do not infer it.
36
- - Read each relevant active capability skill before relying on or changing that capability.
37
- - When ongoing work has or may have a Working Record, read Track Work and recover its `resume` view before task work.
38
- - Identify the current owner. Read Workflow when authority, ownership, route, or continuity is unclear, then read the owner’s skill when its exact method is absent.
39
- - Recover the current Slice, route or execution boundary, blockers, checkpoints, evidence boundary, partial effects, and stop condition without inventing missing state.
40
-
41
- Resume only when authority, ownership, current work, route, evidence requirements, and the stop condition are coherent. Otherwise inspect the missing source, ask, defer, or stop.
40
+ Summaries and records may preserve evidence of prior approval; check that the approval still applies. They do not create authority, prove live state, or keep an absent method active. Current user direction, live source truth, and current Runtime State take precedence over conflicting memory. With intact context, use bounded record reads only when needed; another turn or ordinary pause is not context loss.
42
41
 
43
42
  ## Three Nested Loops
44
43
 
45
- One user-facing **Interaction Lifecycle** runs from Entry to a Feedback Loop when needed to a Supported Exit. A later user turn or new evidence begins another lifecycle.
44
+ The **Interaction Lifecycle** runs from Entry through the Feedback Loop when needed to a Supported Exit. A later user turn or new evidence begins another lifecycle. One lifecycle may contain several bounded activities.
46
45
 
47
46
  For each bounded activity, the **Feedback Loop** is:
48
47
 
49
48
  ```text
50
- Orient
51
- -> choose one current owner
52
- -> use the current owner
53
- -> gather or produce evidence
54
- -> determine what the result proves
49
+ Orient or reconstruct state
50
+ -> choose or retain the current owner
51
+ -> establish the required result and a supported approach
52
+ -> apply its method and gather or produce evidence
53
+ -> determine what the evidence supports
55
54
  -> self-review the supported result
56
55
  -> continue, correct, re-enter, ask, defer, stop, or exit
57
56
  ```
58
57
 
59
- When the current owner must touch the environment, the **Environment Interaction Loop** is:
58
+ Reuse settled understanding. For concrete work, resolve what is required and how to produce the next result before production changes; these need not be separate investigations or user turns. A learning action answers its bounded question, not an expanding production ambition.
59
+
60
+ When the owner needs the environment, the **Environment Interaction Loop** is:
60
61
 
61
62
  ```text
62
63
  Need evidence or a covered effect
63
- -> select and bound one environment action
64
- -> choose the tool
64
+ -> reuse adequate context or identify what is missing
65
+ -> select and bound the action and tool
65
66
  -> execute once
66
- -> observe
67
- -> identify what changed
68
- -> reconcile observation residency when available
67
+ -> observe what changed
68
+ -> apply active capability guidance where relevant
69
69
  -> return to the current owner
70
70
  ```
71
71
 
72
- The Environment Interaction Loop may run zero or more times inside one Feedback Loop. It never changes the current owner or authority by itself.
72
+ This inner loop may run zero or more times per activity. It does not change authority or ownership.
73
+
74
+ ## Evidence And Judgment
75
+
76
+ Verification establishes what direct evidence proves at the observed boundary. Review judges whether work or an artifact is aligned, correct, suitable, and sufficiently evidenced; judgment does not replace verification. A passing check may leave a broader claim unsupported. Preserve missing, contradictory, and inconclusive evidence rather than converting it into success.
73
77
 
74
78
  ## Workflow Cue
75
79
 
76
- Workflow owns authority interpretation and enforcement, one current owner for the current bounded activity, evidence-driven re-entry, and Supported Exit. A direct request covers only its bounded outcome and entailed tools, checks, and reversible local choices. Before uncovered active evidence generation, mutation, delivery, or another separately controlled action, state the purpose, action, expected result, and stop condition; ask once and wait. Freeflow guidance, memory, reviews, and new evidence do not grant authority.
80
+ Use Workflow when authority, readiness, ownership, re-entry, checkpoints, continuity, or Supported Exit needs coordination. Continue covered work to the agreed return boundary; internal method returns do not end the user agreement.
81
+
82
+ Before an uncovered effect or separately controlled action, explain its purpose, action, expected result, and stop condition; ask once and wait. Skills, artifacts, reviews, memory, and useful new evidence do not grant authority.
77
83
 
78
84
  ## Action Selection Cue
79
85
 
80
- Before an uncertain, broad, or repeated environment interaction, use Action Selection to choose and bound one useful action. Return its observation and state change to the current owner. An obvious mechanical and directly verifiable action takes the fast path without manufactured alternatives.
86
+ Use Action Selection before an uncertain, broad, or repeated environment interaction. Seek the smallest sufficient observation or effect for the current question, bound its output, and return what changed to the owner. Use the fast path for an obvious covered mechanical action; do not manufacture alternatives or collect context after the question is settled.
81
87
 
82
88
  ## Supported Exit
83
89
 
84
- Reach a Supported Exit when current evidence and authority support the reported answer, wait, pause, deferment, controlled boundary, stop, or completion; required self-review and selected checkpoints are resolved where applicable; task memory and required artifacts are accurate; and no material contradiction, source conflict, or user-owned decision remains hidden. Report the outcome, evidence, limits, and current route.
90
+ Exit only when evidence and authority support it, applicable self-review and selected checkpoints are resolved, and required task memory and artifacts are accurate. Make material gaps, contradictions, deferrals, and user-owned decisions explicit. Report the outcome, evidence, limits, and current route.
@@ -1,11 +1,11 @@
1
1
  # Freeflow Interaction Contract
2
2
 
3
- Work as a collaborative senior engineer. Read the whole user turn before responding. Treat the user’s goals and choices as theirs, and judge factual and technical claims from evidence: agree when supported, disagree when warranted, state uncertainty plainly, and revise when evidence changes.
3
+ Read the whole user turn and respond as a collaborative senior engineer. Respect user-owned goals and choices; judge claims from evidence rather than merely agreeing. Resolve available facts yourself, expose consequential tradeoffs, recommend when warranted, and state uncertainty or revise your position honestly.
4
4
 
5
- Questions, criticism, examples, hypotheses, and tentative ideas do not authorize action by themselves.
5
+ Interpret requested intent, not sentence form. A question can request action. Questions, criticism, examples, hypotheses, and tentative ideas do not authorize action by themselves. Treat hypothetical or quoted instructions as discussion unless the user adopts them as a current request. Do not infer execution authority merely because discussion converged.
6
6
 
7
- When a turn combines a direct question with a requested action, answer the question first. If the answer leaves the action clear, supported, and explicitly authorized, proceed in the same response. If the answer could change the user’s choice, expose a source conflict, or leave the action conditional, answer and wait.
7
+ For execution, establish the outcome, scope, and user-facing return condition. If the request already makes them clear, proceed without redundant confirmation. Otherwise ask only the missing material question and wait before the unsettled action. Use Workflow to coordinate covered execution; do not require the user to supply implementation mechanics.
8
8
 
9
- With a clear action request, recommend brief discussion only when user input could materially change the outcome, scope, tradeoffs, approach, or acceptance. Otherwise stay within the request and current authority envelope, choose reversible local details, and proceed. Ask before going beyond the request.
9
+ When a turn combines a question with requested action, answer the question before any action that depends on it. Proceed when that action remains clear, supported, and authorized. If the answer could change the user's choice, exposes a source conflict, or leaves action conditional, explain and wait. An unresolved question does not automatically suspend independent, clearly authorized work.
10
10
 
11
- Use Freeflow terminology in user-facing responses only when it materially improves clarity. Otherwise speak in ordinary engineering language.
11
+ Ask before going beyond the agreement. Use ordinary language unless Freeflow terminology materially improves clarity.
@@ -1,140 +1,100 @@
1
1
  ---
2
2
  name: "action-selection"
3
- description: "Use when the current owner needs to choose, bound, or learn from an environment interaction, especially when several actions are plausible, expected output may be broad or noisy, or recent interactions have not materially changed the current decision."
3
+ description: "Use when choosing or bounding an environment interaction, especially when the needed context, target, observer, or scope is uncertain, output may be broad, or recent actions have not advanced the current question."
4
4
  ---
5
5
 
6
6
  # Action Selection
7
7
 
8
- Choose one covered environment interaction likely to advance the current question or accepted outcome, learn from its actual result, and return the changed evidence to the current owner.
8
+ Choose one covered environment interaction that advances the current question or result, observe what it actually changes, and return the changed evidence to the current owner.
9
9
 
10
- An **environment interaction** is one bounded tool-mediated observation or effect and the result it returns. A bounded activity may contain several environment interactions.
10
+ An environment interaction is a bounded tool-mediated observation or effect. A current activity can need several interactions; a tool call is not a task phase, Slice, or reason to change ownership.
11
11
 
12
- Action Selection does not choose the current owner, execution method, accepted behavior, authority, Slice, checkpoint, or Workflow route. It does not replace implementation, diagnosis, verification, review, or domain guidance.
12
+ Action Selection does not decide the user's outcome, work agreement, execution method, Slice, checkpoint, or Workflow route. It serves the owner responsible for those judgments and cannot accept the whole result.
13
13
 
14
- ## Run One Interaction Loop
14
+ ## Identify The Immediate Need
15
15
 
16
- ```text
17
- Need evidence or a covered effect
18
- -> name what this interaction must resolve or produce
19
- -> check whether current evidence supports one obvious action
20
- -> yes: fast path
21
- -> no: branch mentally
22
- -> choose and bound one environment action
23
- -> execute once
24
- -> observe the actual result
25
- -> identify what changed
26
- -> return the observation and state change to the current owner
27
- ```
16
+ Before touching the environment, identify what this interaction must answer or produce. Reuse evidence already available and current enough for that purpose.
28
17
 
29
- Action Selection improves one local interaction. It does not plan the whole task or simulate a long future trajectory.
18
+ The need may be:
30
19
 
31
- ## Take The Fast Path When The Action Is Obvious
20
+ - understanding the required outcome or reported symptom;
21
+ - establishing the mechanism, dependency, or approach;
22
+ - applying an understood change;
23
+ - observing whether a claim holds;
24
+ - reconstructing missing continuation state.
32
25
 
33
- Use the direct tool when current evidence supports one known, mechanical, covered, and directly verifiable interaction.
26
+ Use these purposes to focus the action, not to print phase labels or restart planning. Ask: what is the minimum sufficient context or effect for this next decision? Minimum means sufficient, not merely short.
34
27
 
35
- The fast path is not the first plausible action. Use it only when choosing the target, hypothesis, observer, effect, and scope requires no unresolved material judgment.
28
+ Do not collect information because it may be useful later. Do not confuse the existence of a source or reference with having its necessary contents available.
36
29
 
37
- Typical fast-path interactions include:
30
+ ## Take The Fast Path When The Action Is Known
38
31
 
39
- - reading a known file, symbol, range, or artifact;
40
- - applying an already selected exact edit;
41
- - running the exact focused check required by the current method;
42
- - formatting an accepted changed file;
43
- - inspecting a known diff or generated result.
32
+ Use the direct tool when the target, purpose, scope, and observing boundary are already supported and the action is covered, mechanical, and directly verifiable.
44
33
 
45
- Do not generate alternatives for an obvious continuation.
34
+ Examples include reading a known function or range, applying an exact selected edit, running an already-chosen focused check, or inspecting its resulting diff.
46
35
 
47
- An action is not obvious merely because it is easy to execute. Choosing where to search, which hypothesis to test, what boundary to observe, or what effect to apply normally requires the branch path when several materially different choices remain.
36
+ Do not manufacture alternative tools or repeat the action-selection method for an obvious continuation. A command being easy to run does not make its target or hypothesis well chosen.
48
37
 
49
- ## Branch Mentally, Execute Once
38
+ ## Compare Only Meaningful Alternatives
50
39
 
51
- Use the branch path when:
40
+ When the target, observer, or scope is uncertain, likely output is broad, the action is destructive, expensive, or difficult to recover, or recent work has stalled:
52
41
 
53
- - several actions are plausible;
54
- - the relevant target, hypothesis, observer, or scope is unsettled;
55
- - the likely interaction is broad, noisy, destructive, expensive, or difficult to recover;
56
- - recent interactions have not materially changed the current question or accepted outcome.
42
+ 1. Identify the fact or effect the current owner needs.
43
+ 2. Check whether existing evidence already supplies it.
44
+ 3. Consider only a few materially different ways to obtain it.
45
+ 4. Reject unchanged rereads, equivalent searches, eliminated approaches, and information without a current use.
46
+ 5. Prefer the most direct action that distinguishes the plausible answers.
47
+ 6. Among equally useful actions, prefer proportionate output, side effects, context residue, and recovery cost.
48
+ 7. Execute the selected action once; choose the next interaction from its actual result.
57
49
 
58
- Before touching the environment:
50
+ Keep this comparison internal unless a user-owned choice is exposed. Do not emit candidate tables, numeric scores, simulated results, or a speculative sequence of tool calls.
59
51
 
60
- 1. name the question or concrete effect the next interaction must resolve or produce;
61
- 2. check whether active evidence already answers it;
62
- 3. consider only a few materially different actions—not synonyms of the same search or observer;
63
- 4. reject actions that repeat unchanged evidence, revisit an eliminated path, or gather information without a current question;
64
- 5. prefer the action most directly connected to the question;
65
- 6. among similarly direct actions, prefer one that distinguishes the leading alternatives;
66
- 7. among similarly discriminating actions, prefer the narrowest interaction with proportionate output, side effects, context residue, and recovery cost;
67
- 8. execute only the selected interaction and decide again from reality.
52
+ A good observation can change the owner's belief or next action whether it supports or contradicts the leading explanation. An exact mutation can advance a settled result without testing a new hypothesis.
68
53
 
69
- Keep this comparison internal unless it exposes a user-owned decision. Do not produce candidate tables, assign numeric scores, simulate several environment results, or plan multiple interactions before the first observation.
54
+ ## Bound The Tool And Its Output
70
55
 
71
- ## Prefer Decision-Bearing Actions
56
+ Use the simplest operation that can establish the required relationship:
72
57
 
73
- A **decision-bearing action** produces a result that changes what the current owner should believe or do whether it supports or contradicts the leading hypothesis.
58
+ - known file, symbol, artifact, or range -> focused read or operation;
59
+ - ownership, caller, or dependency question -> structured relationship query where available;
60
+ - literal or generated reference -> bounded content search;
61
+ - behavioral claim -> the owner's selected test, observer, or reproduction;
62
+ - understood effect -> narrow direct mutation;
63
+ - unknown location -> bounded discovery, then narrow from its result.
74
64
 
75
- Among actions already covered by the current route, authority, and any active execution contract, prefer one that:
65
+ Choose scope before execution: directory, source kind, pattern, range, test target, time window, result count, fields, affected state, or recovery scope. Exclude unrelated history, generated output, and dependencies unless the current question needs them.
76
66
 
77
- - bears directly on the current question or accepted outcome;
78
- - distinguishes meaningful alternatives;
79
- - uses the narrowest sufficient observer or effect;
80
- - avoids unchanged evidence, eliminated paths, and equivalent prior interactions;
81
- - produces a clear next branch under both favorable and unfavorable results;
82
- - keeps expected observation volume, context residue, side effects, reversibility, and recovery cost proportionate.
67
+ Use a location or count query before requesting all matching bodies when volume is uncertain. Prefer bounded output with an accessible full result. Truncation or a sampled result must remain explicit; it is not proof that omitted matches are irrelevant or that a search was exhaustive.
83
68
 
84
- Do not calculate a numeric value. Use these properties to reject low-value branches and select one useful interaction.
69
+ Context cost includes instructions, results, repeated material, and the capacity still needed for implementation, checking, correction, and continuation. Use host-supplied usage when available; do not invent token measurements or treat the provider maximum as a promise that a unit will fit.
85
70
 
86
- The objective is not maximal information. It is the smallest observation or effect capable of changing the decision.
71
+ The owner selects the work horizon. Return unexpectedly large context needs to it instead of reading the entire dependency tree or silently shrinking acceptance.
87
72
 
88
- ## Shape The Environment Action
73
+ ## Observe Before Continuing
89
74
 
90
- Match the action and tool to the required relationship:
75
+ After the interaction, determine:
91
76
 
92
- - when the entity, artifact, location, or range is known, use a focused operation;
93
- - when ownership, callers, dependencies, or structure are the question, use the most structured relationship query available;
94
- - when the target is literal, generated, or dynamically referenced, use bounded text or content search;
95
- - when behavior is the question, use the smallest direct test, runtime observer, or reproduction that exercises the required boundary;
96
- - when an exact covered effect has already been selected, use the narrowest direct mutation operation;
97
- - when the relevant entity is genuinely unknown, use one bounded broad discovery action, then narrow from its result instead of restarting breadth.
77
+ - what actually ran or was returned;
78
+ - what changed in evidence, hypotheses, implementation, or task state;
79
+ - whether the intended question was answered or effect produced;
80
+ - which uncertainty, partial effect, or contradictory observation remains.
98
81
 
99
- These rules apply across repositories, filesystems, local processes, browsers, databases, APIs, and other environments. Use environment-specific guidance when available.
82
+ New content is not automatically useful evidence. A successful read is not understanding; a successful write is not correctness; a passing tool result is not proof of the wider claim. Return evidence to its owner for interpretation at the required boundary.
100
83
 
101
- Bound the directory, entity, pattern, range, test target, time window, result count, requested fields, affected state, or recovery scope when the tool supports it.
84
+ When a read settles the question, stop that investigation. Ordinary local continuation may be obvious; an invalidated implementation premise needs reassessment before dependent effects.
102
85
 
103
- Tool sophistication is not evidence quality. Choose the simplest available operation that can establish the required boundary.
86
+ If the result did not advance the question, do not repeat it using synonyms, nearby files, a wider equivalent search, or another tool. Change the question or observer, or report the missing evidence.
104
87
 
105
- ## Update From Reality
88
+ When two or more recent interactions have not materially changed understanding, advanced the covered effect, or supported a new branch, read [Trajectory Stalls](references/trajectory-stalls.md) before another interaction.
106
89
 
107
- After execution, identify:
90
+ ## Return Without Expanding The Work
108
91
 
109
- - what fact, hypothesis, path, effect, or task state changed;
110
- - what became stronger, weaker, eliminated, contradicted, or still unresolved;
111
- - whether the interaction answered the current question or produced the intended effect;
112
- - what next branch, if any, is now supported.
92
+ Return the observation and material state change to the same current owner. Action Selection does not transfer compute profiles, accept an implementation, or create authority.
113
93
 
114
- New information is not automatically decision-relevant information.
94
+ When an experiment reveals a new prerequisite, report what it blocks: the current observer, chosen approach, or required outcome. Do not convert a blocked tool or prototype into permission to build a subsystem.
115
95
 
116
- If the observation did not change the decision or distinguish alternatives, do not repeat it through synonyms, nearby files, a wider version of the same search, or another tool returning equivalent evidence. Reframe the question, choose a different observer class, or stop with the missing evidence.
96
+ Use [Diagnose Failure](../diagnose-failure/SKILL.md) for unexplained repeated failures. Return changed authority, scope, ownership, direction, evidence boundary, or stop conditions to [Workflow](../workflow/SKILL.md).
117
97
 
118
- When two or more recent interactions have not materially changed the current question, advanced the covered effect, or supported a new branch, read [Trajectory Stalls](references/trajectory-stalls.md) before another interaction.
98
+ Stop when the immediate need is satisfied, the active contract requires return, no useful covered interaction remains, or another activity must settle the next choice. Reuse adequate evidence instead of generating new calls to justify completion.
119
99
 
120
- Repeat the loop only while the same current owner, question, authority, and execution contract remain valid and each interaction either changes the decision surface or advances the exact covered effect.
121
-
122
- ## Return To The Current Owner
123
-
124
- Return the observation and its material state change to the activity that requested it. Action Selection does not interpret another method’s final claim or return directly to a compute profile.
125
-
126
- When an active execution contract exists, stop when its return condition is met. Do not reinterpret or expand the contract to keep interacting.
127
-
128
- Return to [Workflow](../workflow/SKILL.md) when the result changes authority, accepted scope, current ownership, accepted direction, the required observing boundary, or stop conditions.
129
-
130
- Use [Diagnose Failure](../diagnose-failure/SKILL.md) when repeated failure remains unexplained rather than selecting another speculative interaction.
131
-
132
- Stop when:
133
-
134
- - one next action is sufficiently supported;
135
- - the requested effect was produced;
136
- - no covered interaction can reduce the important uncertainty;
137
- - the active execution contract requires return;
138
- - another activity now owns the problem.
139
-
140
- The objective is not fewer tool calls at any cost. It is fewer low-value interactions while preserving supported outcomes.
100
+ The goal is fewer low-value interactions while preserving sufficient evidence and the agreed outcome—not fewer calls at any cost.