Repository navigation
Prove the release gate blocks a disposable container deploy - #6
Conversation
The example workflow only printed a message after the gate proof. Deployments now go through ReleaseDeployer, which refuses a locked gate, rolls a local container back, and deploys again after recovery. Audit rows are HMAC-chained, and a failed insert rolls the privileged write back. Co-authored-by: Angel L. Pinzon <angelpinzon1706@gmail.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Passing the archive through a Ruby string failed on CI when the locale was UTF-8. Docker now imports the tar file directly. Co-authored-by: Angel L. Pinzon <angelpinzon1706@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d728cf3c4
ℹ️ 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".
| ActiveRecord::Base.transaction do | ||
| budget = BudgetEvaluator.new.evaluate!(shard: shard) |
There was a problem hiding this comment.
Acquire audit and budget locks in a consistent order
On PostgreSQL, concurrent evaluation and manual budget_guard requests for the same shard can deadlock. This transaction first obtains the error-budget row lock through BudgetEvaluator, then requests the audit advisory lock. Conversely, AgentsController#run uses with_audited_mutation to obtain the audit advisory lock before BudgetGuardAgent#execute updates that same budget row. Each request can therefore wait on the other's lock, causing PostgreSQL to abort one operation. Acquire these locks in a consistent order while preserving AGENTS.md's same-transaction audit/write requirement.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
| canonical_json(metadata) | ||
| ].join("\n") | ||
| Digest::SHA256.hexdigest(payload) |
There was a problem hiding this comment.
Use unambiguous serialization for signed audit fields
When a signed string contains a newline, joining the fields with newline separators permits different field values to produce the same digest. For example, action incident_resolved with justification approved\nby ops hashes identically to action incident_resolved\napproved with justification by ops. A direct database edit can therefore change those fields without invalidating either the HMAC or chain_intact?, contrary to the stored-field tamper-detection invariant in AGENTS.md. Encode the complete payload as a canonical JSON array/object or another length-delimited representation before hashing.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
| def self.payload_digest(sequence:, shard_id:, actor:, action:, justification:, prev_digest:, metadata:) | ||
| payload = [ |
There was a problem hiding this comment.
Include audit timestamps in the authenticated payload
A database writer can change an audit row's created_at while both authentic? and chain_intact? continue to return true, because the digest never includes that column. This affects operator-visible evidence: AuditLogsController#index orders and limits records by created_at, and returns that timestamp, so an undetected edit can reorder events or move a record outside the latest-50 feed. Seal and verify the persisted timestamp as part of the payload to satisfy AGENTS.md's stored-field tamper-detection invariant.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
Evaluation and agent runs now lock the shard row, then the error-budget row, then the audit chain. Signatures use a canonical JSON payload that includes created_at, so a timestamp edit or a newline inside a field fails verification. Co-authored-by: Angel L. Pinzon <angelpinzon1706@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74037fb865
ℹ️ 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".
| with_audited_mutation( | ||
| action: "agent_toggle", | ||
| shard: Shard.find_by(name: "shard-default"), |
There was a problem hiding this comment.
Resolve a persisted audit shard for global agent operations
When the database contains only custom shards and has not loaded the demo seeds, Shard.find_by(name: "shard-default") returns nil. The new audit-first wrapper then raises AuditLog::PersistenceError in seal!, so an otherwise valid global agent toggle returns HTTP 503 without updating its configuration; both run_all branches have the same dependency. Previously these operations worked without the demo shard because the audit helper skipped nil shards. Resolve or create a persisted audit scope for these global operations while retaining the required transactional audit, rather than making them depend on optional demo seed data.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d673c3d32
ℹ️ 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".
| configured = ENV["CELLGUARD_AUDIT_HMAC_KEY"].to_s | ||
| unless configured.empty? | ||
| raise PersistenceError, "audit signing key must be at least 32 bytes" if configured.bytesize < 32 |
There was a problem hiding this comment.
Document the new audit signing key in README.md
The new CELLGUARD_AUDIT_HMAC_KEY setting is documented in docs/DEPLOYMENT.md and AGENTS.md, but is absent from README.md. This violates the root AGENTS.md requirement to document every new environment variable in both README and the deployment guide. Add the setting, its minimum 32-byte length, and the SECRET_KEY_BASE fallback to README so readers can discover how audit signing is configured.
AGENTS.md reference: AGENTS.md:L341-L341
Useful? React with 👍 / 👎.
Summary
The release gate already returned HTTP 200/423, but the example deploy workflow only printed a message. This change makes a real disposable deployment honor that decision, and closes the related audit, remediation, agent, and Go coverage gaps.
ReleaseDeployerdeploys only when the gate is open. A locked gate leaves the running container untouched. Rollback restores the previous revision while the gate is still locked, and a later revision deploys after fresh healthy observations reopen the gate./bin/busybox. No registry pull and no paid infrastructure.make deploy-proofand the Deploy workflow run that proof.audit_unavailable(HTTP 503).AuditLog.chain_intact?. OptionalCELLGUARD_AUDIT_HMAC_KEY(at least 32 bytes) overrides the key derived fromSECRET_KEY_BASE.AgentSchedulerJobplusAgentRunJob#performrunsbudget_guard,chaos_orchestrator,incident_response, andhealing.Verification
RAILS_ENV=test bundle exec rails test— 50 runs, 198 assertions, 0 failuresmake go-classifier-testandgo build ./cmd/classifiermake go-agent-runner-testandgo build ./cmd/runnertest/integration/gated_deploy_test.rbdeployedrev-aandrev-b, refusedrev-cwhile locked, rolled back torev-a, then deployedrev-dafter recoveryA caller that never uses
ReleaseDeployercan still deploy elsewhere. Audit verification is local: there is no external write-once ledger, and a database superuser can delete rows, which breaks the chain check.