Skip to content

fix: enforce safe prompt-perfector execution - #1439

Merged
BigSimmo merged 11 commits into
mainfrom
codex/chat-prompt-skill-review-e608
Jul 31, 2026
Merged

fix: enforce safe prompt-perfector execution#1439
BigSimmo merged 11 commits into
mainfrom
codex/chat-prompt-skill-review-e608

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make prompt-perfector refinement-only by default with explicit evaluation, execution, and authority controls.
  • Replace unsupported workspace semantics with a portable, fail-closed repository workflow.
  • Add a dependency-free repository-isolation verifier and regression coverage for unsafe states.

Verification

  • npm run verify:pr-local
    • Stopped after runtime PASS because this worktree has no installed Next.js, React, ESLint, Playwright, TypeScript, or Vitest packages.
    • npm ci --include=dev was not run because Database Next.js and Vitest processes were active in other worktrees.
  • npm run check:skills — 33 canonical skills and 8 aliases valid
  • Skill Creator quick_validate.py — skill valid
  • Isolation verifier self-test — 10/10 passed
  • Live task-worktree verification — SAFE_TO_EDIT=true
  • Primary-checkout negative verification — blocked with BLOCK_REASON=primary_worktree
  • Prompt scenario contract — 15/15 passed
  • Node syntax checks for the verifier and skill test
  • Lockfile-version Prettier 3.9.6 check for every changed file
  • npm run check:branch-review-ledger
  • git diff --check origin/main...HEAD

UI verification not run: no UI, routing, styling, or browser behavior changed.

Risk and rollout

  • Risk: Low workflow risk. The verifier intentionally fails closed and could block repository-writing prompt execution when bootstrap state is incomplete or stale.
  • Rollback: Revert the prompt-perfector skill, verifier, and associated test changes.
  • Provider or production effects: GitHub branch push and draft PR creation only; no application runtime, clinical, database, API, deployment, or production effects.

Clinical Governance Preflight

Not applicable: this PR does not touch ingestion, answer generation, search/ranking, source rendering, document access, privacy, production environment, or clinical output.

Notes

RAG impact: no retrieval behaviour change — prompt skill workflow and local repository-isolation tooling only.

The exact npm run format command could not start because local Prettier was absent. A cached offline Prettier 3.9.6 matching the lockfile formatted and checked all changed files; the whole-tree fallback was bounded but timed out without creating additional changes.

Summary by CodeRabbit

  • New Features

    • Added safer prompt refinement controls, including approval, literal, variant, and execution modes.
    • Added repository-isolation checks to detect unsafe editing conditions before changes are made.
    • Added workflow guidance for task classification, authorization, verification, and final workspace checks.
  • Tests

    • Added coverage for prompt refinement safeguards, workflow requirements, isolation verification, and verifier self-tests.
  • Documentation

    • Recorded the latest review findings and validation checks.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 20 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 79723f03-ae2a-4084-a1d1-4423514689e3

📥 Commits

Reviewing files that changed from the base of the PR and between 5582a7c and 9ce8eb4.

📒 Files selected for processing (3)
  • .agents/skills/prompt-perfector/references/repository-workflow.md
  • docs/branch-review-ledger.md
  • tests/database-skills.test.ts
📝 Walkthrough

Walkthrough

Prompt Perfector guidance now defines explicit prompt-handling and execution controls. Repository workflow documentation and a Git isolation verifier enforce state checks, while tests validate the safeguards and record the review outcome.

Changes

Prompt Perfector safety workflow

Layer / File(s) Summary
Prompt handling and output controls
.agents/skills/prompt-perfector/SKILL.md, .agents/skills/prompt-perfector/agents/openai.yaml
Prompt handling, execution authorization, user-controlled modes, and improved-prompt-only output rules are updated.
Repository workflow and isolation verification
.agents/skills/prompt-perfector/references/repository-workflow.md, .agents/skills/prompt-perfector/scripts/verify-repository-isolation.mjs
Repository task classification, isolated-worktree checks, Git-state validation, dirty-worktree overrides, machine-readable results, and failure exit codes are added.
Skill validation and review record
tests/database-skills.test.ts, docs/branch-review-ledger.md
Tests cover Prompt Perfector safeguards and run the verifier’s 10-case self-test; the review ledger records findings and checks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent as Prompt Perfector agent
  participant Verifier as verify-repository-isolation.mjs
  participant Git as Git repository
  Agent->>Verifier: request repository-state verification
  Verifier->>Git: inspect worktree, branch, HEAD, operations, and status
  Git-->>Verifier: repository state and status hash
  Verifier-->>Agent: safety result, block reasons, and exit status
Loading

Possibly related PRs

  • BigSimmo/Database#455: Hardens agent execution through authorization and workflow-safety controls.
  • BigSimmo/Database#594: Adds repository-local agent workflow, isolated worktree, and Git verification guidance.
  • BigSimmo/Database#959: Updates prompt-oriented agent skills with execution controls and worktree safeguards.

Suggested labels: codex, skip-branch-sync

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo marked this pull request as ready for review July 30, 2026 11:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1611d5ee15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/database-skills.test.ts Outdated
Comment thread docs/branch-review-ledger.md Outdated
Comment thread .agents/skills/prompt-perfector/references/repository-workflow.md Outdated
@BigSimmo
BigSimmo enabled auto-merge (squash) July 30, 2026 13:15
@BigSimmo

Copy link
Copy Markdown
Owner Author

@cursoragent resolve merge conflict

@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Taking a look!

Open in Web Open in Cursor 

…ll-review-e608

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
Owner Author

@cursoragent resolve merge conflict

@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Already done — no new conflict to fix.

PR #1439 is MERGEABLE at tip 39466bb2 (merge-tree clean vs origin/main).
mergeStateStatus: BLOCKED is only waiting on required checks, not a content conflict.

#1439

Open in Web Open in Cursor 

cursoragent and others added 2 commits July 30, 2026 13:19
Resolve main sync fallout by keeping ledger history append-only, aligning
skill contract tests with the workflow text, and documenting a POSIX
bootstrap path when PowerShell is unavailable.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
Owner Author

Closing as superseded by #1434. Current-head comparison confirms #1434 contains the same prompt-perfector SKILL.md and openai.yaml blobs, plus stronger repository-isolation workflow/verifier/tests (Codex Cloud support and content-sensitive dirty-state hashing). Keeping both would duplicate and potentially regress the stronger implementation.

@BigSimmo BigSimmo closed this Jul 30, 2026
auto-merge was automatically disabled July 30, 2026 13:46

Pull request was closed

@BigSimmo

Copy link
Copy Markdown
Owner Author

@cursoragent this PR will be re-opened soon. Please resolve any failing CI, run bugbot and resolve any bugbot comments against current repo and fix any merge conflicts and also fix any errors and address and fix all comments or suggestions that are likely to improve the PR and Codebase. Please implement smallest required fix according to best code practices. Check your work. Leave this PR closed for now but still make all these changes and run the review. I want it ready to go for when I re-open it.

@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR #1439 remains CLOSED and is ready to reopen on branch tip ec809158.

What I fixed

  • Merged origin/main and resolved add/add conflicts without regressing chore: make Codex Cloud setup reproducible #1434’s stronger Cloud + status-hash verifier (14/14 self-tests).
  • Kept this PR’s unique value: a portable POSIX secondary-worktree bootstrap for non-Windows / non-Cloud executors.
  • Consolidated skill contract tests onto the stronger fail-closed suite (refinement + POSIX + Cloud/hash assertions).
  • Restored append-only ledger baseline from main, then appended a reopen-readiness row.

Review / Bugbot / CI

Item Result
Unresolved review threads 0 (all 3 Codex threads already resolved)
Bugbot (cursor findings) None on existing threads
Cursor check suite on new tip Queued only (same stuck pattern seen elsewhere; no findings returned)
Merge vs main clean (merge-tree exit 0)
Unique delta repository-workflow.md, tests/database-skills.test.ts, ledger append

Checks run

  • vitest tests/database-skills.test.ts5/5
  • Isolation self-test → 14/14
  • check:skills, check:branch-review-ledger, lint, typecheck, prettier, runtime, lock parity → pass

Note for reopen

The branch tip is ec809158, but GitHub’s closed PR object still shows old head d432d409. After you reopen, confirm the PR head refreshes to ec809158 (push again if needed). Hosted CI will re-run on reopen.

Open in Web Open in Cursor 

cursoragent and others added 3 commits July 31, 2026 00:15
Keep main's Cloud/status-hash isolation verifier and restore an append-only
ledger baseline, while preserving this branch's portable POSIX secondary
worktree bootstrap and consolidated skill contract coverage.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Capture the post-main-sync review outcome for the closed prompt-perfector
branch so it is ready when the PR is reopened.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Keep the closed PR branch one sync behind-clean before reopen.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
Owner Author

@coderabbitai please run a new review of this closed PR for me

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@BigSimmo: Running a fresh full review of #1439 against its current state.

✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. Your recent PR review activity is in the 95th percentile or higher among CodeRabbit users, so adaptive limits apply. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 36 minutes.

@BigSimmo BigSimmo reopened this Jul 31, 2026
@supabase

supabase Bot commented Jul 31, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@BigSimmo

Copy link
Copy Markdown
Owner Author

@cursoragent Work this open PR (confirm number + GitHub head first). Start from
origin/ matching that head; preserve unrelated local WIP.
Do not merge, force-push, rebase, or arm auto-merge. No provider-backed
gates without approval. If you can’t push or resolve threads: diagnose +
comment only.

Goal: review + Bugbot the tip, fix actionable issues with smallest changes,
clear merge/required-CI/thread blockers, push fixes, post one PR summary.
Stay light — no full local verify:* / Playwright / broad suites unless
needed to prove one concrete fix. Don’t regenerate large assets unless required.

  1. Snapshot tip, behind/ahead, mergeable, merge-tree (real conflict vs
    behind-but-clean), required checks on that tip, unresolved actionable
    threads. Missing checks while dirty ≠ green. If the tip moves mid-work,
    re-snapshot.
    npm run ledger:lookup -- <branch> --scope "PR #<n> review+bugbot+fix".
    If already reviewed at this HEAD/scope and still clean with required checks
    green and no new actionable threads: summarize, comment, stop.

  2. Unblock once: real conflict → merge origin/main (for ledger/issues churn,
    prefer main’s queues, keep this PR’s notes); behind-but-clean → sync once
    (wait if required CI is in flight); else leave. No sync thrash.
    If auto-merge is already armed, push only for a real blocker.

  3. Review + Bugbot the delta vs base. High-confidence only (correctness,
    security, privacy, auth, data loss, migrations/RLS, clinical/RAG/source,
    prod reliability, user-facing). Separate PR-introduced defects from
    pre-existing re-emitted data. For generated assets, review generator/
    contracts/aliases/cache — not every generated line. If RAG/governance
    surfaces are touched, note/fix PR body only when policy text is wrong
    or missing. Ignore bot summary/rate-limit noise.

  4. Fix P0/P1 always; fix clear scoped P2; otherwise short disposition reply
    then resolve. Fix required-check failures on this tip only (ignore advisory).
    Prove with the smallest targeted check only. No broad refactors.

  5. Format + commit before push. Push only this PR’s fix commits. Append ledger
    for the final GitHub head + scope above (--supersede on a requested fresh
    same-HEAD pass). Never push a ledger-only tip.

  6. Post one concise top-level PR comment: tip SHA, sync, fixed vs dispositioned,
    required CI status, residual risks. Leave merge to me. Inline comments only
    for remaining open P0/P1 needing a human decision.

Stop when merge-tree clean, no actionable threads left, and required checks are
green or clearly in progress on the current tip.

@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR #1439 · tip 9ce8eb4fe0a1 · MERGEABLE · merge-tree clean · 0 behind

Snapshot → sync

GitHub DIRTY was behind-but-clean. Merged origin/main (caught one mid-flight main advance). Auto-merge off.

Review + Bugbot

Unique delta: POSIX secondary-worktree bootstrap, skill contract tests, one append-only ledger row (on main’s Cloud/status-hash verifier). No P0/P1; no new Bugbot findings; 0 unresolved threads. Restored ledger to append-only vs main.

CI on tip

SUCCESS: mergeability, policy, change scope, Gitleaks, Semgrep, Safety. In progress: Static PR checks, Unit coverage (PR required still settling).

Posted

Summary comment on the PR. Merge left to you.

Open in Web Open in Cursor 

cursoragent and others added 3 commits July 31, 2026 04:58
Unblock PR #1439: GitHub DIRTY was behind-but-clean vs advanced main.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Catch the one main commit that landed during the prior sync so GitHub can
build refs/pull/1439/merge (local merge-tree already clean).

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Restore docs/branch-review-ledger.md from origin/main and append only the
current review+bugbot+fix record so the PR no longer reorders historical rows.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo enabled auto-merge (squash) July 31, 2026 05:01
@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR #1439 review+bugbot+fix summary

Tip: 9ce8eb4fe0a161b5e27c6467f36105c28c619e38
PR: OPEN · mergeable: MERGEABLE · merge-tree vs origin/main: clean (0 behind)

Sync

  • GitHub DIRTY/CONFLICTING was behind-but-clean (local merge-tree exit 0).
  • Merged origin/main to restore refs/pull/1439/merge (main advanced once mid-flight; caught up).
  • No auto-merge armed.

Review + Bugbot

  • Unique delta: POSIX secondary-worktree bootstrap in repository-workflow.md, consolidated skill contract tests, one append-only ledger row.
  • Keeps main’s stronger Cloud + --expected-status-hash verifier (14/14 self-test).
  • No P0/P1 findings; no new Bugbot/cursor[bot] defect threads.
  • Prior Codex threads remain resolved (0 unresolved).
  • Restored ledger unique delta to append-only vs main (no historical row rewrite).

Fixed vs dispositioned

Item Disposition
Merge conflict / missing PR CI while dirty Fixed — synced main; mergeability SUCCESS on tip
Codex P1/P2 (contract text, ledger order, POSIX bootstrap) Already fixed earlier; still resolved
New Bugbot findings None
Product code defects in tip delta None found

Required CI (tip 9ce8eb4fe0a1)

  • SUCCESS: PR mergeability, PR policy, Change scope, Gitleaks, Semgrep (+ ingestion gate), GitGuardian
  • In progress on this tip: Static PR checks, Safety and config checks, Unit coverage
  • PR required not finished yet — clearly running on this tip

Residual

  • Hosted PR required / Static / Unit still settling on this tip.
  • PR body verification checklist still mentions verifier 10/10 (tip is 14/14); notes-only, not a policy-gate gap.
  • Merge left to you.

@BigSimmo
BigSimmo merged commit d018c4f into main Jul 31, 2026
23 checks passed
@BigSimmo
BigSimmo deleted the codex/chat-prompt-skill-review-e608 branch July 31, 2026 05:05
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.

2 participants