Skip to content

fix(openspec-propose): enforce dirty-tree guard with AskUserQuestion tool call - #406

Merged
jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/fix-dirty-tree-guard
Jul 31, 2026
Merged

jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/fix-dirty-tree-guard

Conversation

@jflowers

Copy link
Copy Markdown
Contributor

Summary

Closes the T1 (prose-only gate) vulnerability in the openspec-propose skill and
opsx-propose command identified in issues #350 and #353.

Both files had a dirty-tree guard before git checkout -b that described "asking the
user for confirmation" in prose only. Under context compression (long sessions, large
tool outputs), this prose reasoning could be dropped by the agent, causing silent branch
switches with uncommitted work — a data integrity risk.

The fix replaces the prose-only guard with an explicit AskUserQuestion tool-call
instruction that cannot be optimized away. The guard now requires:

  • Showing the user the git status output, target branch, and a warning
  • Two options: "Stash changes and continue" / "Abort — keep changes as-is"
  • Stash failure handling (non-zero exit → abort)
  • Post-stash verification (git status must be empty after stash)

Fixes #350, #353

How to Test

  1. Start an /opsx-propose session with a dirty working tree (uncommitted changes).
    Verify the agent invokes AskUserQuestion with two options instead of silently
    switching branches.
  2. Select "Abort" — verify the workflow stops without switching branches.
  3. Select "Stash" — verify git stash runs and the tree is verified clean before checkout.
  4. Open both files and verify the AskUserQuestion instruction appears in section 3a
    ("Dirty working tree check"), after git status --short and before git checkout -b.

How to Demo

Open .opencode/skills/openspec-propose/SKILL.md and navigate to the "Dirty working
tree check" subsection. The prose-only "ask the user" language has been replaced with
an explicit AskUserQuestion tool-call block specifying options, stash handling, and
verification. The same change is mirrored in .opencode/commands/opsx-propose.md.

Key Files Changed

Implementation:

  • .opencode/skills/openspec-propose/SKILL.md (+23 lines) — AskUserQuestion enforcement added to dirty-tree guard
  • .opencode/commands/opsx-propose.md (+20 lines) — identical fix in companion command

OpenSpec artifacts:

  • openspec/changes/fix-dirty-tree-guard/proposal.md — change proposal with constitution alignment
  • openspec/changes/fix-dirty-tree-guard/design.md — technical design with known remaining instances
  • openspec/changes/fix-dirty-tree-guard/specs/dirty-tree-guard-enforcement.md — delta spec (FR-001, FR-002)
  • openspec/changes/fix-dirty-tree-guard/tasks.md — implementation checklist (all tasks complete)

This PR was generated by /finale (AI-assisted).

…tool call

Replace prose-only dirty-tree guard in openspec-propose skill and
opsx-propose command with explicit AskUserQuestion tool-call
enforcement. Under context compression, prose-only gates could be
silently dropped, causing agents to switch branches with uncommitted
work.

- Add AskUserQuestion with options: "Stash changes and continue" /
  "Abort — keep changes as-is"
- Add stash failure handling (non-zero exit → abort)
- Add post-stash verification (git status must be empty after stash)
- Create OpenSpec change artifacts (proposal, design, specs, tasks)
- Document 5 remaining files with same vulnerability in design.md

Fixes unbound-force#350, unbound-force#353

Assisted-by: claude-opus
Generated with AI assistance (claude-opus)
@jflowers
jflowers merged commit 1f124ac into unbound-force:main Jul 31, 2026
15 checks passed
jflowers added a commit that referenced this pull request Aug 1, 2026
…cit AskUserQuestion gate

Replace the prose-only "STOP and ask the user for
confirmation" instruction in speckit-workflow/SKILL.md
Pre-conditions section with an explicit AskUserQuestion
tool call pattern matching the sibling files hardened in
PRs #396 and #406.

- Add AskUserQuestion with stash/abort options
- Add stash failure handling (non-zero exit → abort)
- Add post-stash re-verification via git status --short
- Add post-workflow stash restore reminder
- Update scaffold copy in lockstep
- Add OpenSpec change artifacts

Fixes #395

Assisted-by: claude-opus
Generated with AI assistance (claude-opus)
sonupreetam added a commit to sonupreetam/unbound-force that referenced this pull request Aug 3, 2026
Add a three-layer runtime sandbox for the OpenCode review
invocation in council-review-action:

Layer 1 — OPENCODE_CONFIG_CONTENT permission config:
  Denies edit, bash, webfetch, websearch, skill,
  external_directory, and doom_loop. Read, glob, grep
  remain allowed (OpenCode defaults). Task is intentionally
  NOT denied — required for multi-agent Divisor subagent
  invocation via the Task tool.

Layer 2 — --pure flag:
  External MCP plugins are not loaded, closing the plugin
  bypass vector where an external plugin could grant
  capabilities beyond the permission config.

Layer 3 — Agent frontmatter:
  All divisor-*.md agents now declare permission: edit: deny,
  bash: deny, webfetch: deny in their frontmatter. This is
  defense-in-depth; even if the runtime config were
  misconfigured, agent-level restrictions apply.

Additional changes:
- Bumped opencode pin from 1.2.26 to 1.15.13 (1.16.0+
  changed JSONL streaming format, breaking parse-output.sh)
- Explicitly deny all ask-default permissions instead of
  using --dangerously-skip-permissions or --auto
- Synced scaffold assets with migrated agent frontmatter
- Added OpenSpec artifacts for council-review-sandbox

References: nunya#406, unbound-force#337 (closed as
NOT_PLANNED — work folded into unbound-force#406)

Signed-off-by: sonupreetam <[email protected]>
@jflowers
jflowers deleted the opsx/fix-dirty-tree-guard branch November 15, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(openspec-propose skill): dirty-tree guard is prose only — no AskUserQuestion enforcement

1 participant