diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7ca58..7fee91e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Align the skills updater with current main protection. The reviewed merge contract now requires strict `validate` and `Privacy Guard` (both GitHub Actions app 15368), and auto-merge waits until every required check has succeeded on the exact PR head. Scheduled runs had been stopping because the contract listed only `validate`. + - Extend `Privacy Guard` with optional `.privacy-baseline` support, so the required commit-metadata check can scan `baseline..HEAD` on push when historical exposure has been accepted. Mirrors vllnt/skills. - Accept the reviewed Skills `v0.2.0` update from `7483dd4dfd8502fd2db376c13e44fa0cbc464161` to `06365b10b42d1c56308b946187d51ccf1efa7d33` as `0.1.0-canary.9` through a separate protected PR, because the range changes sensitive paths. Adds the `init-project` workflow (replacing `build-project`), defaults packages to the newest stable release behind the 7-day age gate, defers fast-changing tool detail to official docs, and adds machine security and privacy workflows. The automatic sensitivity policy is unchanged. diff --git a/README.md b/README.md index 55a5d18..3f49731 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ To retire a closed, unmerged automation PR after human review: An existing ordinary open PR still requires full deterministic reconstruction before it can be updated; historical acknowledgements do not relax that proof or any live manual hold. -Before publication and merge, source and destination heads are rechecked. Merge requires the reviewed main protection contract (strict `validate` from GitHub Actions app 15368, administrators enforced, zero required approving reviews, no force pushes/deletions), observed successful checks at the exact candidate head, and a normal squash-merge API call fenced by that head. No admin bypass, direct main push, protection change, release, or marketplace publication occurs. CI and post-push PR-head propagation waiting share a bound of about five minutes. Only the exact previous generated head may be awaited while the branch ref is either that previous head or the new candidate; an unexpected head or any manual hold still stops immediately. Checks and merging require the new exact PR head. Missing, failed, skipped, or cancelled evidence leaves the PR open and fails the run. API errors and uncertain writes fail visibly rather than blindly retrying. An orphaned branch after an uncertain PR creation needs human inspection. Concurrent runs serialize without cancellation. +Before publication and merge, source and destination heads are rechecked. Merge requires the reviewed main protection contract (strict `validate` and `Privacy Guard`, both from GitHub Actions app 15368, administrators enforced, zero required approving reviews, no force pushes/deletions), observed success of every required check at the exact candidate head, and a normal squash-merge API call fenced by that head. No admin bypass, direct main push, protection change, release, or marketplace publication occurs. CI and post-push PR-head propagation waiting share a bound of about five minutes. Only the exact previous generated head may be awaited while the branch ref is either that previous head or the new candidate; an unexpected head or any manual hold still stops immediately. Checks and merging require the new exact PR head. Missing, failed, skipped, or cancelled evidence leaves the PR open and fails the run. API errors and uncertain writes fail visibly rather than blindly retrying. An orphaned branch after an uncertain PR creation needs human inspection. Concurrent runs serialize without cancellation. There is no atomic GitHub API transaction covering upstream refs, destination refs, and PR metadata. Immediate rechecks plus branch leases, merge head fences, and strict required checks narrow those races; a last-instant source update is handled on the next run. Branch protection remains the merge authority. @@ -151,6 +151,8 @@ Automatic repository synchronization was independently verified on 2026-09-21. A Live testing caught a generated-help false hold and post-push PR-head propagation timing; fixes were reviewed and merged through PRs #5 and #6, with 37 regression tests passing. The fresh PR #7 case required neither manual metadata repair nor manual merge. Daily fallback is configured; its timer was not waited for. Push delivery, manual resends, automatic merging, and manual no-op execution were observed. +Scheduled updater runs from 2026-11-20 through 2026-11-23, including [run 45236891171](https://github.com/vllnt/stack/actions/runs/45236891171), stopped before any write: the reviewed contract listed only `validate` while main protection also required `Privacy Guard` (GitHub Actions app 15368). The check rollup on merged PR #30 marks those two checks required and leaves CodeQL and the Analyze jobs optional. Unit tests cover the updated contract; a hosted updater run after this change merges is still required to show the schedule continues. + Claude Code 2.1.283 (2026-09-27): `claude plugin validate` passes for the catalog and plugin; a local-directory marketplace install into an isolated configuration installed the `vstack` plugin with all 22 skills, and a maintainer session with the local install listed every `vstack:*` skill. After `vllnt/stack` became public (merge `c3ad08c08fe460ed4f2e1a40630afe4001ddd23c`), an anonymous clone succeeded, and the CLI equivalents `claude plugin marketplace add vllnt/stack` plus the matching `claude plugin install` command in a clean, credential-free configuration installed the plugin from the GitHub source; a headless session there listed exactly the 22 `vstack:*` skills. The same commands after merge `915a4d0d519d726f84185ec698b3ed3f4c925cb8` installed it again with its icon, updated description, and 22 skills. The in-chat `/plugin` forms were not run separately. The marketplace listing later rejected that SVG icon (a PNG embedded in SVG) as `ICON_INVALID`; the replacement `.claude-plugin/icon.png` passes `claude plugin validate --strict`, but its marketplace acceptance and rendering remain unverified. The marketplace was later renamed to `vllnt`; see the changelog for migrating earlier installs. Skill invocation behavior (including `plan-work` staying read-only), automatic skill selection, and the rest of the acceptance checklist remain unverified. **Codex and Cursor installation, and startup/context-loss behavior in every host, remain unverified.** The repository is public and installable as a GitHub marketplace. A Claude plugin directory submission is in validation and is not listed yet. Canary builds are published as [GitHub prereleases](https://github.com/vllnt/stack/releases); releases are created manually. No automatic Claude/Codex principle loading exists. diff --git a/scripts/update_skills.py b/scripts/update_skills.py index 837a671..0bc7c1c 100644 --- a/scripts/update_skills.py +++ b/scripts/update_skills.py @@ -17,6 +17,10 @@ BRANCH = "automation/update-skills" SHA = re.compile(r"[0-9a-f]{40}\Z") MARKER = "vstack-skills-update-v1" +# Shared reviewed merge contract. protection() refuses any other required-check +# set; checks_pass() waits until each of these has succeeded on the exact head. +# Both contexts are GitHub Actions (app 15368). +REQUIRED_CHECKS = {("validate", 15368), ("Privacy Guard", 15368)} class Stop(RuntimeError): @@ -154,10 +158,9 @@ def candidate(base, pin, source): def protection(): rule = api("branches/main/protection") checks = rule.get("required_status_checks") or {} - expected = {("validate", 15368)} actual = {(c.get("context"), c.get("app_id")) for c in checks.get("checks", [])} reviews = rule.get("required_pull_request_reviews") or {} - if (checks.get("strict") is not True or actual != expected or + if (checks.get("strict") is not True or actual != REQUIRED_CHECKS or rule.get("enforce_admins", {}).get("enabled") is not True or reviews.get("required_approving_review_count") != 0 or rule.get("allow_force_pushes", {}).get("enabled") is not False or @@ -263,8 +266,14 @@ def checks_pass(head): value = api(f"commits/{head}/check-runs?per_page=100", token_env="GITHUB_TOKEN") if value.get("total_count", 101) > 100: raise Stop("check inventory exceeds bound") - checks = [c for c in value.get("check_runs", []) if c.get("name") == "validate" and (c.get("app") or {}).get("id") == 15368] - return bool(checks) and all(c.get("head_sha") == head and c.get("status") == "completed" and c.get("conclusion") == "success" for c in checks) + runs = value.get("check_runs", []) + # Every returned run for a required context must be an exact-head success. + # Runs outside the contract, including still-running optional checks, do not count. + for name, app_id in REQUIRED_CHECKS: + matched = [c for c in runs if c.get("name") == name and (c.get("app") or {}).get("id") == app_id] + if not matched or any(c.get("head_sha") != head or c.get("status") != "completed" or c.get("conclusion") != "success" for c in matched): + return False + return True def merge(pr, head, base, pin, previous_head=None): @@ -294,7 +303,7 @@ def merge(pr, head, base, pin, previous_head=None): return if attempt < 19: time.sleep(15) - raise Stop("exact-head validate success missing; PR remains open") + raise Stop("exact-head required-check success missing; PR remains open") def main(): diff --git a/tests/test_update_skills.py b/tests/test_update_skills.py index 12e0cbc..289831a 100644 --- a/tests/test_update_skills.py +++ b/tests/test_update_skills.py @@ -21,11 +21,23 @@ def pr(head=A): def protected(): - return {"required_status_checks": {"strict": True, "checks": [{"context": "validate", "app_id": 15368}]}, + return {"required_status_checks": {"strict": True, "checks": [ + {"context": "validate", "app_id": 15368}, + {"context": "Privacy Guard", "app_id": 15368}]}, "enforce_admins": {"enabled": True}, "required_pull_request_reviews": {"required_approving_review_count": 0}, "allow_force_pushes": {"enabled": False}, "allow_deletions": {"enabled": False}} +def check_run(name, **overrides): + run = {"name": name, "app": {"id": 15368}, "head_sha": A, "status": "completed", "conclusion": "success"} + run.update(overrides) + return run + + +def check_payload(*runs): + return {"total_count": len(runs), "check_runs": list(runs)} + + @contextlib.contextmanager def repository(): with tempfile.TemporaryDirectory() as temp: @@ -146,25 +158,95 @@ def test_source_and_destination_races(self): u.fence(A, A) def test_missing_failed_skipped_cancelled_wrong_app_checks(self): - for conclusion in (None, "failure", "skipped", "cancelled", "timed_out"): - check = {"name": "validate", "app": {"id": 15368}, "head_sha": A, "status": "completed", "conclusion": conclusion} - with patch.object(u, "api", return_value={"total_count": 1, "check_runs": [check]}): - self.assertFalse(u.checks_pass(A)) - for checks in ([], [{"name": "validate", "app": {"id": 1}, "head_sha": A, "status": "completed", "conclusion": "success"}]): - with patch.object(u, "api", return_value={"total_count": len(checks), "check_runs": checks}): + other = {"validate": "Privacy Guard", "Privacy Guard": "validate"} + for name in ("validate", "Privacy Guard"): + for conclusion in (None, "failure", "skipped", "cancelled", "timed_out"): + with patch.object(u, "api", return_value=check_payload(check_run(other[name]), check_run(name, conclusion=conclusion))): + self.assertFalse(u.checks_pass(A)) + for bad in (check_run(name, app={"id": 1}), check_run(name, head_sha=B), + check_run(name, status="in_progress", conclusion=None)): + with patch.object(u, "api", return_value=check_payload(check_run(other[name]), bad)): + self.assertFalse(u.checks_pass(A)) + with patch.object(u, "api", return_value=check_payload(check_run(other[name]))): self.assertFalse(u.checks_pass(A)) + duplicate_failure = check_payload(check_run("validate"), check_run("Privacy Guard"), + check_run("Privacy Guard", conclusion="failure")) + with patch.object(u, "api", return_value=duplicate_failure): + self.assertFalse(u.checks_pass(A)) + with patch.object(u, "api", return_value=check_payload()): + self.assertFalse(u.checks_pass(A)) + # Optional checks may still be running. Only the reviewed contract gates the merge. + ready = check_payload(check_run("Privacy Guard"), check_run("validate"), + check_run("Analyze (python)", status="in_progress", conclusion=None), + check_run("CodeQL", app={"id": 57789}, status="in_progress", conclusion=None)) + with patch.object(u, "api", return_value=ready): + self.assertTrue(u.checks_pass(A)) with patch.object(u, "api", return_value={"total_count": 101}), self.assertRaises(u.Stop): u.checks_pass(A) def test_protection_requires_reviewed_contract(self): + self.assertEqual(u.REQUIRED_CHECKS, {("validate", 15368), ("Privacy Guard", 15368)}) with patch.object(u, "api", return_value=protected()): u.protection() + reversed_rule = protected() + reversed_rule["required_status_checks"]["checks"].reverse() + with patch.object(u, "api", return_value=reversed_rule): + u.protection() + for checks in ( + [{"context": "validate", "app_id": 15368}], + [{"context": "Privacy Guard", "app_id": 15368}], + [{"context": "validate", "app_id": 15368}, {"context": "Privacy Guard", "app_id": 1}], + [{"context": "validate", "app_id": 15368}, {"context": "Privacy Guard", "app_id": 15368}, + {"context": "Analyze (python)", "app_id": 15368}], + ): + value = protected() + value["required_status_checks"]["checks"] = checks + with patch.object(u, "api", return_value=value), self.assertRaises(u.Stop): + u.protection() + loose = protected() + loose["required_status_checks"]["strict"] = False + with patch.object(u, "api", return_value=loose), self.assertRaises(u.Stop): + u.protection() for key in protected(): value = protected() del value[key] with patch.object(u, "api", return_value=value), self.assertRaises(u.Stop): u.protection() + def test_merge_waits_until_every_required_check_succeeds_on_exact_head(self): + pending = check_payload(check_run("validate"), check_run("Privacy Guard", status="in_progress", conclusion=None)) + ready = check_payload(check_run("Privacy Guard"), check_run("validate")) + polls = iter((pending, ready)) + + def remote(path, method="GET", body=None, token_env=None): + if method == "PUT": + self.assertEqual(body, {"sha": A, "merge_method": "squash"}) + return {"merged": True} + if path.startswith("commits/"): + self.assertEqual(token_env, "GITHUB_TOKEN") + self.assertIn(A, path) + return next(polls) + if path == "branches/main/protection": + return protected() + return pr() + + with patch.object(u, "api", side_effect=remote) as remote_api, patch.object(u, "fence"), patch.object(u.time, "sleep") as sleep: + u.merge(pr(), A, B, B) + sleep.assert_called_once_with(15) + self.assertEqual(sum(c.args[1:2] == ("PUT",) for c in remote_api.call_args_list), 1) + + def test_merge_does_not_start_while_a_required_check_is_missing(self): + def remote(path, method="GET", body=None, token_env=None): + self.assertNotEqual(method, "PUT") + if path.startswith("commits/"): + return check_payload(check_run("validate")) + return pr() + + with patch.object(u, "api", side_effect=remote) as remote_api, patch.object(u, "fence"), patch.object(u.time, "sleep") as sleep, self.assertRaises(u.Stop): + u.merge(pr(), A, B, B) + self.assertEqual(sleep.call_count, 19) + self.assertFalse(any(c.args[1:2] == ("PUT",) for c in remote_api.call_args_list)) + def test_merge_positive_and_uncertain_failure_no_retry(self): for merged in (True, False): def api(path, method="GET", body=None): @@ -337,9 +419,7 @@ def test_resolution_schema_and_identity_fail_closed(self): u.check_closed_holds([dict(closed, **change)], {1: A}) def test_checks_use_only_builtin_token_and_missing_token_has_no_fallback(self): - check = {"name": "validate", "app": {"id": 15368}, "head_sha": A, - "status": "completed", "conclusion": "success"} - response = u.sync.encoded({"total_count": 1, "check_runs": [check]}) + response = u.sync.encoded(check_payload(check_run("validate"), check_run("Privacy Guard"))) with patch.dict(os.environ, {"GH_TOKEN": "synthetic-personal", "GITHUB_TOKEN": "synthetic-builtin"}, clear=True): with patch.object(u, "run", return_value=response) as remote: self.assertTrue(u.checks_pass(A))