fix: only restart fleet on rebuild & ignore paths#9
Merged
Conversation
ankitgoswami
approved these changes
Apr 21, 2026
🔐 Codex Security Review
Review SummaryOverall Risk: NONE FindingsNo material security, correctness, or reliability issues identified in the reviewed diff. Notes
Generated by Codex Security Review | |
flesher
added a commit
that referenced
this pull request
May 8, 2026
Triage of the parallel adversarial review run on PR #206. Findings applied as code: [P1 #1] activity_log composite-FK MATCH SIMPLE bypass on NULL organization_id closed via CHECK constraint: ck_activity_log_site_requires_org enforces site_id IS NULL OR organization_id IS NOT NULL. Verified: insert with site_id + NULL org rejected; insert with NULL site_id + NULL org accepted (system events unchanged). [P1 #2] command_on_device_log org_id backfill: pre-flight DO block counts orphan rows (codl rows whose device row is missing) and RAISES with a clear message before SET NOT NULL. A clean abort beats SET NOT NULL failing mid-migration with the dirty flag set. [P2 #5] InsertError CTE rewrite: documented the contract change (missing device $3 yields sql.ErrNoRows instead of FK violation). Existing caller wraps generically so surface unchanged. [P2 #6] Plan doc trimmed: power-contract column list marked DEFERRED in entity description and Phase 1 migration bullet. Future readers won't write service code against columns that don't exist. [P2 #7] ListSites count subqueries: added org_id predicate to device and building scans so they hit idx_device_org_site / idx_building_org_deleted instead of full-table scan in multi-tenant prod. [P2 #8] InsertDeviceMetrics sub-select dropped AND deleted_at IS NULL to match InsertError / InsertMinerStateSnapshot. Telemetry from a soft-deleted device is still legitimate per-site history; three writers, one behavior. [P3 #10] building.default_rack_order_index: added ck_building_default_rack_order_index CHECK (BETWEEN 0 AND 4) to match sibling CHECKs. [P3 #11] fk_device_set_rack_device_set_org: added ON DELETE CASCADE to match the single-column FK on device_set_id and the building FK on the same row. Composite adds the org-matching invariant without changing cascade semantics. Findings deferred: - #3 (non-CONCURRENTLY indexes inside tx): deploy-time concern, document in PR/deploy notes; restructuring migrations to use CONCURRENTLY is a separate effort. - #4 (no integration tests): defer to Phase 1B service layer where end-to-end flows exercise the invariants. - #9 (device.uq_device_id_org_id missing): already exists (verified on live DB); finding is incorrect. - #12 (CREATE TABLE IF NOT EXISTS): IF NOT EXISTS hides genuine schema errors; force-clean is the right golang-migrate pattern. Round-trip clean, build clean, lint clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Earlier
timescaledbwould stop whenever a rebuild of the go server started.This prevents that case and also ignores more files that would cause unnecessary rebuilds.