Skip to content

ci: a census allowance that was paid is reported, not kept (engine#2889 paid the only one) - #2915

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-1051-census-stale-allowance
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-1051-census-stale-allowance

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

serve_field_census.py (engine#2893, merged as #2894) carries a named-debt allowlist, and nothing reported when a debt was paid.

Why this is not a tidy-up

UNOWNED = {
    "cache_prompt": "engine#2889 (the prefix cache ignores the caller's opt-out)",
}

engine#2889 merged at 06:22Z and taught the route to read cache_prompt. On main today:

$ python3 tools/ci/serve_field_census.py --root .
cache_prompt           read-in-route
id_slot                read-in-route
rc=0

The entry is a fiction, the check prints the field as read, and nothing says the allowance is dead. An allowlist that can only grow is how UNOWNED comes to mean "fields we once worried about" instead of "fields we are still ignoring, on purpose, with an owner" — and this repo has already paid for that lesson once with known_fail_device_case and its [UNEXPECTED-PASS] arm.

I raised this on #2894 before it merged (the entry was already dead by then, nine minutes after #2889 landed) and the PR landed without it, so this is the follow-up rather than a review objection.

What changes

  • The dead cache_prompt entry is removed.
  • stale_allowances(result) returns the UNOWNED keys whose field is no longer ignored, check() prints each one with the value it now has and the issue the entry names, and returns 1.
  • Three self-test arms cover the mechanism rather than the instance.

Measured

tree result
this branch cache_prompt read-in-route, id_slot read-in-route, rc 0
UNOWNED with the dead cache_prompt entry restored serve_field_census: the allowance for cache_prompt is no longer needed -- the field is read-in-route on this tree, so remove it from UNOWNED (…), rc 1

--self-test: 11 arms, all green (was 8; the three new ones are: a read field makes its allowance stale, an ignored field does not, and a field that became a named refused also pays its debt).

Refs engine#2889, engine#2893, engine#2894.

…89 paid the only one)

`serve_field_census.py` carries `UNOWNED` -- fields accepted and discarded, each naming the issue that owns the fix -- so
the check stays green only while the debt is named. Nothing reported the other direction, so an entry whose issue merged
could only sit there: the check keeps printing it, the field is read, and the allowlist can never shrink.

That is not hypothetical. `engine#2889` merged at 06:22Z and taught the route to read `cache_prompt`, and on `main` today:

```
$ python3 tools/ci/serve_field_census.py --root .     # before this commit
cache_prompt           read-in-route
rc=0                                                   <- the allowance is a fiction, and it is silent
```

So: the dead entry is removed, and `stale_allowances()` reports any future one and fails the check, because a green tick
over an allowance nothing needs is how `UNOWNED` would come to mean "fields we once worried about".

Measured, both directions:

```
$ serve_field_census.py --root .                        # this tree
cache_prompt           read-in-route
id_slot                read-in-route
rc=0

$ <UNOWNED = {"cache_prompt": "engine#2889 (paid)"}>     # the entry restored
serve_field_census: the allowance for cache_prompt is no longer needed -- the field is read-in-route on this
                    tree, so remove it from UNOWNED (engine#2889 (paid))
rc=1
```

Three self-test arms cover the mechanism rather than the instance: an allowance whose field is now read is stale, one
still `ignored` is not, and a field that became a named `refused` also pays its debt. 11 arms total, all green.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Stale Allowance Reporting

The PR introduces logic to detect and report stale allowances in the UNOWNED dictionary, where entries are removed when the corresponding field is no longer ignored. This prevents the UNOWNED list from growing indefinitely and ensures that allowances are only kept while the debt they represent is still relevant. The change correctly identifies when a field is no longer ignored and reports it as stale, returning exit code 1 to indicate the issue.

def stale_allowances(result):
    """UNOWNED keys whose field is no longer `ignored`: the debt was paid and the entry is now a fiction."""
    return [k for k in UNOWNED if result.get(k) != "ignored"]


def check(root):
    route, options = pathlib.Path(root) / ROUTE, pathlib.Path(root) / OPTIONS
    missing = [str(p) for p in (route, options) if not p.is_file()]
    if missing:
        print(f"serve_field_census: cannot tell: {', '.join(missing)} not found", file=sys.stderr)
        return 2
    result = census(route.read_text(errors="replace"), options.read_text(errors="replace"))
    report(result)
    stale = stale_allowances(result)
    for key in stale:
        print(f"serve_field_census: the allowance for {key} is no longer needed -- the field is {result[key]} on this "
              f"tree, so remove it from UNOWNED ({UNOWNED[key]})", file=sys.stderr)
    if stale:
        return 1

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing under ORCH 11-20 (no new ci/tooling PRs until fewer than 5 are open; new PRs only when they close or directly advance an OPEN issue). This is neither: it is a follow-up to #2894, which is merged, and the issues it names (#2889, #2893) are closed. The work is complete and verified (rc 1 with a dead allowance restored, rc 0 without, self-test 11 arms) and stays on my lane's shelf: branch deleted, patch recorded in ~/briefs/CL-1051-STATE.md; I will re-open it against main as soon as the queue is under five, or immediately if someone reports a stale UNOWNED entry in the meantime. Reviewing the green queue first, per the same directive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant