gstack icon indicating copy to clipboard operation
gstack copied to clipboard

/autoplan Phase 0: silent phase-skip when scope detection misses by one term; no diagnostic

Open aviraldua93 opened this issue 5 months ago • 3 comments

Filed downstream at aviraldua93/gstack-copilot#9. Bug in canonical upstream gstack — exposed during smoke test of /autoplan.

Summary

/autoplan Phase 0 detects whether to run Phase 2 (Design Review) and Phase 3.5 (DX Review) by grepping the plan file with grep -ciE "\b($TERMS)\b" and a threshold of ≥ 2 matches. When count is below threshold, the phase is silently skipped — no diagnostic, no opportunity to override.

Failure modes

  1. Silent miss — plan IS UI/DX-relevant but uses hyphenated terms (form-control, api-endpoint), terms in code fences grep skips, or terms synonymous-but-not-listed (screen reader matches, chrome accessibility tree does not). User gets 2 phases instead of 4 and never knows why.
  2. Borderline trip — exact-threshold matches give no warning. Lose one match anywhere and the phase silently disappears next run.

Suggested fixes

  1. Print matched terms, not just count:
UI scope detection:
  matched: dashboard (×2)
  threshold: 2
  → UI_SCOPE: yes

When count equals threshold, add inline warning ⚠ borderline match (count = threshold); confirm or override.

  1. Confirm at the gate when borderline — single AskUserQuestion before phases run.

  2. Expand term list and version it — move to scripts/scope-terms.json so community can contribute. Current list is 10 UI terms, 30 DX terms — short for the domain.


Filed via GitHub Copilot CLI by @aviraldua93 during stress-testing a downstream port.

aviraldua93 avatar Jun 10 '26 19:06 aviraldua93

This is a phase-gate diagnostic contract issue.

If Phase 0 scope detection misses by one term, /autoplan should not silently skip a phase.

A planning workflow should make phase decisions visible:

phase considered
  -> evidence matched
  -> decision: run / skip
  -> diagnostic reason

A standard AISP-style contract could express this:

[
  {
    "role": "system",
    "content": {
      "protocol": "AISP V1.0.0",
      "axiom_0": "Human_Sovereignty_and_Wellbeing",
      "id": "gstack_autoplan_phase_gate_diagnostic_aisp",
      "name": "gstack /autoplan Phase Gate Diagnostic Contract",
      "version": "1.0.0",
      "license": "MIT",
      "summary": "Machine-checkable contract for emitting diagnostics when /autoplan phases are skipped.",
      "flow_format": "mermaid",
      "loading_mode": "node",
      "tools": ["filesystem"],
      "params": {
        "plan_input_path": "string"
      },
      "system_prompt": ""
    }
  },
  {
    "role": "user",
    "content": {
      "instruction": "STRICTLY OBEY aisp_contract; its non_negotiable rules are inviolable; then RUN aisop.main",
      "user_input": "{user_input}",
      "aisp_contract": {
        "profile": "aisp.skill.v1",
        "invocation": {
          "mode": "planning_phase_validation",
          "when_to_use": [
            "before /autoplan skips a phase",
            "when scope detection decides phase 0 is not needed",
            "when phase selection is based on heuristic matching"
          ],
          "when_not_to_use": [
            "manual explicit user skip",
            "phase disabled by CLI flag"
          ]
        },
        "non_negotiable": [
          {
            "rule": "Do not skip an /autoplan phase without a diagnostic reason.",
            "enforced_by": "diagnose.step2:sys.assert"
          },
          {
            "rule": "Phase skip decisions must record evidence terms and missing terms.",
            "enforced_by": "trace.step2:sys.assert"
          }
        ],
        "discovery": {
          "category": "planning_workflow",
          "tags": ["gstack", "autoplan", "phase-gate", "diagnostics", "aisp"]
        },
        "risk_level": "medium",
        "resources": [
          {
            "id": "plan_input",
            "path": "{plan_input_path}",
            "kind": "artifact",
            "mode": "read_only",
            "when": "Read before phase gate decisions.",
            "scope": "skill"
          }
        ]
      },
      "aisop": {
        "main": "graph TD\n    load[Load plan input] --> detect[Detect phase scope]\n    detect --> decide[Run or skip phase]\n    decide --> diagnose[Emit diagnostic]\n    diagnose --> trace[Record phase decision trace]\n    trace --> end_node((End))"
      },
      "functions": {
        "load": {
          "step1": "sys.io.read(plan_input_path) -> plan_input",
          "output_mapping": "plan_input"
        },
        "detect": {
          "step1": "Evaluate scope terms, synonyms, and required phase criteria.",
          "output_mapping": "phase_scope_detection"
        },
        "decide": {
          "step1": "Decide run or skip for each phase.",
          "output_mapping": "phase_decisions"
        },
        "diagnose": {
          "step1": "For every skipped phase, produce reason, matched evidence, missing evidence, and confidence.",
          "step2": "sys.assert('every skipped phase has diagnostic reason', 'Autoplan phase skip requires diagnostic')",
          "output_mapping": "phase_diagnostics"
        },
        "trace": {
          "step1": "Record phase decisions, evidence terms, confidence, and user-visible warnings.",
          "step2": "sys.assert('phase skip trace contains evidence and reason', 'Phase skip trace incomplete')",
          "output_mapping": "phase_gate_trace"
        },
        "end_node": {
          "step1": "Return phase_gate_trace."
        }
      }
    }
  }
]

The key invariant:

a skipped planning phase is a decision, not absence of work.

It should leave evidence.

optimization2026 avatar Jun 30 '26 06:06 optimization2026

@16francej — recommend closing this issue in favor of #2014, but it should close only after generated-skill checks cover 0, 1, 2, and 3 matches, near misses, forced dispatch, and headless operation. Current coverage checks wording rather than dispatch behavior. Retain visible counts, the exactly-two boundary, near-miss diagnostics, and nonblocking force behavior.

time-attack avatar Jul 15 '26 12:07 time-attack

Thanks for the report, @aviraldua93. Fixed in v1.91.97.0 (#3165): /autoplan Phase 0 now prints the evidence behind each scope decision (matched terms with counts, visual nouns, rendered-file paths, and the source of each flag). Hyphenated terms and rendered-file paths count, and you can force either phase with --ui / --no-ui / --no-dx or a scope marker in the plan.

Closing. A borderline-match warning was not added, so please open a new issue if you'd like that.

capy-ai[bot] avatar Oct 17 '26 16:10 capy-ai[bot]