Skip to content

feat: add pt-snap memory leak diagnostic skill - #104

Merged
codeasier merged 7 commits into
mainfrom
feat/skill-memory-leaks
Aug 24, 2026
Merged

codeasier merged 7 commits into
mainfrom
feat/skill-memory-leaks

Conversation

@codeasier

@codeasier codeasier commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

📝 Description

  • Add the repository-shipped pt-snap-memory-leak workflow for read-only SnapshotDB leak and retention diagnosis.
  • Combine current peak, gap, end-of-trace candidate, callstack, block, and event query surfaces.
  • Add conservative classification and output contracts that separate evidence, inference, unknowns, and validation experiments.
  • Update AGENTS navigation and add focused static contract tests.

🔗 Related Issue

Fixes #103

🧪 Testing

  • Tests added/updated
  • Manual testing completed

Commands run:

  • pytest tests/test_memory_leak_skill.py tests/test_setup_skill.py (4 passed)
  • black --check tests/test_memory_leak_skill.py
  • ruff check tests/test_memory_leak_skill.py
  • python3 /Users/test1/.agents/skills/agents-docs/scripts/validate_agents.py . (22 files, 0 errors, 0 warnings)
  • git diff --check

✅ Checklist

  • Code follows project guidelines
  • Documentation updated (if applicable)
  • No new warnings introduced
  • Changes tested locally

Snapshot Runtime Provenance

  • Snapshot provenance evaluation completed when snapshot runtime files change
    Snapshot provenance decision: no-update
    Snapshot provenance no-update reason: This PR changes only agent skill documentation, static contract tests, and AGENTS navigation; no files under src/pt_snap_cli/snapshot/** changed.

📸 Screenshots (if applicable)

Not applicable.

📋 Additional Notes

The workflow accepts existing SnapshotDB files only. It does not install packages, persist focus, deserialize pickle input, or treat end-of-trace survival as proof of a confirmed leak.

@codeasier codeasier added the enhancement New feature or request label Aug 23, 2026
@codeasier codeasier changed the title feat: add pt-snap memory leak diagnostic skill feat: add memory leak diagnostics and local skill evaluation Aug 23, 2026
@codeasier
codeasier force-pushed the feat/skill-memory-leaks branch from c89fd3b to 2405a57 Compare August 23, 2026 17:01
@codeasier codeasier changed the title feat: add memory leak diagnostics and local skill evaluation feat: add pt-snap memory leak diagnostic skill Aug 23, 2026
@codeasier codeasier mentioned this pull request Aug 23, 2026
7 tasks done

@codeasier codeasier left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Cross-review found six verified issues: one high, four medium, and one low. The focused tests pass, but they only assert static substrings and do not cover these command and query semantics.

Comment thread skills/pt-snap-memory-leak/SKILL.md Resolved
Comment thread skills/pt-snap-memory-leak/SKILL.md Resolved
Comment thread skills/pt-snap-memory-leak/SKILL.md Resolved
Comment thread skills/pt-snap-memory-leak/SKILL.md Resolved
Comment thread skills/pt-snap-memory-leak/SKILL.md Resolved
Comment thread skills/pt-snap-memory-leak/SKILL.md Resolved
@codeasier

Copy link
Copy Markdown
Owner Author

All six findings are addressed in 493372b (10 focused tests pass; black/ruff clean).

  1. High — shell-safe substitution: All commands now use single quotes ('<db_path>'). Required Inputs adds explicit rules: never place substituted values inside double quotes, backticks, or $(); escape embedded single quotes as '\''; pass argument arrays for programmatic execution; treat focus-file paths as untrusted input to quoting.

  2. Medium — unused event range: Removed the input. leak_detection is inherently end-of-trace with no range parameters, so scoped retention analysis belongs to point-in-time attribution workflows rather than this skill.

  3. Medium — pre-snapshot blocks freed during trace: Step 4 documents that the template excludes blocks with allocEventId=-1 AND freeEventId>=0 and adds a bounded quantification query (block --params '{"allocEventId":-1,"min_freeEventId":<peak+1>}') whose sizes are reported as pre-snapshot memory live at the event but without attributable callstack.

  4. Medium — occupancy vs survival: Step 4 is retitled to "Compare occupancy at the active peak". It now states this is an occupancy comparison between independent aggregates, calls out top_n truncation and equal-sized replacement, and requires identity matching (same id/address plus allocation event ID live at both events) plus lifecycle continuity before any persistence claim.

  5. Medium — unbounded -n 0: The address-event listing now starts at -n 100 and continues via offset or min_id/max_id windows; the skill warns that unlimited settings materialize every row.

  6. Low — percent column: Corrected to "share of included active bytes" with the exact formula noted (size_bytes / total size_bytes), explicitly not block-count share.

@codeasier
codeasier merged commit fd4c9be into main Aug 24, 2026
6 checks passed
@codeasier
codeasier deleted the feat/skill-memory-leaks branch October 3, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a pt-snap memory leak diagnostic skill

1 participant