Repository navigation
ci(requirements-sync): commit nightly migration straight to master #884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,8 +4,16 @@ name: Requirements Sync | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # It detects drift between the committed requirements DB (requirements/seed.sql + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # migrations) and the live state of GitHub Project #43, then has Claude write a new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # numbered migration capturing the delta and open a PR for human review. Nothing is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # committed to the source of truth without that review. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # numbered migration capturing the delta and commit it straight to master. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # There is no PR and no human review on this path — deliberately. PR merges on this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # repo are blocked by an org-level required-review ruleset that the bot cannot satisfy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # and cannot bypass, so nightly sync PRs simply accumulated unmerged. Direct pushes to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # master are not gated by that ruleset, so the bot pushes. The safety net is therefore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # entirely pre-push: the "Independent build & integrity gate" step below builds the DB and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # runs integrity + foreign-key checks BEFORE the commit reaches master, and hard-fails the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # run without pushing if anything is wrong. Keep that gate ahead of the push — moving it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # after would mean a bad migration lands on master and only then goes red. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Drift in scope: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # (a) new requirements — issues that have newly reached "Refined Tickets" or beyond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -20,7 +28,9 @@ on: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Read-only: the job reads each issue's merged closing PRs to derive impl_commit_sha / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # impl_paths, but no longer opens or merges any PR of its own. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull-requests: read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -170,33 +180,40 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version once, and put all the change rows at that same new version (one logical edit). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NEVER delete a requirement or move it to a lower status, even if an issue dropped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| below the gate or was removed — refs are never reused. If you see such a case, note | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it in the PR body for a human to handle (do not change the row). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it in your final output for a human to handle (do not change the row). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## 6. Verify before opening a PR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## 6. Verify your own work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Run `yarn requirements:build` — it must succeed. Then run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `sqlite3 requirements/requirements.db "PRAGMA integrity_check; PRAGMA foreign_key_check;"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| — integrity must be 'ok' and foreign_key_check must be empty. If either fails, fix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| the migration; if you cannot, do NOT open a PR — exit with an error instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## 7. Open (or update) the PR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| First check for an existing open PR from a branch matching `chore/requirements-sync-*` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (`gh pr list --state open --head ...`). If one exists, commit onto THAT branch and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| push (do not open a duplicate). Otherwise create branch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `chore/requirements-sync-<YYYY-MM-DD>`, commit only the new migration file, push, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `gh pr create` against master. The PR body must summarise the delta: counts of new / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status-changed / impl-changed requirements with their REQ refs, and any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| below-the-gate cases noted for a human. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| the migration. If you cannot fix it, DELETE the migration file you scaffolded and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit with an error. Do not leave a broken migration in the working tree: a later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| step in this workflow commits whatever migration it finds there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## 7. Stop — do NOT commit, push, branch, or open a PR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Leave the new migration file in the working tree, uncommitted. A later step in this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow re-verifies it independently and commits it straight to master. You have no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git or gh write access in this job, by design — do not create a branch, do not commit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| do not push, do not open a PR. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Finish by printing a summary of the delta to stdout: counts of new / status-changed / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| impl-changed requirements with their REQ refs, and any below-the-gate cases a human | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| needs to look at. Nobody reviews a PR on this path, so that output is the run's only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| human-readable audit record — make it complete. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| claude_args: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --dangerously-skip-permissions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --append-system-prompt "You are running in a scheduled GitHub Action to sync the requirements database. Read @CLAUDE.md and the requirements/ SQL files. Be precise: this is an append-only audit log. If there is no drift, do nothing and open no PR. Never hard-delete or down-status a requirement." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --allowedTools "Read,Glob,Grep,Write,Edit,Bash(corepack:*),Bash(yarn:*),Bash(git:*),Bash(gh:*),Bash(sqlite3:*),Bash(./requirements/scripts/new_migration.sh:*)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --append-system-prompt "You are running in a scheduled GitHub Action to sync the requirements database. Read @CLAUDE.md and the requirements/ SQL files. Be precise: this is an append-only audit log. If there is no drift, do nothing and write no migration. Never hard-delete or down-status a requirement. You do not commit or push: leave the migration file uncommitted in the working tree and a later workflow step verifies and commits it." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --allowedTools "Read,Glob,Grep,Write,Edit,Bash(corepack:*),Bash(yarn:*),Bash(git status:*),Bash(git diff:*),Bash(gh api:*),Bash(sqlite3:*),Bash(./requirements/scripts/new_migration.sh:*)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Independent build & integrity gate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: always() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Defense in depth: re-verify whatever migrations now exist in the working tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # (including any Claude just wrote), independent of Claude's own checks. A bad | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # migration must never sit in a green PR. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # (including any Claude just wrote), independent of Claude's own checks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This step MUST stay ahead of the push step below. It is the only thing standing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # between a bad migration and master — there is no PR review on this path, so a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # failure here has to stop the push rather than annotate it after the fact. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yarn requirements:build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result=$(sqlite3 requirements/requirements.db "PRAGMA integrity_check;") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -210,3 +227,82 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✓ requirements DB builds clean and passes integrity checks" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # No `if:` — defaults to success(), so this is skipped whenever the Claude step or the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # integrity gate above failed. Never weaken this to always(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Commit migration to master | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Only ever stage migrations — that is the source of truth this job owns. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -z "$(git status --porcelain -- requirements/migrations)" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "No migration written — nothing to commit. This is the normal no-drift outcome." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # requirements/requirements.db is listed in .gitignore but was committed before that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # rule existed, so it is still TRACKED and every `yarn requirements:build` shows it as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # modified. Discard that churn: it is a build artefact, it must not ride along in this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # commit, and leaving the tree dirty would make the rebase below refuse to run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git checkout -- requirements/requirements.db 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stray=$(git status --porcelain | grep -v ' requirements/migrations/' || true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "$stray" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::warning::ignoring unexpected working-tree changes outside requirements/migrations/:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$stray" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git add -- requirements/migrations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git status --porcelain -- requirements/migrations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+240
to
+259
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Stray working-tree changes are warned about but not discarded, and can abort the rebase. Line 248's own comment explains that Either fail fast when ♻️ Suggested fix stray=$(git status --porcelain | grep -v ' requirements/migrations/' || true)
if [ -n "$stray" ]; then
- echo "::warning::ignoring unexpected working-tree changes outside requirements/migrations/:"
- echo "$stray"
+ echo "::error::unexpected working-tree changes outside requirements/migrations/ — refusing to commit:"
+ echo "$stray"
+ exit 1
fi📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git commit -m "chore(requirements): sync github $(date -u +%F)" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -m "Automated nightly sync of the requirements DB from GitHub Project #43. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Committed directly to master by the requirements-sync workflow: PR merges are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| blocked by an org-level required-review ruleset the bot cannot satisfy. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| migration passed yarn requirements:build, PRAGMA integrity_check and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PRAGMA foreign_key_check before this commit was created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # master may have moved while this ~30 minute job ran. Rebase onto whatever is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # there now and re-run the integrity gate before pushing, because a migration that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # was valid against the old master can collide with one that landed since (this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # exactly the duplicate-numbering/duplicate-id class of failure). Never force-push. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for attempt in 1 2 3; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git fetch origin master | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # The verification below rebuilds the tracked .db artefact; drop that churn so the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # next rebase attempt starts from a clean tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git checkout -- requirements/requirements.db 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! git rebase origin/master; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git rebase --abort || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::migration conflicts with master (attempt ${attempt}) — not pushing. Re-run the workflow; it will re-derive the delta against the new master." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # The rebase may have pulled in another migration alongside ours. Re-verify. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yarn requirements:build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result=$(sqlite3 requirements/requirements.db "PRAGMA integrity_check;") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$result" != "ok" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::integrity_check failed after rebasing onto master: $result" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fk=$(sqlite3 requirements/requirements.db "PRAGMA foreign_key_check;") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "$fk" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::foreign_key_check failed after rebasing onto master: $fk" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if git push origin HEAD:master; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✓ pushed $(git rev-parse --short HEAD) to master" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::warning::push rejected (attempt ${attempt}/3) — master moved, retrying" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "::error::could not push to master after 3 attempts" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
claude code CLI --dangerously-skip-permissions ignores --allowedTools restriction documented behavior💡 Result:
In the Claude Code CLI, the flag --dangerously-skip-permissions (and its equivalent, --permission-mode bypassPermissions) effectively bypasses the permission prompt system entirely [1][2][3]. Users and security researchers have reported that when these bypass flags are active, the --allowedTools restriction is not enforced, meaning the model can execute tools not included in the allowed list [4][5]. Although the official CLI documentation lists --allowedTools as a mechanism to specify tools that execute without prompting [1][6], it does not explicitly state that this restriction is guaranteed to be enforced when permission bypass flags are engaged. In practice, this creates a behavior where the bypass mode overrides the tool allow-listing, rendering --allowedTools ineffective at restricting tool access in those sessions [4][5]. Consequently, using --dangerously-skip-permissions is considered a high-risk configuration that removes the safety layer provided by tool restrictions [7][2][8]. Some users have suggested using --disallowedTools as a potential alternative for restricting specific actions in bypass mode, though this is also subject to the limitations of the bypass configuration [9].
Citations:
--allowedToolshas no effect when permission bypass flags are active anthropics/claude-code#50303🏁 Script executed:
Repository: hmcts/cath-service
Length of output: 13645
🏁 Script executed:
Repository: hmcts/cath-service
Length of output: 12841
🌐 Web query:
Claude Code CLI --disallowedTools bypassPermissions --dangerously-skip-permissions documentation💡 Result:
The --dangerously-skip-permissions flag in the Claude Code CLI is used to disable interactive permission prompts, allowing the agent to execute actions such as shell commands, file edits, and tool calls automatically without pausing for user approval [1][2]. Key points regarding this flag: Functionality: Setting this flag is equivalent to launching the CLI with --permission-mode bypassPermissions [3][4][5]. When active, Claude Code skips the evaluation layer that normally requires user confirmation for most tool uses [1]. Safety and Limitations: - Circuit Breakers: Despite the bypass, certain operations still trigger prompts as a safety measure, including removals that target the filesystem root or home directory (e.g., rm -rf / or rm -rf ~) [6][1]. - Security Restrictions: For security reasons, the flag cannot be used when running Claude Code with root or sudo privileges [4][7]. - Tool Constraints: Notably, when bypass mode is active, established tool restrictions—such as --allowedTools or --disallowedTools—may be ignored, meaning the model can potentially access and use tools that would otherwise be restricted [8]. Alternatives: Because of the risks involved, Anthropic recommends using it only in isolated environments like containers or VMs [6][9]. For scenarios where you want to reduce prompt fatigue without fully disabling safety checks, the official "auto" permission mode is recommended, as it uses a model-based classifier to approve routine actions while still flagging potentially unsafe ones [10][1][7]. Configuration: - Mode Toggling: You can use --allow-dangerously-skip-permissions to add the bypass mode to the Shift+Tab cycle, allowing you to switch into it mid-session without needing to restart [3][5]. - Prevention: To prevent the use of this mode in managed or team environments, administrators can set permissions.disableBypassPermissionsMode to "disable" in settings files [6][9]. Top results: [3][6][8][4][1][5]
Citations:
--allowedToolshas no effect when permission bypass flags are active anthropics/claude-code#50303🌐 Web query:
Claude Code GitHub issue#50303--allowedTools ignored --dangerously-skip-permissions --permission-mode bypassPermissions💡 Result:
GitHub issue
#50303in the anthropics/claude-code repository documents a confirmed bug where the --allowedTools flag is ignored when using permission bypass flags, specifically --dangerously-skip-permissions or --permission-mode bypassPermissions [1]. Official documentation clarifies that this behavior is by design regarding the operation of bypass modes [2][3][4]. When permission mode is set to bypassPermissions, the system automatically approves every tool call that reaches the permission evaluation step, regardless of whether that tool is listed in an allowlist like --allowedTools [2]. In this mode, --allowedTools only serves to pre-approve listed tools, while unlisted tools fall through to the bypass mechanism and are subsequently approved [2]. The issue was closed as not_planned by automation [1]. If restrictive control over specific tools is required while operating in a headless or non-interactive environment, documentation suggests using --disallowedTools (blacklist) instead of --allowedTools (whitelist) [2], or utilizing the Agent SDK's canUseTool callback, which remains effective even when bypassPermissions is enabled [5]. Additional security measures include using managed settings to disable bypass modes entirely across an organization by setting permissions.disableBypassPermissionsMode to disable [3][4].Citations:
--allowedToolshas no effect when permission bypass flags are active anthropics/claude-code#50303Do not rely on
--allowedToolsto block git/gh write commands in bypass mode.With
--dangerously-skip-permissions, tool restrictions can be bypassed, so this job is still configured to commit uncommitted Claude output and the token remains available forgit commit/git push. Remove the auto-commit from this workflow or make Claude output in an isolated location without commit privileges, then keep the commit step strictly in a separate step that does not pass Claude/GitHub token access, even as a fallback if Claude writes outsiderequirements/migrations.