Skip to content

Implement PAI user-choice Q&A contract (closes #148)#154

Merged
virtualian merged 1 commit intomainfrom
148-askuserquestion-implementation
Apr 24, 2026
Merged

Implement PAI user-choice Q&A contract (closes #148)#154
virtualian merged 1 commit intomainfrom
148-askuserquestion-implementation

Conversation

@virtualian
Copy link
Copy Markdown
Owner

Summary

  • Adds a PAI-level trigger-consistency layer on top of the existing AskUserQuestion usage — an Algorithm ENUMERATE→OFFER sub-step, a NATIVE ❓ OPEN_CHOICES: output field, a rewritten AISTEERINGRULES.md "AskUserQuestion for choices" rule with six concrete triggers, and a new normative protocol at PAI/PROTOCOLS/qa-contract.md.
  • Formalises the subagent→DA bubble pattern in THEDELEGATIONSYSTEM.md with correct + anti-pattern code. Adds a pack user-choice policy to SKILLSYSTEM.md with a done-state for new packs.
  • Implements all seven work items from §8 of reports/20260421-issue-143-askuserquestion-pai-design.md (investigation landed in Add issue #143 report: AskUserQuestion PAI Q&A pattern design #149). Runtime probe of Architect, Engineer, Plan subagents confirmed all three report AskUserQuestion as ABSENT — bubble protocol is the only workable path across the specialised fleet. Probe results in reports/20260422-issue-148-subagent-probes.md.

Non-goals (per issue body)

  • No wrapper skill, no rename of AskUserQuestion, no new tool.
  • No non-CC adapter code (contract is abstract-only; CC is the sole backend today).
  • No changes to existing hooks, no edits to any of the 13 existing AskUserQuestion call sites, no runtime code edits.
  • Runtime installation at ~/.pai/ intentionally untouched; edits target the shipped repo artefact at Releases/v4.0.3+/.

Design notes for review

  • Placement of ENUMERATE→OFFER: inserted after the existing OBSERVE EXIT GATE — EXTERNAL ASSUMPTION VERIFICATION block (not before), so the order is "verify assumptions → enumerate open choices → transition to THINK". Avoids gate collision.
  • Dual CLAUDE.md edit: the field and directive are added to both .claude/CLAUDE.md (live) and .claude/CLAUDE.md.template (installer source). Diff of the two files post-edit shows only the pre-existing preamble/placeholder differences — no drift introduced.
  • qa-contract.md line budget: 194 lines (issue requested 150-250). Expanded from initial 180 after peer review and a scoped RedTeam pass surfaced three must-fixes and two silent-corruption risks (dedupe identity, label canonicalisation). Invariants grew from 6 to 9 to patch these.
  • Writing-Prompts Standard: the new qa-contract.md carries schema blocks and code examples. This is a pragmatic reading of the standard's scope — operational PAI protocol files behave like THEDELEGATIONSYSTEM.md (which already uses code blocks), not like .claude/marr/standards/ meta-prompts. Flagging here so reviewers can push back if the strict reading should apply.

Test plan

  • Read PAI/PROTOCOLS/qa-contract.md end-to-end; confirm schema, carriers, and invariants read cleanly as a standalone spec.
  • Trigger the new NATIVE ❓ OPEN_CHOICES: field in a test session — confirm non-empty values render and that the paired AskUserQuestion rule is observed.
  • Exercise the Algorithm ENUMERATE→OFFER block in an Advanced-tier task with multiple open choices — confirm the commit-with-rationale vs AskUserQuestion split behaves as described.
  • Run an Agent call (Architect/Engineer/Plan) with a prompt that triggers a user-choice point; confirm the subagent returns pending_user_choices[] rather than attempting direct invocation.
  • Diff ~/.pai/ after a fresh install to confirm the new PROTOCOLS/ directory propagates.

Closes #148.

Introduce a PAI-level trigger-consistency layer over the existing
AskUserQuestion usage. No renames, no wrappers, no new tools — only
new prompt/doc machinery so the existing 13 call sites and hooks stay
untouched.

- Algorithm: ENUMERATE→OFFER sub-step at OBSERVE exit, after the
  assumption-verification gate, with commit-with-rationale and
  AskUserQuestion escape paths plus worked examples.
- NATIVE format: new ❓ OPEN_CHOICES: field in CLAUDE.md and its
  template, with a pairing rule that forbids non-empty values
  without an accompanying AskUserQuestion call.
- AISTEERINGRULES: "AskUserQuestion for choices" rewritten with six
  concrete triggers (OBSERVE ambiguity, capability substitution,
  commit-message approval, branch-naming, skill-routing,
  effort-level) and a worked example.
- PROTOCOLS/qa-contract.md (new, 194 lines): normative Request/
  Response schema, Carrier A (subagent return-value) and Carrier B
  (DA→user AskUserQuestion) mappings, nine invariants, non-CC
  harness stub note. Single source of truth referenced by callers.
- THEDELEGATIONSYSTEM: new "User-choice bubbling" subsection
  formalising pending_user_choices[] with anti-pattern and correct
  code examples.
- SKILLSYSTEM: one-line pack user-choice policy plus a concrete
  done-state for new packs.
- reports/: subagent probe results for Architect, Engineer, and
  Plan — all three report AskUserQuestion as ABSENT, confirming
  the bubble protocol is mandatory across the specialised fleet.

Runtime installation at ~/.pai/ intentionally untouched; edits
target the shipped repo artefact at Releases/v4.0.3+/.
@virtualian virtualian merged commit 1542ae9 into main Apr 24, 2026
@virtualian virtualian deleted the 148-askuserquestion-implementation branch April 24, 2026 15:25
virtualian added a commit that referenced this pull request Apr 26, 2026
Plan file capturing the per-file selective merge approach used to apply
PR #154 to the live runtime at ~/.pai/ + ~/.claude/ without a fresh
install. Documents path mapping, three-way merge strategy per file
class, drift-preservation criteria, and verification logic.

Runtime application is complete; this commit lands the planning artefact
only — the runtime files themselves live outside git.
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.

Implement issue #143 Q&A pattern design — bubble protocol + trigger gate

1 participant