You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(install): let GitLab and Azure DevOps projects replay a verified no-op - #5331
#4993's verified-state record replays a repeat no-op apm install only when it can prove the run's inputs. For a project whose git remote is on GitLab or Azure DevOps, it never recorded: there was no exact proof that policy discovery would return without a fetch. Those users always took the full pipeline on repeat no-ops (about 1.1 to 1.4 s at tree-10, instead of about 0.25 s).
This PR records a GitLab or ADO project's verified no-op only when that run's discovery made no policy fetch attempt:
Each policy fetch channel notes its attempt in the new import-light core/policy_fetch_ledger.py. The GitHub contents, GitLab REST and ADO items channels note it before any credential lookup; policy_get notes every HTTP fetch.
The record writer compares the count with the run's entry (verdict_inputs.entry_stamp). Any attempt means no record.
Why this is exact: GitLab ancestry and ADO discovery are cache-first. With no attempt, every candidate discovery consulted was a fresh cached entry. The record already keys every policy_v1 file (bytes and mtime) and the remote (git config), and it expires at the earliest cached_at + capped_ttl(cache.ttl). A later run with identical keyed inputs before that expiry therefore also fetches nothing. A pinned GitLab project (policy.hash) always fetches, so it never records. GitHub projects keep #4993's first-candidate rule unchanged.
Human scope-approval comment: confirmed by the regent under rule 23 (perf approved by default); INT posts the apm-scope record on #5075, review contact Daniel Meppiel (@danielmeppiel).
Does this PR complete the issue, or what remains? Completes it.
Type of change
Bug fix
New feature
Documentation
Maintenance / refactor
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
New cells in tests/integration/test_verdict_record.py:
test_a_gitlab_or_ado_run_whose_policy_came_from_the_cache_records_and_hits[gitlab|ado]: fails on main, because main never recorded these hosts.
test_a_gitlab_or_ado_run_that_attempted_a_policy_fetch_never_records[gitlab|ado]: the negative control.
ruff 0.15.12 check and format, the architecture linter, the complexity ratchet against origin/main, and tm006: clean.
Performance (PERF VP GODSPEED rule: one final no-regression check at the final head, 9 pairs). Base main 22324e6 vs d32b14c, tree-50, CPU including children, RTT 30. Runs: Linux 45366051813, Windows 45366144596.
OS
Journey
Base
New
Paired p50
95% band
Linux
install-noop
3.758 s
3.741 s
1.0019
[0.9851, 1.0190]
Linux
install-warm
13.296 s
13.378 s
0.9963
[0.9479, 1.0112]
Windows
install-noop
5.797 s
5.812 s
1.0000
[0.9683, 1.0859]
Windows
install-warm
24.453 s
24.438 s
1.0000
[0.9888, 1.0287]
All 4 cells pass at p50 <= 1.010. The bench fixtures use a GitHub origin, so this gates against regression only; the cells above prove the GitLab/ADO path engages. An earlier 6-pair check at 1fa51f2 read Linux install-warm 1.0231 (band [0.932, 1.044]); the head then moved with source folds, and the VP ruled this one final rerun. The 15-pair 3-OS run for the release note runs after merge.
Review: W3d accepted d32b14c (R1, R2 and R3 met). Copilot took 2 rounds: 3 correctness findings folded with cells, 1 missed speedup declined to the PERF backlog, 1 test-coverage finding covered by the R1/R2 cells.
Changelog
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
… no-op (#5075)
A GitLab or ADO project records its verified no-op only when the run's
policy discovery made no fetch attempt: every candidate it consulted came
from a fresh cached entry, which the record already keys and whose TTL
bounds the record's expiry. Each policy fetch channel notes its attempt
in core/policy_fetch_ledger before any credential lookup or request; the
writer compares the count with the run's entry. GitHub projects keep the
first-candidate rule.
apm-spec-waiver: no-op replay prints the engine's own no-op output and writes no bytes; nothing OpenAPM-observable changes
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Deleting the policy cache after discovery can still permit recording, removing the policy TTL bound and allowing replay instead of refetching for up to 24 hours.
Extends verified no-op install replay to GitLab and Azure DevOps projects by tracking whether policy discovery attempted a fetch, building on the existing authenticated-record mechanism.
Changes:
Tracks policy fetch attempts before credential lookup and HTTP requests.
Allows GitLab and Azure DevOps records when the fetch count is unchanged during the run.
Adds replay eligibility tests, registers the ledger with the architecture owner, and adds a changelog fragment.
File
Description
tests/integration/test_verdict_record.py
Adds GitLab and ADO record/replay eligibility cases.
src/apm_cli/policy/discovery.py
Accounts for GitHub and ADO fetch attempts.
src/apm_cli/policy/_policy_http.py
Accounts for policy HTTP fetch attempts.
src/apm_cli/policy/_gitlab.py
Accounts for GitLab attempts before credential lookup.
src/apm_cli/install/verdict_record.py
Captures the initial fetch count alongside run time.
src/apm_cli/install/verdict_policy.py
Uses the fetch count to gate GitLab and ADO recording.
…record (#5075)
The record writer now also requires the policy cache's shape (every file's
path, size and mtime) at write to equal the run's entry, so a cache deleted
or changed between discovery and the write never records. Adds misses only.
Cells: a fetch that fails at the credential lookup or transport is still
counted on every channel (github, gitlab, ado, http); a pinned GitLab project
through real discovery never records; a cache changed after discovery never
records.
apm-spec-waiver: no-op replay prints the engine's own no-op output and writes no bytes; nothing OpenAPM-observable changes
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical metadata-preserving policy-cache rewrite can authenticate an outdated successful verdict and bypass new restrictions, while snapshot errors can abort installation instead of merely disabling recording.
…#5075)
The GitLab/ADO record now binds each policy cache file's content digest
(no-follow) as well as its mtime, so a same-size, mtime-preserving rewrite
after discovery never records. A cache the snapshot cannot read is no
record and never aborts the install (W3d R3). The repository channels
(github contents, ado items) note their attempt in _policy_auth_resolver,
before any credential lookup; discovery.py stays within the file cap.
apm-spec-waiver: no-op replay prints the engine's own no-op output and writes no bytes; nothing OpenAPM-observable changes
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A critical check-to-use race can authenticate a deleted policy cache with an old successful verdict and fresh expiry, allowing later installs to replay that verdict instead of fetching the missing policy.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Cache check-to-use race can authenticate a missing policy
src/apm_cli/install/verdict_policy.py:154
The cache comparison finishes before _write() separately reads the cache in _inputs() and _expiry(), leaving a check-to-use race. If the cache is deleted after this guard, the writer can authenticate the empty cache with the old successful verdict and a fresh 24-hour policy expiry, allowing later installs to replay instead of fetching the missing policy. Compare the cache snapshot actually used for input hashing with the entry snapshot, derive policy expiry from that same snapshot, and add a regression that deletes the cache after this guard but before hashing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#4993's verified-state record replays a repeat no-op
apm installonly when it can prove the run's inputs. For a project whose git remote is on GitLab or Azure DevOps, it never recorded: there was no exact proof that policy discovery would return without a fetch. Those users always took the full pipeline on repeat no-ops (about 1.1 to 1.4 s at tree-10, instead of about 0.25 s).This PR records a GitLab or ADO project's verified no-op only when that run's discovery made no policy fetch attempt:
core/policy_fetch_ledger.py. The GitHub contents, GitLab REST and ADO items channels note it before any credential lookup;policy_getnotes every HTTP fetch.verdict_inputs.entry_stamp). Any attempt means no record.Why this is exact: GitLab ancestry and ADO discovery are cache-first. With no attempt, every candidate discovery consulted was a fresh cached entry. The record already keys every
policy_v1file (bytes and mtime) and the remote (git config), and it expires at the earliestcached_at + capped_ttl(cache.ttl). A later run with identical keyed inputs before that expiry therefore also fetches nothing. A pinned GitLab project (policy.hash) always fetches, so it never records. GitHub projects keep #4993's first-candidate rule unchanged.Issue and approved scope
Issue: Fixes #5075
Human scope-approval comment: confirmed by the regent under rule 23 (perf approved by default); INT posts the apm-scope record on #5075, review contact Daniel Meppiel (@danielmeppiel).
Does this PR complete the issue, or what remains? Completes it.
Type of change
Testing
New cells in
tests/integration/test_verdict_record.py:test_a_gitlab_or_ado_run_whose_policy_came_from_the_cache_records_and_hits[gitlab|ado]: fails on main, because main never recorded these hosts.test_a_gitlab_or_ado_run_that_attempted_a_policy_fetch_never_records[gitlab|ado]: the negative control.Commands, each run once through host_guard:
pytest tests/integration/test_verdict_record.py -n 0-> 85 passed, 4 skipped (Windows-only).pytest tests/unit/install/test_architecture_invariants.py tests/integration/test_cli_startup_import_budget.py tests/integration/policy/test_remote_reads.py -n 0-> 7 passed, 5 skipped.Performance (PERF VP GODSPEED rule: one final no-regression check at the final head, 9 pairs). Base main 22324e6 vs d32b14c, tree-50, CPU including children, RTT 30. Runs: Linux 45366051813, Windows 45366144596.
All 4 cells pass at p50 <= 1.010. The bench fixtures use a GitHub origin, so this gates against regression only; the cells above prove the GitLab/ADO path engages. An earlier 6-pair check at 1fa51f2 read Linux install-warm 1.0231 (band [0.932, 1.044]); the head then moved with source folds, and the VP ruled this one final rerun. The 15-pair 3-OS run for the release note runs after merge.
Review: W3d accepted d32b14c (R1, R2 and R3 met). Copilot took 2 rounds: 3 correctness findings folded with cells, 1 missed speedup declined to the PERF backlog, 1 test-coverage finding covered by the R1/R2 cells.
Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.