Skip to content

sbx-mgr store: typed accessor for the live network-policy gateway read - #1016

Merged
ac-pplx merged 1 commit into
mainfrom
ac/sbxmgr-store-gateway-accessor
Oct 27, 2026
Merged

ac-pplx merged 1 commit into
mainfrom
ac/sbxmgr-store-gateway-accessor

Conversation

@ac-pplx

@ac-pplx ac-pplx commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#714 added has_live_network_policy_gateway as a public sbx-mgr store reader and called it from the server. #715 (typed db::read views) and #721 (old readers non-public outside tests) landed after it without a view for it, so #721 left it public. It was the one flat crate::db sandbox reader that production code outside the store still called directly.

  • Accessor: SandboxView::live_network_policy_gateway() is one call to the reader, with the same id, strictness and error. It answers whether a row has netgtw_pid IS NOT NULL AND pool_template IS NULL, and returns false without a row.
  • Call site: the server's template network-policy update (sandbox_network_policy.rs) now calls crate::db::read::sandbox_view(&db, &sandbox.id).live_network_policy_gateway(). The connection guard, lock scope and map_err text are unchanged.
  • Narrowed reader: has_live_network_policy_gateway is declared with db_private_outside_tests!. The store's own &tx callers in update_network_policy_override and clear_local_network_policy and its tests keep using it.
  • Tests: the accessor table in store/src/db/read/tests.rs checks the view and the old reader against fixed expectations. On the main row, which has a registered gateway, they are [T, T, F, T] across Accepting, CorruptJson, MissingRow and PreviousWithoutCurrent. On the paused row, which has none, they are [F, F, F, F].

Validation

At b43d9dc6:

Check Result
bash ci/scripts/run-rust-checks.sh fmt pass
bash ci/scripts/run-rust-checks.sh clippy, including all three sbx-mgr production feature sets pass
cargo arch, with the base baseline, renames and architecture from main pass; 0 required findings, none in the changed files
SPACE_CI_REQUIRE_TEST_DEPS=1 cargo nextest run --locked over pplx-space-sbx-mgr, -sbx-mgr-store, -db-migrate, -db-migrator, -db-test-fixtures 1962 passed, 1 skipped (the #[ignore]d transfer_directory::tests::distinct_service_uids_can_exchange_downloads)
Mutation: accessor returns Ok(true) fails: live_network_policy_gateway without a gateway on Accepting (True vs False)
Mutation: accessor returns Ok(false) fails: live_network_policy_gateway on Accepting (False vs True)
Production clippy (no test-support) with the server call reverted to crate::db::has_live_network_policy_gateway fails: E0603 function has_live_network_policy_gateway is private; passes again once restored

Kind was not run.

Severity and risk

Severity: does not apply (an API-boundary cleanup). Risk: low. The production read runs the same statement on the same connection guard. Roll back by reverting this commit.

AI assistance: Claude Code drafted the code, tests and this description.

#714 added has_live_network_policy_gateway as a public store reader after
#715 introduced the typed db::read views and #721 made the old readers
non-public outside tests. It was the one reader left without a typed
accessor, so production code outside the store still called it directly.

Add SandboxView::live_network_policy_gateway, one call to the reader with
the same id, strictness and error: whether a row has
netgtw_pid IS NOT NULL AND pool_template IS NULL, false without a row.
Convert the server's template network-policy update to it, under the same
connection guard and with the same error mapping. Declare the reader with
db_private_outside_tests!, so production code outside db can no longer
reach it; the store's own transaction callers and tests still do.

The accessor table checks the view and the old reader on the main row
(registered gateway: true, true, false without a row, true) and on the
paused row (no gateway: false in every fixture).
@github-actions github-actions Bot added the triage:pending Waiting for a maintainer to triage label Oct 27, 2026
@github-actions

Copy link
Copy Markdown

Thanks for opening this pull request! A SPACE maintainer will take a look.

CONTRIBUTING.md explains how we review outside contributions.

@ac-pplx
ac-pplx marked this pull request as ready for review October 27, 2026 20:13
@ac-pplx
ac-pplx added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 224e555 Oct 27, 2026
25 checks passed
@ac-pplx
ac-pplx deleted the ac/sbxmgr-store-gateway-accessor branch October 27, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:pending Waiting for a maintainer to triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants