diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 5140e395..fcf22986 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -109,9 +109,11 @@ loading the delivery [commands](../src/loopzero/cli.py), which implement the con target branch and required CI. The receipt must record a clean passing run at that head with the current commands and check settings digest. A settings change or an older receipt without the digest requires a fresh check. The - digest covers execution and stage reuse settings, including the effective - allowlisted environment, without recording raw environment values. Waiters - check for policy changes on every poll. + digest covers execution and stage reuse settings without recording raw + environment values. It excludes only inherited `HEAVY_SLOT_GRANTED_CORES` + for local sandbox receipts. Explicit settings, delegated runner environments + and stage reuse keys still bind the grant. Waiters check for policy changes + on every poll. Local readiness and hosted eligibility carry a review forward only across a first-parent chain of verified merges from the configured PR base. They reconstruct each merge in an isolated Git repository and compare its tree diff --git a/src/loopzero/sandbox.py b/src/loopzero/sandbox.py index 5edb2449..6f725e28 100644 --- a/src/loopzero/sandbox.py +++ b/src/loopzero/sandbox.py @@ -253,6 +253,9 @@ def settings_fingerprint(config: Config, worktree: Path, *, base: str | None = N settings = _execution_settings(config, base) if config.check_runner and settings["runner_executable"] is None: return None + if not config.check_runner and "HEAVY_SLOT_GRANTED_CORES" not in config.env: + # The inherited local worker limit is transient. Stage reuse still binds it. + settings["environment"].pop("HEAVY_SLOT_GRANTED_CORES", None) payload = [settings, config.inputs] return hashlib.sha256(json.dumps(payload, sort_keys=True).encode()).hexdigest() diff --git a/tests/test_sandbox.py b/tests/test_sandbox.py index ecff7435..674e4d8a 100644 --- a/tests/test_sandbox.py +++ b/tests/test_sandbox.py @@ -749,10 +749,13 @@ def cache(config, *, clean=False, verify_reuse=False): @pytest.mark.parametrize('change', ['other', 'input', 'shared', 'command', 'network', 'environment', 'version', 'failed', 'boolean_exit_code', 'dirty_receipt', 'keyless', - 'dirty_tree', 'legacy']) + 'dirty_tree', 'legacy', 'grant']) def test_declared_input_reuse(git_repo, bwrap_log, monkeypatch, fetched_base, change): cfg = make_config(checks=('echo one', 'echo two'), inputs={'echo one': ('*.md',), 'echo two': ('*.md',), '*': ('shared',)}) + if change == 'grant': + cfg = replace(cfg, env_allowlist=(*cfg.env_allowlist, "HEAVY_SLOT_GRANTED_CORES")) + monkeypatch.setenv("HEAVY_SLOT_GRANTED_CORES", "2") for inputs in ({}, {'*': ()}, {'*': ('uv.lock',)}): assert sandbox._input_key(replace(cfg, inputs=inputs), git_repo, 'unlisted', fetched_base) is None whole = replace(cfg, inputs={'*': ('.',)}) @@ -776,6 +779,12 @@ def test_declared_input_reuse(git_repo, bwrap_log, monkeypatch, fetched_base, ch cfg = replace(cfg, network=True) elif change == 'environment': monkeypatch.setenv('LZ_KEEP', 'changed') + assert _current_check_report(git_repo, cfg, fetched_base) is None + elif change == 'grant': + monkeypatch.setenv("HEAVY_SLOT_GRANTED_CORES", "4") + assert _current_check_report(git_repo, cfg, fetched_base) is not None + monkeypatch.delenv("HEAVY_SLOT_GRANTED_CORES") + assert _current_check_report(git_repo, cfg, fetched_base) is not None elif change == 'version': monkeypatch.setattr(sandbox, '__version__', 'new') else: