Skip to content

test(reflect): characterize _is_stale across changed/unchanged/vanished sources - #4996

Closed
PratikDhanave wants to merge 1 commit into
Graphify-Labs:v8from
PratikDhanave:test/reflect-is-stale-characterization
Closed

PratikDhanave wants to merge 1 commit into
Graphify-Labs:v8from
PratikDhanave:test/reflect-is-stale-characterization

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

What

Adds three characterization tests for the learning-overlay staleness check _is_stale in graphify/reflect.py. These lock in the existing, correct behavior at the helper level — complementing the loader-level tests already in tests/test_reflect.py that exercise the same logic end-to-end through load_learning_overlay.

This is not a bug fix. No production code is touched; the behavior under test is already correct. The tests simply pin it down so future refactors of the fingerprint/resolution path can't silently regress it.

Behavior characterized

_is_stale recomputes the source file's content hash and compares it to the fingerprint the writer stored, using the same file resolution + hash as the writer (_code_fingerprint):

  • unchanged source (stored fingerprint still matches) -> fresh (False)
  • changed source content -> stale (True)
  • vanished / unresolvable source path -> stale (True) — the deliberate over-flagging (safe) direction for a re-verify hint

Each test seeds the stored fingerprint via the writer's own _code_fingerprint, documenting that writer and reader agree on an unchanged file, then asserts the baseline before mutating.

Verification

$ uv run pytest tests/test_reflect.py -q
62 passed in 2.90s

$ uv run pytest tests/test_reflect.py -q -k is_stale
3 passed, 59 deselected in 0.20s

$ uv run ruff check
All checks passed!

Tests only; no runtime/behavior change.

…ed sources

Add three characterization tests pinning the existing, correct behavior of
the learning-overlay staleness check (graphify/reflect.py::_is_stale) directly
at the helper level:

- unchanged source (stored fingerprint still matches) -> fresh (False)
- changed source content -> stale (True)
- vanished / unresolvable source path -> stale (True), the deliberate
  over-flagging safe direction for a re-verify hint

They use the writer's own _code_fingerprint to seed the stored fingerprint,
documenting that writer and reader agree on an unchanged file. No behavior
change.
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Thanks for the pull request, @PratikDhanave. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

Not checked: tests were not run; no formal proof of the changed code.


Graphify review — findings

Adds characterization tests that exercise _is_stale directly, rather than only through the loader tests. They cover three cases: an unchanged source file reads as fresh, an edited file reads as stale, and a source path that no longer resolves reads as stale whatever fingerprint was stored. That last case is the deliberate over-flagging direction, so a re-verify hint is never silently dropped.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 118 functions depend on the 118 functions this change touches.

Health — grade A; 2 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • _make_graph() — 4 callers, 6 callees (medium)
  • test_lessons_artifact_cannot_be_globbed_back_into_memory() — 0 callers, 6 callees (medium)

Verification — 118 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 118 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

1 of 518 test file(s) selected (0%) via static blast radius.

  • tests/test_reflect.py — impact, changed-test

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

@safishamsi

Copy link
Copy Markdown
Member

Landed in 0.9.103 (published to PyPI), cherry-picked with your authorship preserved. Thanks @PratikDhanave.

@safishamsi safishamsi closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants