Repository navigation
deploy: sandbox quota-recorder target + generic unit restorer (#5770) - #12753
Merged
Merged
Conversation
M3 of the deployment migration (design doc section 4.4): - pkgs/deploy/quota-recorder.py + .nix: the live quota-recorder script becomes a flake package (bin/quota-recorder), byte-identical to the script running today. - services.nix: quota-recorder as the first sandbox-class deploy target — timer-driven oneshot (OnCalendar *:0/5), secret by name only (turso.fleet-platform-rw-token), no ports, no health endpoint. - deploy.py: one shape extension — an optional, strictly validated 'timer' field; sandbox activation class: generations under ~/.local/share/deploy/profiles, rendered units stored inside the generation, activated targets recorded in a sandbox manifest, activation links units into /etc/systemd/system and enables the timer (or service); rollback flips back with the same semantics as the systemd class; a 'restore' verb re-activates every manifest target after a recycle. - pkgs/deploy/restore.py: standalone stdlib restorer for boot time (no nix build at hand), strict argv per the operator-script contract; test_deploy_slice4.py covers both restorers, the timer validation, deploy/rollback/restore against a fake systemctl (22 tests). - scripts/muse/bootstrap.sh: persist phase installs the restorer to ~/tools/deploy-restore.py, hooks it into init.sh, and removes the legacy per-service quota-recorder block it replaces; check phase reports the timer state when a sandbox manifest exists. - Registry + design doc: quota-recorder.timer row in the new sandbox system-timers subsection; dated amendment recording the timer field and the sandbox class. - lib: deploy-slice4-tests check; deploy-list greps quota-recorder. No new dependencies (stdlib only).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 37 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Implements M3 of the deployment migration for #5770 (design doc §4.4): the sandbox quota-recorder as a deploy target, plus the generic unit restorer in the sandbox bootstrap. One shape extension, flagged on #5770: an optional, strictly validated
timerfield — the §3 shape had no way to express a timer-driven oneshot.What lands
pkgs/deploy/quota-recorder.py+quota-recorder.nix: the live recorder script becomes a flake package (bin/quota-recorder); the packaged script is byte-identical to the one running today (cmpverified).services.nix:quota-recorder— first sandbox-class target. Timer-driven oneshot (OnCalendar=*:0/5, Persistent, RandomizedDelaySec=20), secret by name only (turso.fleet-platform-rw-token), no ports, no health endpoint.deploy.py:timervalidation; thesandboxactivation class — generations under~/.local/share/deploy/profiles(home is what survives a recycle), rendered units stored inside the generation, activated targets recorded in<state-dir>/sandbox-manifest.json, activation links units into/etc/systemd/systemand enables the timer (or the service); rollback flips back with the systemd class's semantics; arestoreverb re-activates every manifest target.pkgs/deploy/restore.py: standalone stdlib restorer for boot time (no nix build at hand), strict argv per the Design: unknown means stop — one strict argument contract for the repo's operator scripts #3352 contract.scripts/muse/bootstrap.sh: persist phase installs the restorer to~/tools/deploy-restore.py, hooks it intoinit.shafter the shebang, and removes the legacy per-service quota-recorder block it replaces; check phase reports the timer state when a manifest exists.quota-recorder.timerrow in a new sandbox system-timers subsection ofdoc/fleet-schedule-registry.md; dated §3 amendment recording thetimerfield and the sandbox class.lib:deploy-slice4-testscheck;deploy-listgrepsquota-recorder.No new dependencies (stdlib only; the package uses the existing python3 + makeWrapper).
Verification (venue: the muse sandbox itself)
test_deploy_slice4.py— 22/22 pass (timer validation, rendering, deploy/rollback/restore against a fake systemctl, both restorers, strict argv). Pre-existing suites unchanged: slice2, argv, argv-property, dupkeys-property, target-shape-property pass; slice3 has one failure (test_store_path_artifact_registers_with_nix_env_first) that fails identically on pristine HEAD here —nix-envis not on this sandbox's PATH; environmental, not a regression.nix eval .#deployTargets.x86_64-linuxlistsquota-recorder; the registry JSON was produced by pure evaluation (per the build: nix build .#deploy wedges in mcpx check phase (go test idle, no test binary); registry build realizes every target package #12738 hazard,nix build .#deploywas not used);nix build .#deployTargets.x86_64-linux.quota-recorder.packagebuilt the artifact and its outPath matches the evaluation.turso-ackline to the current month's JSONL (the recorder's data path is unchanged — file-first, Turso landing per the design: move agent append streams (agent.events, agent.quota_records) from Supabase to Turso staging #5690 cutover; the issue's "Supabase acks" wording predates it). Generation 2 deployed;rollbackreturned to generation 1 with links repointed and the timer active;statusreads both generations back.~/tools/deploy-restore.pyas init.sh invokes it — units relinked from the current generation, timer active again, zero hand steps. The literal done-when's "actual sandbox recycle" is substituted by this simulation of exactly what a recycle wipes; the restorer hook is installed in the live~/tools/init.shand the bespoke block is removed there too.Not merged — for Felix's review. #5770 stays open for Felix to close.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.