Skip to content

fix: preserve callflow HTML on staging failure - #4571

Open
manthanut27 wants to merge 1 commit into
Graphify-Labs:v8from
manthanut27:fix/issue-4562-callflow-atomic
Open

manthanut27 wants to merge 1 commit into
Graphify-Labs:v8from
manthanut27:fix/issue-4562-callflow-atomic

Conversation

@manthanut27

Copy link
Copy Markdown

What does this PR do?

Fixes #4562.

This PR ensures that an existing callflow HTML report is preserved if writing a replacement fails.

  • Uses write_text_atomic() to write the generated HTML safely.
  • Preserves the previous report when staging the replacement fails.
  • Adds regression tests for staging write failures, close failures, and successful replacement.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and verified the regression test fails without the fix.
  • Made the smallest fix necessary.
  • Added a regression test for write failure, close failure, and successful replacement.
  • Kept the PR description synchronized with the implementation.
  • Documented any limitations / unsupported cases explicitly.

Invariant protected: If writing a replacement callflow HTML report fails before replacement completes, the previously generated report must remain unchanged, and temporary files must be cleaned up.

How was this tested?

uv run --frozen python -m pytest tests/test_callflow_html.py -q
# 14 passed

uv run --frozen pytest tests/test_atomic_writes.py -q
# 15 passed, 3 skipped

uv run --frozen ruff check <changed Python files>
# All checks passed

git diff --check
# Passed

Graphify-specific checklist

  • Updated generated skill artifacts (not applicable: no skill source fragments changed).
  • Confirmed AST/structural extraction remains deterministic (not specifically tested; this change only affects callflow HTML writing).
  • Reviewed changes for security implications.
  • Confirmed no API keys or local-only graph data are included.
  • Disclosed AI authorship in the commit metadata, if required by the repository's convention.

@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @manthanut27. 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; formal verification proved 0 of 1 changed function(s) (1 not verified).

Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).

Not verified on this run: write\_callflow\_html (vacuous: never exercised).


Graphify review — findings

Makes write_callflow_html write the report through write_text_atomic, so a failure while staging or closing the temp file leaves any existing callflow.html untouched and no temp files behind. Adds tests for staging-write failure, staging-close failure, and a successful atomic replace of an existing report.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 583 functions depend on the 168 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: write_callflow_html() — 10 callers, 26 callees

Verification — 583 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: 343 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

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

  • tests/test_callflow_html.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.

Docs that may be stale (advisory)

…and 10 more.

Formal verification

Could not verify: Could not verify write\_callflow\_html.

The verifier did not have enough to check write\_callflow\_html, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 51 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly FileNotFoundError — names the real obstacle, not a sampling gap)

· 1 more finding(s) on lines outside this diff (see the check run).

This branch has not been deployed

No deployments
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.

[Feature]: Preserve callflow HTML when staging a replacement fails

1 participant