Skip to content

release: fix raw retention boundary - #189

Merged
NikolayS merged 7 commits into
NikolayS:mainfrom
samo-agent:agent/w3-b3
Jul 27, 2026
Merged

release: fix raw retention boundary#189
NikolayS merged 7 commits into
NikolayS:mainfrom
samo-agent:agent/w3-b3

Conversation

@samo-agent

@samo-agent samo-agent commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • separate exact physical raw coverage (ash._raw_oldest_sample()) from the reusable minute-aligned planning/loss boundary (ash._raw_retention_start())
  • floor both sides of the wait/query tie guard and print the same down-rounded remediation boundary it accepts
  • keep source selection and report query attribution tied to physical coverage while status/report coverage expose the logical boundary
  • preserve still-readable evidence after delayed rotation by choosing the older of ring geometry and the physical oldest minute
  • add three independent exact B3 regressions, including the README query copied verbatim after a no-argument ash.start() call
  • clarify the logical-vs-physical report and status contracts

Root cause

ash._raw_retention_start() exposed the exact first sample second. Readers query minute buckets, so status could not be fed back into since, and the guard rounded its advice up past the only partial minute. The same physical timestamp was also being used for source attribution and public planning even though those are different contracts.

Verification

  • all three exact failures reproduced independently on current main (1fcf9e7): README drill errors, status self-feed errors, and advice rounds up to an empty result
  • PostgreSQL 17.9 fresh install and full discovered upgrade chain: pass
  • exact README/default-start/status/advice B3 step: pass
  • report attribution, retention split, delayed-rotation range guard, compare, and chart step: pass
  • behavioral reader suite through the changed retention section: pass
  • release: prevent cleanup from deadlocking rotation #185 cleanup/rotation regression: pass
  • grant_reader dynamic helper closure: 41/41 current non-admin functions after release: fix reader privilege blockers and sample slot race #181, including direct EXECUTE/call of ash._raw_oldest_sample(); rebuild preserves it and revoke removes it
  • workflow YAML parse and git diff --check: pass
  • Codex review plus independent adversarial verification: approved with no blockers

Rebase resolution

Rebased onto current main (1fcf9e7). The ash.status() catalog-comment conflict preserves both #185's day-granular rotation / consecutive_rotate_failures contract and this PR's logical-vs-physical retention contract. Two test fixtures that still used a now-invalid 30-minute rotation_period were converted to the deliberate one-day contract and their entirely-past/partial/delayed-evidence ranges were scaled without weakening any assertion.

Merge sequencing

Land this retention-boundary change before rebasing sibling PRs #182 and #180. PR #181's dynamic non-admin helper enumeration is retained and verified for the new helper. Expect documentation conflicts in blueprints/AAS_API.md and blueprints/AAS_EXAMPLES.md when #182 and #186 are rebased.

Fixes #163

@NikolayS

Copy link
Copy Markdown
Owner

REV Code Review Report

No issues found. Reviewed the final pushed diff for security, runtime/SQL correctness, exact regression coverage, repository guidelines, API contracts, documentation, upgrade behavior, and merge sequencing.

Result: PASSED

Area Findings Potential Filtered
Security 0 0 0
Bugs 0 0 0
Tests 0 0 0
Guidelines 0 0 0
Docs 0 0 0
Metadata / API contract 0 0 0

Manual evidence included the three independent #163 RED assertions on the #129 base, the copy-pasted README drill on a fresh default-start install, status-boundary self-feed, down-rounded remediation preserving all eight samples, delayed-rotation evidence, the full discovered upgrade chain, fresh/upgrade schema equivalence, and the complete reader-helper privilege closure.

Merge-sequencing note (non-blocking): land B3 before rebasing #180/#182; reconcile their shared report/workflow/source-provenance regions and rerun the exact boundary tests. #181 must retain dynamic non-admin helper enumeration.


REV-assisted review (parallel analysis following postgres-ai/rev)

PR NikolayS#185 deliberately rejects sub-day rotation_period values. Keep that product contract intact and scale NikolayS#189's synthetic retention windows from minutes to whole days instead. The same entirely-past, partial-overlap, delayed-evidence, and down-rounded-boundary assertions remain in force.

@NikolayS NikolayS left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Codex review report — PASS

Reviewed rebased head e724827 against current main (1fcf9e7). No remaining blocker.

  • RED: all three exact #163 regressions fail independently on main: the README tie drill raises and advises the next minute; feeding status.raw_retention_start back into the drill raises; following the advice yields {up,0,NULL,…}.
  • GREEN: the consolidated README/default-start/status/advice block passes on PostgreSQL 17.9, as do the full behavioral reader step and the report/compare/retention/chart step.
  • Rebase conflict: combined #185's day-granular rotation and consecutive_rotate_failures status wording with #189's logical-vs-physical retention wording.
  • Semantic collision fixed: two #189 fixtures still assigned a 30-minute rotation_period, which #185 deliberately forbids. Commit e724827 retains the product validation and scales the synthetic windows to one-day geometry; the entirely-past, partial-overlap, delayed-evidence, and down-rounding assertions are unchanged in substance.
  • #181 privilege bundle: 41/41 current non-admin functions are granted. ash._raw_oldest_sample() is explicitly EXECUTE-able/callable by the reader, survives rebuild_partitions, and is removed by revoke_reader. The historical PR-body count of 42 became 41 because #181 intentionally moved _admin_funcs() out of the reader set.
  • Previous-fix cross-check: #185's cleanup/rotation regression still passes on this installer.
  • Additional verification: fresh install, discovered full upgrade chain, YAML parse, and git diff --check pass. Automated Codex review and an independent adversarial review found no issues.

This is verification and collision resolution against the existing #160 audit; no assertions were deleted or weakened.

@NikolayS
NikolayS marked this pull request as ready for review July 27, 2026 20:38
@NikolayS
NikolayS merged commit 86e0ca8 into NikolayS:main Jul 27, 2026
8 checks passed
@samo-agent
samo-agent deleted the agent/w3-b3 branch July 27, 2026 20:43
NikolayS added a commit that referenced this pull request Jul 27, 2026
Preserve honest retained grain across aas, timeline, top, compare, chart, summary, and v1.5 backfills; disclose effective plans and mark legacy/incomplete hourly detail as rollup_1h_flat.\n\nThe final rebase preserves #189's physical/logical raw-retention split and #181's dynamic reader grants. The Codex review's full-archive scan finding is fixed by keeping _rollup_1h_has_flat() indexable. Fixes #161, #168, #175, and #130; supersedes #131.
NikolayS pushed a commit that referenced this pull request Jul 27, 2026
Keep #180's until-relative compare defaults exactly once. The #182 reader expansion carried an older duplicate declaration block whose now-relative defaults would both fail function compilation and discard the B5 contract.

Use #189's _raw_retention_start() and _active_slots() helpers for #180's alternate-coverage NOTICE instead of reintroducing the pre-B3 retention formula. This keeps the corrected logical/physical raw boundary split and excluded-slot rule intact.

Adapt the sparse-hour C1 gate to #182's honest rollup_1h_flat plan: aggregate readers disclose one widened hourly datum, while report still returns silent NULL because exact per-minute coverage is not derivable.
NikolayS added a commit that referenced this pull request Jul 27, 2026
* fix: reject inverted reader windows

* docs: clarify reader and scheduler diagnostics

* fix: preserve reader contracts after rebase

Keep #180's until-relative compare defaults exactly once. The #182 reader expansion carried an older duplicate declaration block whose now-relative defaults would both fail function compilation and discard the B5 contract.

Use #189's _raw_retention_start() and _active_slots() helpers for #180's alternate-coverage NOTICE instead of reintroducing the pre-B3 retention formula. This keeps the corrected logical/physical raw boundary split and excluded-slot rule intact.

Adapt the sparse-hour C1 gate to #182's honest rollup_1h_flat plan: aggregate readers disclose one widened hourly datum, while report still returns silent NULL because exact per-minute coverage is not derivable.

* fix: make diagnostic source guidance actionable

When cron.database_name is unset or names the current database, explain how to configure pg_cron or use the external scheduler. Recommend installing pg_ash in another database only when the setting names a real, different target.

Document ash.report's rollup_1m-only contract in the README and guard both disclosures in CI. Exercise mutable cron.database_name placeholders only on the cron-off axis because preloaded pg_cron registers the GUC as postmaster-only. This closes the Codex pre-merge review findings without changing report behavior.

---------

Co-authored-by: samo-agent <280144521+samo-agent@users.noreply.github.com>
samo-agent added a commit to samo-agent/pg_ash that referenced this pull request Jul 27, 2026
Document that retained AAS is weighted by the current sampler interval, successful idle ticks are not persisted, and intervals above one minute can overstate minute extrema. Mark the affected user stories partial and expose the limitation in the README, release notes, blueprints, and sample_interval catalog comment.

Hand-resolve against current main by retaining NikolayS#182's final grain/provenance contracts, NikolayS#180's until-only window and report disclosures, NikolayS#189's raw-boundary wording, and NikolayS#187's retired-benchmark caveat.
NikolayS added a commit that referenced this pull request Jul 27, 2026
Document that retained AAS is weighted by the current sampler interval, successful idle ticks are not persisted, and intervals above one minute can overstate minute extrema. Mark the affected user stories partial and expose the limitation in the README, release notes, blueprints, and sample_interval catalog comment.

Hand-resolve against current main by retaining #182's final grain/provenance contracts, #180's until-only window and report disclosures, #189's raw-boundary wording, and #187's retired-benchmark caveat.

Co-authored-by: samo-agent <280144521+samo-agent@users.noreply.github.com>
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.

Release blocker: fresh-install tie drills reject retained raw samples

2 participants