feat(reflex): runtime guardrails — command/edit guard + Pi hook + dataset export - #30
Merged
Merged
Conversation
First implementation of the reflex PRD:
- classify-command: deterministic Allow/Ask/Block for shell commands
- BLOCK: dd, rm -rf /home, curl|sh, hardcoded credentials
- ASK: sudo apt, kill -9, chmod 777, git push --force
- low-risk prefixes: git status, git log, ls, npm run, grep, cat
- classify-edit: risky file edit detection
- Pattern-based: lockfiles, generated files, config files, .env
- Repo-arch cache scoring: repeated-fix, co-change cards
- High-churn file heuristics (agent-session.ts, models.generated.ts)
- test-plan: recommend tests/checks for changed files
- Direct test discovery: same-dir, __tests__/, test/
- Co-change-based test suggestions
- TypeScript typecheck, monorepo workspace tests, e2e hints
- events: append-only event log (JSONL)
- Tracks command_allowed, command_asked, command_blocked,
edit_classified, pi_hook_triggered, etc.
- install-pi: Pi auto-mode pre-action hook
- Generates .repo-arch/reflex/pi-hook.js
- Updates .pi/settings.json with reflex package path
- beforeCommand + beforeEdit hook functions
- dataset: export training data from events + synthetic examples
- Converts reflex events to labeled dataset
- Includes synthetic allow/ask/block examples
- Splits train/valid for LoRA fine-tuning
Build order from PRD: policy-only command guard → file-edit
classifier → test signals → Pi hook → event capture → dataset
→ training
Related to: repo-arch reflex PRD
…removed unused imports
bearmug
force-pushed
the
feat/reflex-runtime-guardrails
branch
from
May 21, 2026 20:20
5b35d3d to
cc43f8b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First implementation of the
repo-arch reflexruntime guardrails PRD. Adds a deterministic policy layer for shell commands and file edits, with an event log, test-plan generator, and Pi auto-mode hook.What changed
New
reflexsubcommandsModules (
src/reflex/)classify-command.tsclassify-edit.tstest-plan.tsevents.tsinstall-pi.tsdataset.tsindex.tsCommand guard examples
Edit classification examples
Build order (from PRD)
Notes
train.tsandsession-ingest.tsremain TODOs — wired in the build order but not yet implemented.