Skip to content

fix: implement dataset-global query semantics (#204) - #215

Closed
codeasier wants to merge 1 commit into
fix/issue-203-chain-67e26f4from
fix/issue-204-chain-67e26f4
Closed

codeasier wants to merge 1 commit into
fix/issue-203-chain-67e26f4from
fix/issue-204-chain-67e26f4

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

Part of the #198–#205 dependency stack, based on fix/issue-203-chain-67e26f4 (stacked on #203). Merge in issue order; after the parent merges, retarget this PR to main.

  • Eleven dataset-global builtins: event, allocation, memory_peak, allocator_gap, active_blocks_at_event, active_memory_callstack_at_event, preexisting_live, block, freed_block_lifetime, leak_detection, callstack_analysis.
  • Global filter/source identity/dedup/threshold/sort happen before final windows; exact totals ignore windows; dataset custom SQL and runtime builtin-name overrides are rejected through original identity/deep equality.
  • Independent per-metric/device real peaks with earliest-ID tie-breaking; the same selected event is used for report gap/attribution/active coverage; percentages use included group bytes after filtering/topN before caller caps.
  • One shared diminishing budget across the three report queries (100000 fetched/output rows, 64 MiB serialized values); exhaustion rejects the whole query; dataset fetchmany 256 while standalone consume=None retains fetchall.
  • Callback deadline expiry now maps to QueryTimeoutError / CLI QUERY_TIMEOUT (previously normalized incorrectly to QueryExecutionError).
  • callstack_analysis legacy alloc_count counts ALL real non-NULL stack-bearing actions (not allocation-only); missing/literal/empty stay distinct; weighted stats over full identity.

Commits in this PR:

32 files changed, 1727 insertions(+), 266 deletions(-):

README.md
README_zh.md
docs/en/querying.md
docs/en/sharded-snapshotdb.md
docs/zh/querying.md
docs/zh/sharded-snapshotdb.md
src/pt_snap_cli/cli.py
src/pt_snap_cli/cli_reports.py
src/pt_snap_cli/core/dataset_attribution.py
src/pt_snap_cli/core/dataset_global.py
src/pt_snap_cli/core/dataset_resolver.py
src/pt_snap_cli/core/dataset_sources.py
src/pt_snap_cli/core/dataset_support.py
src/pt_snap_cli/core/models.py
src/pt_snap_cli/core/query_service.py
src/pt_snap_cli/core/report_service.py
src/pt_snap_cli/query/executor.py
src/pt_snap_cli/query/registry.py
src/pt_snap_cli/query/templates/basic/block.yaml
src/pt_snap_cli/query/templates/business/leak_detection.yaml
src/pt_snap_cli/query/templates/statistical/allocator_gap.yaml
src/pt_snap_cli/query/templates/statistical/callstack_analysis.yaml
src/pt_snap_cli/query/templates/statistical/memory_peak.yaml
tests/core/test_dataset_attribution.py
tests/core/test_dataset_global.py
tests/query/test_callstack_schema_compat.py
tests/query/test_registry.py
tests/query/test_template_semantics.py
tests/test_contract_cli_api.py
tests/test_dataset_focus.py
tests/test_fragmentation_query_scope.py
tests/test_native_dataset.py

🔗 Related Issue

Refs #204 — deliberately no auto-closing keywords; the issue stays open because GUI/C++/installed-wheel acceptance is human-deferred.

Review comment: #204 (comment)

🧪 Testing

  • Tests added/updated
  • Manual testing completed

Real global query/report runs exercised locally, including timeouts, paging, budget exhaustion and the authentic-original differential (3219 lifecycles, 325 terminal candidates, 60 all-action groups, 4 ranges, 16 points, 3 metric reports).

  • Owning focused run: 724 passed.
  • Owning full suite: 1888 passed; combined line+branch coverage 92.4612665% (raw line 94.0197538%, raw branch 87.2866128%); critical floors 91.89/90.27/85.45.
  • basedpyright 0 errors (1169 informational warnings); staged governance: 27 passed; post-commit regression: 724 passed.
  • Independent parent verification: fixture provenance 7 + 334 global/source/schema/report/CLI-API/lifecycle/registry regressions, all passed.

✅ Checklist

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

"No new warnings" keeps the pre-existing external pytest-asyncio startup deprecation and existing informational type warnings unchanged rather than hidden; ResourceWarning / PytestUnraisableExceptionWarning remain errors.

Snapshot Runtime Provenance

  • Snapshot provenance evaluation completed when snapshot runtime files change
    No snapshot runtime files change in this PR, so no provenance declaration is required.

📸 Screenshots (if applicable)

Not applicable — no user-interface or C++ changes in this PR.

📋 Additional Notes

  • Terminal leak candidates require terminal presence, state 0/1, no completed free and a proven captured allocation — candidates, not confirmed leaks; latest-containing-shard state is an observation.
  • CI: the Test workflow only runs for PRs based on main; this stacked PR runs CI once it is retargeted to main after [FEATURE] 数据集按事件查询与跨片 alloc/free、堆栈来源解析 #203 merges.

Head SHA: a0f9738fedaa31b7c3929f5884c48df74616a75a; branch fix/issue-204-chain-67e26f4. All checks above were recorded locally on this exact head; the C++/GUI consumer and installed-wheel profile remain untested and unclaimed.

@codeasier

Copy link
Copy Markdown
Owner Author

Superseded by #216 — the complete #198–#205 chain (including this PR’s commits) was merged into main via #216 (rebase merge) after retargeting. This PR stays as the per-issue review record; the linked issue remains open pending the human-deferred GUI acceptance.

@codeasier codeasier closed this Oct 6, 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.

1 participant