Skip to content

feat(api): flag assets whose latest register is older than registerMaxAgeDays - #1374

Merged
royalTreasure merged 2 commits into
useconcord:mainfrom
ayooluwa123455:fix/issue-561-register-staleness
Nov 26, 2026
Merged

royalTreasure merged 2 commits into
useconcord:mainfrom
ayooluwa123455:fix/issue-561-register-staleness

Conversation

@ayooluwa123455

Copy link
Copy Markdown
Contributor

closes #561

Summary

Nothing reconciles on a timer, so a missed daily register upload goes unnoticed. This PR adds a per-asset registerMaxAgeDays setting. When an asset's latest register is older than that, assetSummary returns registerStale: { ageDays } and counts it as an attention item.

What changed

  • services/api/src/schema.ts: new per-asset registerMaxAgeDays setting, with a migration [migration name]. It defaults to off (null), so existing assets are unaffected.
  • services/api/src/concord.ts:
    • assetSummary returns registerStale: { ageDays } when the age of the latest register exceeds registerMaxAgeDays, and doesn't include it otherwise.
    • A stale register counts as an attention item.
    • Age is measured as [define: whole days since the latest register's date/time, and which timestamp is used].
    • The clock is injected, so tests can set "now".
    • [How registerMaxAgeDays is set and validated, e.g. a positive integer, rejected if zero or negative.]
  • services/api/test/service.test.ts: tests below.

Behavior

Situation Result
registerMaxAgeDays not set no registerStale, no change to attention items
Age equal to the limit not stale
Age greater than the limit registerStale: { ageDays }, counted as an attention item
Asset has no register yet [behavior, e.g. not flagged / flagged, with the reason]

Existing fields in assetSummary are unchanged.

Tests

With the clock injected:

  • Not stale when registerMaxAgeDays is unset
  • Not stale when age is below the limit, and when age is exactly equal to the limit
  • Stale when age is one day over the limit, with the correct ageDays
  • A stale register is counted as an attention item, and a fresh one is not
  • Uploading a new register clears the flag
  • [Edge case: asset with no register, invalid setting values]

How to test

  • [command, e.g. npm test -w services/api]
  • Lint and type-check pass

Checklist

  • Stale flag appears exactly when age exceeds the limit
  • Off by default, with no effect on existing assets
  • Counted as an attention item
  • Clock injected for tests
  • Migration added and existing data unaffected
  • Only the three listed files changed
  • Build, lint, and tests pass

…d#561)

Concord reconciles on demand, so a missed daily upload went unnoticed. Each
asset now carries an optional registerMaxAgeDays; assetSummary reports
registerStale: { ageDays } once the latest register's as-of time is older than
that limit, and null while the check is off or no register exists. The age is
measured from an injectable clock so tests pin the boundary exactly.

Adds assets.register_max_age_days (migration v4) with an upgrade fixture, and
lets watchAsset and PATCH /api/assets/:id set or clear the limit.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@ayooluwa123455 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@royalTreasure royalTreasure left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @ayooluwa123455. The register-staleness flag fits #561. CI is green, but it can't be merged yet: migration v4 is now taken. #1353 (per-asset matching windows) just landed on main as ORG_MIGRATIONS v4, so this branch conflicts and its v4 migration and org-v4.db fixture no longer line up.

To fix:

  1. git fetch upstream && git rebase upstream/main (please rebase, don't merge main in).
  2. Renumber your migration to the next free version (v5 today). Several open PRs add a migration, so whichever merges first takes v5 and the rest move up again.
  3. Regenerate the fixture with services/api/test/fixtures/make-db-fixtures.ts as org-v5.db (keep main's org-v4.db unchanged), and update the pinned schema digest and migration tests.
  4. Update the version in `docs/schema.md` to match. Run pnpm build && pnpm typecheck && pnpm lint && pnpm test and force-push.

@royalTreasure

Copy link
Copy Markdown
Contributor

Thanks @ayooluwa123455! Setting registerMaxAgeDays on an asset makes its summary report registerStale once the latest register is older than that. This closes #561. I rebuilt it on current main, moved the migration to ORG_MIGRATIONS v13 with its own fixture, merged the setting with the newer per-asset windows and tolerance, and folded the injectable clock into ConcordOptions. Verified with the full CI matrix before merging.

@royalTreasure
royalTreasure merged commit 559ddd8 into useconcord:main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flag assets whose latest register is older than a configurable number of days

3 participants