mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 21:29:35 +00:00
policy: keep the Sonar gate shape the candidate contract admits
The installed policy had no accepted condition at all, so `VULNERABILITY` had no reviewed accepted failure and the gate condition count could not match. `packaging/nightly-release-tests.py` gains test_sonar_policy_keeps_the_shared_candidate_contract, which mirrors the Sonar rules the pinned candidate contract() applies - non-empty issue scope, accepted failures one-to-one with the issue types, one condition per gate metric, all six live gate conditions, the reviewed A threshold and the A..E bound - so this tree refuses the shape before a nightly run reaches admission. docs/nightly-release-preparation.md records the accepted rating, and the section that said the installed policy fails this contract now states the scope it ships.
This commit is contained in:
@@ -79,7 +79,14 @@
|
||||
"issue_types": [
|
||||
"VULNERABILITY"
|
||||
],
|
||||
"accepted_conditions": [],
|
||||
"accepted_conditions": [
|
||||
{
|
||||
"metric": "new_security_rating",
|
||||
"comparator": "GT",
|
||||
"error_threshold": "1",
|
||||
"maximum": "5"
|
||||
}
|
||||
],
|
||||
"required_conditions": [
|
||||
{
|
||||
"metric": "new_reliability_rating",
|
||||
|
||||
@@ -101,7 +101,7 @@ Read on 2026-11-24; re-read anything that may have moved before `nightly-signer`
|
||||
- Manual actors match the reviewed release-managers list in both `nightly.yml` and `.github/nightly-signing-policy.json`, with `automatic_signer_actors` empty.
|
||||
- Both callers pin the same immutable `craft-common-actions` commit in `uses` and `tooling-revision`.
|
||||
- No nightly schedule is registered, no cache actions or secrets appear in the app callers, and `nightly-sign.yml` retains its literal root `concurrency` block (`group: vectorcraft-nightly-release`, `cancel-in-progress: false`, `queue: max`).
|
||||
- Policy v3 schema, platform rows, bounds, required main-push CI workflow, and SonarCloud project identity match `sonar-project.properties`.
|
||||
- Policy v3 schema, platform rows, bounds, required main-push CI workflow, and SonarCloud project identity match `sonar-project.properties`, and the Sonar gate shape keeps every live condition once with accepted failures inside the reviewed issue scope.
|
||||
- The signer guards `refs/heads/nightly-signer`, passes `app-name: vectorcraft`, and the policy's
|
||||
`release_branch` names it.
|
||||
- A trust-closure scan reads every workflow: nothing binds an `environment`, only `nightly-sign.yml`
|
||||
@@ -174,13 +174,14 @@ enabled, so no `app.ron` is written anywhere); if it is ever turned on, its stat
|
||||
installation on every platform, and `apps/vectorcraft/src/profile.rs` (`install_data_root`) is the
|
||||
one hook every data path follows.
|
||||
|
||||
## Activation prerequisite: the Sonar issue scope
|
||||
## The Sonar issue scope
|
||||
|
||||
The pinned candidate validator requires every entry in `candidate_policy.sonar.issue_types` to map
|
||||
from a reviewed `accepted_conditions` row, and it requires the gate condition set to equal
|
||||
`accepted_conditions` plus `required_conditions`. The installed policy lists `VULNERABILITY` with no
|
||||
accepted condition, so it fails that contract before SonarCloud is read. Correct the policy in this
|
||||
app's activation review with Skylar, together with the live gate conditions, before the first run.
|
||||
`producer_workflow_id` is now populated and the signer runs on `nightly-signer`, so this policy
|
||||
correction - with the registry's Windows and macOS targets - is what still stands between this tree
|
||||
`accepted_conditions` plus `required_conditions`. The installed policy lists `VULNERABILITY` with
|
||||
`new_security_rating` accepted (max 5) and the other five gate conditions required - the same shape
|
||||
PhotoCraft and WordCraft ship - so it satisfies that contract before SonarCloud is read. `debt` stays
|
||||
empty, so any unresolved vulnerability on `main` is still refused, and the live gate is still compared
|
||||
condition by condition against the policy. `producer_workflow_id` is now populated and the signer runs
|
||||
on `nightly-signer`; the registry's Windows and macOS targets are what still stand between this tree
|
||||
and a first signed nightly.
|
||||
|
||||
@@ -429,6 +429,52 @@ class NightlyInstalledPolicy(unittest.TestCase):
|
||||
self.assertIn(item["type"], sonar["issue_types"])
|
||||
self.assertRegex(item["hash"], r"^[0-9a-f]{32}$")
|
||||
|
||||
def test_sonar_policy_keeps_the_shared_candidate_contract(self):
|
||||
"""The Sonar shape craft-common-actions' candidate contract() admits, refused here first.
|
||||
|
||||
An empty issue scope, an accepted condition outside the reviewed issue types, a metric in both
|
||||
lists, a missing live gate condition or a widened security bound is refused at admission, so
|
||||
this suite must catch it before a nightly run can. `debt` stays empty, so any unresolved
|
||||
vulnerability on main is still refused; accepting the new-code rating only records the
|
||||
reviewed A threshold instead of demanding a clean rating the live gate does not.
|
||||
"""
|
||||
sonar = self.policy["candidate_policy"]["sonar"]
|
||||
accepted = {"bugs": "BUG", "vulnerabilities": "VULNERABILITY", "code_smells": "CODE_SMELL",
|
||||
"security_rating": "VULNERABILITY", "new_security_rating": "VULNERABILITY"}
|
||||
gate = {"new_reliability_rating", "new_security_rating", "new_maintainability_rating",
|
||||
"new_coverage", "new_duplicated_lines_density", "new_security_hotspots_reviewed"}
|
||||
self.assertTrue(sonar["issue_types"], "an empty issue scope is refused as unreviewed")
|
||||
self.assertEqual(len(sonar["issue_types"]), len(set(sonar["issue_types"])))
|
||||
metrics = {}
|
||||
for field in ("accepted_conditions", "required_conditions"):
|
||||
for condition in sonar[field]:
|
||||
with self.subTest(field=field, metric=condition.get("metric")):
|
||||
expected = {"metric", "comparator", "error_threshold"}
|
||||
if field == "accepted_conditions":
|
||||
expected.add("maximum")
|
||||
self.assertEqual(set(condition), expected)
|
||||
self.assertNotIn(condition["metric"], metrics, "one condition per gate metric")
|
||||
metrics[condition["metric"]] = condition
|
||||
self.assertIn(condition["comparator"], ("GT", "LT"))
|
||||
self.assertRegex(condition["error_threshold"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
|
||||
if field != "accepted_conditions":
|
||||
continue
|
||||
self.assertIn(condition["metric"], accepted, "an accepted metric outside the reviewed map")
|
||||
self.assertIn(accepted[condition["metric"]], sonar["issue_types"],
|
||||
"an accepted failure must lie inside the reviewed issue scope")
|
||||
self.assertEqual(condition["comparator"], "GT")
|
||||
self.assertRegex(condition["maximum"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
|
||||
maximum = float(condition["maximum"])
|
||||
if condition["metric"] in ("security_rating", "new_security_rating"):
|
||||
self.assertEqual(int(maximum), maximum, "the A..E bound is a whole rating")
|
||||
self.assertTrue(1 <= maximum <= 5, "the security bound stays A..E")
|
||||
self.assertEqual(condition["error_threshold"], "1", "the reviewed A threshold stays")
|
||||
else:
|
||||
self.assertLessEqual(maximum, len(sonar["debt"]), "accepted failures exceed the reviewed debt")
|
||||
self.assertEqual({accepted[c["metric"]] for c in sonar["accepted_conditions"]}, set(sonar["issue_types"]),
|
||||
"accepted conditions and reviewed issue types must cover the same scope")
|
||||
self.assertEqual(set(metrics), gate, "every live gate condition stays gated exactly once")
|
||||
|
||||
|
||||
SIGNER_BRANCH = "nightly-signer"
|
||||
SHARED = "storytold/craft-common-actions/.github/workflows/"
|
||||
|
||||
Reference in New Issue
Block a user