mirror of https://github.com/garrytan/gstack.git
Subcommands:
--check <id> → ASK_NORMALLY | AUTO_DECIDE (decides if a registered
question should be auto-decided by the agent)
--write '{…}' → set a preference (requires user-origin source)
--read → dump preferences JSON
--clear [id] → clear one or all
--stats → short counts summary
Preference values: always-ask | never-ask | ask-only-for-one-way.
Stored at ~/.gstack/projects/{SLUG}/question-preferences.json.
Safety contract (the core of Codex finding #16, profile-poisoning defense
from docs/designs/PLAN_TUNING_V0.md §Security model):
1. One-way doors ALWAYS return ASK_NORMALLY from --check, regardless of
user preference. User's never-ask is overridden with a visible safety
note so the user knows why their preference didn't suppress the prompt.
2. --write requires an explicit `source` field:
- Allowed: "plan-tune", "inline-user"
- REJECTED with exit code 2: "inline-tool-output", "inline-file",
"inline-file-content", "inline-unknown"
Rejection is explicit ("profile poisoning defense") so the caller can
log and surface the attempt.
3. free_text on --write is sanitized against injection patterns (ignore
previous instructions, override:, system:, etc.) and newline-flattened.
Each --write also appends a preference-set event to
~/.gstack/projects/{SLUG}/question-events.jsonl for derivation audit trail.
31 tests:
- --check behavior (4): defaults, two-way, one-way (one-way overrides
never-ask with safety note), unknown ids, missing arg
- --check with prefs (5): never-ask on two-way → AUTO_DECIDE; never-ask
on one-way → ASK_NORMALLY with override note; always-ask always asks;
ask-only-for-one-way flips appropriately
- --write valid (5): inline-user accepted, plan-tune accepted, persisted
correctly, event appended, free_text preserved with flattening
- User-origin gate (6): missing source rejected; inline-tool-output
rejected with exit code 2 and explicit poisoning message; inline-file,
inline-file-content, inline-unknown rejected; unknown source rejected
- Schema validation (4): invalid JSON, bad question_id, bad preference,
injection in free_text
- --read (2): empty → {}, returns writes
- --clear (3): specific id, clear-all, NOOP for missing
- --stats (2): empty zeros, tallies by preference type
31 pass, 0 fail, 52 expect() calls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| fixtures | ||
| helpers | ||
| analytics.test.ts | ||
| audit-compliance.test.ts | ||
| builder-profile.test.ts | ||
| codex-e2e.test.ts | ||
| diff-scope.test.ts | ||
| gemini-e2e.test.ts | ||
| gen-skill-docs.test.ts | ||
| global-discover.test.ts | ||
| gstack-developer-profile.test.ts | ||
| gstack-question-log.test.ts | ||
| gstack-question-preference.test.ts | ||
| hook-scripts.test.ts | ||
| host-config.test.ts | ||
| learnings-injection.test.ts | ||
| learnings.test.ts | ||
| plan-tune.test.ts | ||
| relink.test.ts | ||
| review-log.test.ts | ||
| skill-e2e-bws.test.ts | ||
| skill-e2e-cso.test.ts | ||
| skill-e2e-deploy.test.ts | ||
| skill-e2e-design.test.ts | ||
| skill-e2e-learnings.test.ts | ||
| skill-e2e-plan.test.ts | ||
| skill-e2e-qa-bugs.test.ts | ||
| skill-e2e-qa-workflow.test.ts | ||
| skill-e2e-review-army.test.ts | ||
| skill-e2e-review.test.ts | ||
| skill-e2e-session-intelligence.test.ts | ||
| skill-e2e-sidebar.test.ts | ||
| skill-e2e-workflow.test.ts | ||
| skill-e2e.test.ts | ||
| skill-llm-eval.test.ts | ||
| skill-parser.test.ts | ||
| skill-routing-e2e.test.ts | ||
| skill-validation.test.ts | ||
| team-mode.test.ts | ||
| telemetry.test.ts | ||
| timeline.test.ts | ||
| touchfiles.test.ts | ||
| uninstall.test.ts | ||
| worktree.test.ts | ||