Skip to content

feat(apps): add opt-in retention and a liveness predicate to the Job SDK - #22711

Closed
dodgeblaster wants to merge 1 commit into
mainfrom
fix/7588-job-sdk-retention
Closed

dodgeblaster wants to merge 1 commit into
mainfrom
fix/7588-job-sdk-retention

Conversation

@dodgeblaster

@dodgeblaster dodgeblaster commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let a Job SDK consumer bound how many run records a kind keeps, and tell the SDK when a finished run is still using its resources, so old records are pruned and a run that is terminal-but-still-writing is never deleted out from under itself.

JobStore writes one JSON file per run and removes one only on app disable. list_recent's limit caps the response, not the store, so a consumer's per-run file count grows without bound and every full-set read opens every file. And JobRun.is_terminal is pure status membership, so a run that has reached a terminal status while still delivering its results (Code Review Sage's posting phase, which runs after the run goes terminal) reads as evictable — the moment eviction is added, a status-only test would delete such a run's directory while its poster is still writing.

Why it matters

A consumer that migrates to the SDK gets unbounded growth today, and the obvious eviction predicate (is_terminal) would delete a run mid-delivery — the exact defect Code Review Sage already had to fix inside its own registry. Bounding the store and expressing liveness are the two halves of making retention safe.

This PR changes the public App Kit contract (the register signature gains three optional arguments, and JobRun gains a seq field), which is a public-contract decision pending a maintainer ruling. The shape built here — a bounded cap, an eviction callback, and a live predicate registered alongside the runner — follows the proposal in the issue thread (the 2026-09-28 comment on #7588). That comment is a proposal, not a ruling: its author is not in MAINTAINERS.md, so under docs/decisions/README.md rule 4 it does not settle the contract. This PR is therefore a DRAFT for a maintainer to decide whether to promote.

Not a goal

  • Not choosing a default cap or a default liveness model for existing kinds. Retention is opt-in per kind; a kind that does not pass retention keeps every record exactly as before.
  • Not hardcoding Sage's posting into the SDK. The SDK takes a predicate; posting is one app's implementation of it.
  • Not adding an age cap or a size cap, a background sweep, or a served retention surface. The sweep runs inline on the terminal write, which is where the store already changes.
  • Not a result/payload channel. seq is an SDK-minted integer, not data a runner or caller supplies.

What changed (motivation → approach → change)

Nothing prunes the store and liveness cannot be expressed, so this adds both at register and leaves every existing kind untouched by defaulting the cap off. register(kind, fn, ..., retention=0, live=None, on_evict=None) binds a per-kind count cap, a liveness predicate over a terminal run, and an eviction callback. The retention logic lives in a new owner, src/kiro_crew/apps/job_sdk_retention.py, served through the job_sdk facade like its siblings and bound onto JobSDK, which keeps job_sdk.py under the 1,600-line split line. After each terminal write the sweep keeps the newest retention terminal records of that kind. It spares runs still executing here and terminal runs live claims (neither is counted), calls on_evict with each dropped run, then deletes the file via a new JobStore.remove and audits a new job_evicted event. It reads jobs/ (app-writable) through the bounded, no-follow safe_read_file_bytes_nolink funnel the disable scan uses, via a private JobStore._iter_runs_nolink. That scan skips planted links, oversized or deeply nested files, names that are not run ids, and bodies whose id differs from the filename. iter_runs is unchanged. A disabled SDK sweeps nothing: the sweep checks the closed flag under the lock disable sets it with, so a worker that outlives disable cannot evict a re-enabled SDK's records. Newest-first uses a new SDK-minted seq on JobRun (job_sdk_records.py), stamped at the terminal write (completion order, so a long run finishing last survives its own sweep) because the timestamps are second-resolution. Each seq is at least the wall clock in nanoseconds and above the previous one, so a run finishing after a restart outranks earlier records even if the seed saw nothing; the counter is also seeded once per SDK above the highest seq on disk (off the event loop), which covers a clock that stepped back across the restart; each SDK has its own counter, so one app's store can steer only its own order; the seed ignores a disk seq outside a signed 64-bit range and refuses a floor above half of it, and the sweep sorts an out-of-range seq as 0, so a planted huge integer cannot exhaust the counter or outrank a genuine run. reconcile stamps the runs it resolves and refuses to recreate a record retention removed. Seeding, stamping, the sweep, a raising live (treated as keep) and a raising on_evict are all logged and never skip a run's terminal write. A run whose live clears is released at the kind's next completion.

Backwards compatibility

Compatible: the three register arguments are keyword-only with defaults that reproduce today's behaviour (retention=0 keeps every record, live=None evicts on terminal status alone only when a cap is set, on_evict=None calls nothing), and JobRun.seq defaults to 0, which from_dict supplies for any record an older build wrote.

Removes nothing: no field, method, kind, or key an app can see is renamed or removed; the addition is purely additive, so there is no reader to enumerate.

Tests

test/test_job_sdk_retention.py (new):

  • a kind with no retention keeps every record (the additive default);
  • acceptance (a): running N > cap and driving them terminal settles the on-disk terminal-record file count at the cap, keeping the newest by completion order (a long run that started first and finished last survives), and a cap on one kind does not touch another;
  • on_evict is called with the evicted run before its record is removed;
  • acceptance (b): a terminal run the live predicate claims is kept past the cap while live and evicted once liveness clears, and a live run does not consume a cap slot;
  • a run still executing is never evicted by a sweep; ordering survives a restart (a fresh SDK over the same store);
  • the sweep's scan skips a planted symlink record (not counted, not handed to on_evict), a forged record whose body id differs from its filename, an oversized record and an unparseable one, and survives an absent directory or a listing failure. The symlink and forged-record tests red when the sweep is pointed back at the link-following iter_runs;
  • a stubborn worker left running by disable does not evict a re-enabled replacement SDK's records or fire its stale on_evict (reds with the closed checks removed).
  • a restart whose seed scan comes back empty still keeps the newest run (reds without the wall-clock floor);
  • a planted 4,300-digit seq does not poison the counter (reds without the bound), and one app's near-ceiling seq does not reach another app's numbers (reds with a shared counter);
  • a deeply nested record, a file not named as a run id, and a raising seed, stamp or sweep each leave the run terminal on disk with its live entry released.

Determinism: test/test_job_sdk_retention.py passed 10/10 repeats at -n4 and 3/3 seeded shuffled orders at -n0, and the disable/funnel/forged tests 10/10 more at -n0, and the whole file 5/5 more at -n4 after the module split; post-sweep state is awaited with a bounded _wait_until on file names or existence (never by opening a record, which on Windows blocks the sweep's delete) or a thread join, never a sleep.

test/test_job_sdk_facade.py lists the new owner in OWNERS. test/test_job_sdk.py and test/test_job_sdk_invariants.py: the two field-set guard tests add seq to their expected sets with the rationale that it is SDK-minted, so the sanitize backstop still has error as its only runner-supplied input.

Manual verification

N/A — unit coverage is sufficient; the SDK is a backend module with no user-visible surface in this diff, and the sweep, liveness and ordering are all exercised deterministically by the new tests (proven by reverting the sweep, which reds them).

Screenshots / video

Why no screenshot: backend-only change to the Job SDK; no frontend path is touched.

Related Issues

Closes #7588

Pattern harvest

Not generalizable: this is an additive feature on one module's public contract, not a fix to a defect class.

Checklist

  • At most two commits (one), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (app-kit-platform.md § 26.1)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision ece318edb4a1ced1d7529be5e19848783c6b554f touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of ece318edb4a1ced1d7529be5e19848783c6b554f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: retention is opt-in per kind and purely additive, and the live predicate deals with the terminal-but-still-writing case at its source.

Notes

  • Every capped completion runs a full no-follow scan of the app's whole jobs/ directory, including kinds with no cap. An uncapped sibling kind therefore makes each capped completion cost O(all records); the cap bounds only its own kind.
  • In _persist(only_if_not_terminal=True), the new latest is None → refuse now applies to every kind, not only capped ones. It also catches a record that read returns as None for any other reason, such as a parse failure. Scoping it to kinds with retention > 0 would keep the change to what the goal names.
  • The facade re-exports a lot of private names (_MAX_SEQ, _SEED_CEILING, _order_key, _sweep). Since this is pending a ruling on the public contract, keep the public surface to register's three keyword arguments plus JobRun.seq, so it stays easy to walk back.

[DESIGN-REVIEWED] ece318e

Description read

[DESCRIPTION-READ] e3c96e7e489b86998da82019ee00d3fba875e6063005e72da53fceea9b1ea493

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🔴 BLOCK

Premise-level review of ece318edb4a1ced1d7529be5e19848783c6b554f — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: BLOCK

register(..., retention, live, on_evict) adds three arguments to the public App Kit contract, and nothing in this repository calls them. The app the description cites (Code Review Sage) still uses its own registry.

Notes

  • Item 4 — oversized: the seq machinery (wall-clock floor, 64-bit bounds, half-range refusal, per-SDK seeding) exists only because "the timestamps are second-resolution". Subtraction: drop _SeqCounter and its seeding. Sort on a nanosecond completion time stamped at the terminal write instead.

What this change ships

Inventory (8 items) — 4 justified

Intent: let an app bound how many job run records each kind keeps without deleting a run that is still delivering results. ADDITION.

  1. A kind can cap its retained terminal run records — zero consumers
  2. A kind can mark a terminal run as still live, so it is spared — zero consumers
  3. A kind gets a callback before each eviction — zero consumers
  4. Every run record now carries a persisted completion-order seq — oversized
  5. Evictions write a job_evicted audit event — justified
  6. reconcile will not recreate a record retention removed — justified
  7. The store gains a delete and a no-follow scan for the sweep — justified
  8. The app-kit-platform spec documents the new owner and §26.1 — justified

Blockers

Public contract arguments with no caller — zero consumers
Trigger: grepping retention=|live=|on_evict= across src/kiro_crew finds 0 callers. The only in-tree sdk.register call (apps/builtins/aws_control/hooks.py:302) passes none of them. The description names its consumer only as hypothetical: "A consumer that migrates to the SDK". Sage "already had to fix [this] inside its own registry".
Outcome: three keyword arguments and a persisted record field become App Kit contract that has to be honored forever, and nothing exercises them except their own tests.
Subtraction: defer items 1–4 until a consumer migrates, and land them in the same change as that migration.
Clears when: a consumer that calls register with retention/live/on_evict lands in the same change or is linked from it, or a maintainer records /ai-review override first-principles ece318edb4a1ced1d7529be5e19848783c6b554f zero-consumers: <decision>.

[FIRST-PRINCIPLES-REVIEWED] ece318e

Description read

[DESCRIPTION-READ] 8acd1ddec3324c36c383f2d776cfc299a97715e99eee9627e5caa3785b5e86fb

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed ece318edb4a1ced1d7529be5e19848783c6b554f — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] ece318e

Verdict parsed from the review's SHA-scoped output markers for commit ece318edb4a1ced1d7529be5e19848783c6b554f.

False positive or not applicable? A repository writer can comment:
/ai-review override fable ece318edb4a1ced1d7529be5e19848783c6b554f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of ece318edb4a1ced1d7529be5e19848783c6b554f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ece318e

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ece318edb4a1ced1d7529be5e19848783c6b554f false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 21, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/7588-job-sdk-retention branch from c2c7f77 to b9162b7 Compare October 21, 2026 08:48
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: process-local seq reset to 0 on restart, used as the newest-first sort key

  • Process-local seq used as a durable newest-first key (span=9d7a2beaee45)

Fixed. Confirmed the defect: the counter is a module global reset to 0 per process, so after a restart a kind with high-seq records on disk would mint low seqs for new runs, sort them oldest, and evict the just-finished run.
Fix (head b9162b7): JobSDK.__init__ now calls _seed_seq_from_store, which raises the shared counter above the highest seq any record in this store already holds. A run started after a restart therefore outranks every record the previous process left. New test TestOrderingSurvivesARestart writes seq-98/99 records, builds a fresh SDK over the same store (standing in for the restart), finishes one new run, and asserts the new run survives the cap.

@dodgeblaster

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: process-local seq reset to 0 on restart, used as the newest-first sort key

  • seq reset on restart evicts each new run (span=838e45215efa)

Fixed. Same root cause as the design finding: the sort key seq reset to 0 per process. Fix at head b9162b7 seeds the shared counter above the highest seq the store holds, in JobSDK.__init__ via _seed_seq_from_store, so a post-restart run outranks pre-restart records and is not evicted as oldest. Covered by TestOrderingSurvivesARestart.

@dodgeblaster

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: test reads post-sweep state before the sweep runs on the worker thread

  • retention tests assert before the sweep settles (span=09c151e0bf68)

Fixed. Confirmed: the sweep runs on the worker thread after the terminal write _wait_terminal observes, so the four cap tests could read the store inside that window. Fix at head b9162b7 wraps each post-sweep assertion in _wait_until on the exact state being asserted (file count, evicted list, survivor set) before asserting. Verified deterministic: 12/12 serial runs and -n4 beside the neighbouring job_sdk suites, all green.

@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • Public register arguments with no caller — zero consumers (span=f09a0e98473d)

needs-a-decision. The finding is correct: the three new register arguments and JobRun.seq ship with no in-repo caller (the one JobSDK.register call, aws_control backup, passes none; Code Review Sage is not on the Job SDK), so the surface would lock in before a real consumer tested it.
This is the public-contract question the PR already flags as pending a maintainer ruling. The design shape it implements comes from a PROPOSAL (not a MAINTAINERS.md author), so under docs/decisions/README.md rule 4 it is not settled. The two resolutions the reviewer names — ship a consumer in this PR, or remove the surface — are both decisions I was told to escalate rather than take: inventing a consumer is a product change to another app, and removing the surface discards the feature. Leaving this for the maintainer; the PR stays DRAFT.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 21, 2026
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • Public register arguments with no caller — zero consumers (span=f09a0e98473d)

needs-a-decision. The no-caller objection is legitimate and stands: the new register arguments and JobRun.seq ship with no in-repo consumer, so their shape is not yet exercised by a real caller.
This is the App Kit public-API decision the PR body already flags: the implemented shape follows a proposal, not a maintainer ruling, so under docs/decisions/README.md rule 4 it is unsettled. It is deliberately not resolved here — adding a consumer would widen scope and removing the surface would empty the PR. The PR stays a DRAFT until a maintainer rules on promoting or holding the API.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 21, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/7588-job-sdk-retention branch from b9162b7 to 60cc7a8 Compare October 21, 2026 09:05
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: seq minted at start, so a long run finishing last sorted oldest and its own sweep evicted it

  • retention ranks by start order, evicting a long run on completion (span=838e45215efa)

Fixed at head 60cc7a8. Confirmed the data-loss: seq was minted at start, so a long run A (started first, finished last) carried the lowest seq and its own terminal-write sweep sorted it oldest and deleted it. Fix: seq is now minted at the TERMINAL WRITE (completion order) in _execute's finally, and reconcile stamps a completion seq too, so the run finishing now is the newest terminal record and sorts last-to-evict. New test TestCompletionOrderNotStartOrder blocks run A while cap+1 quick runs of the same kind finish, then releases A and asserts A survives and the oldest-completed quick run is evicted; proven to red under start-order minting.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 21, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/7588-job-sdk-retention branch 4 times, most recently from 0534199 to 5d3378a Compare October 21, 2026 09:59
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • Retention follows planted symlinks with an unbounded read (span=7909c656e6a0)

rebutted. The trigger is a symlink planted inside the app's jobs/ directory, and only something that can already write the gateway's own data home can plant one. Anything with that write access can already wedge every existing iter_runs caller today — reconcile, list_active, list_recent. _sweep_retention adds a new CALLER of that existing read path with the same precondition and the same exposure; it opens no new attack surface. Closing it by moving retention onto the no-follow funnel is hardening past the threat this PR names, against a shared read path this PR does not change (AGENTS.md: rebut, don't absorb out-of-goal hardening; the sandbox/spelling-chase rule). max_seq, which this PR does add, already reads through safe_read_file_bytes_nolink.
Follow-up for a maintainer: a bounded, O_NOFOLLOW read for ALL jobs/ scans (iter_runs included) is a reasonable defense-in-depth change — but it belongs in its own PR that owns the shared seam and keeps its Windows concurrent-replace retry, not folded into this additive retention feature.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 21, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/7588-job-sdk-retention branch from 5d3378a to 520cd91 Compare November 2, 2026 04:39
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • Public contract surface with no caller — zero consumers (span=c7d220e9def6)

needs-a-decision. The finding is factually correct: the only in-tree register caller (apps/builtins/aws_control/hooks.py:302) passes none of retention/live/on_evict, and Code Review Sage keeps its own retention and is not on JobSDK.
Its "Clears when" (migrate a shipped app in this diff) is a product change to another app, and since the 2026-11-01 decision (docs/decisions/2026-11-01-kiro-crew-accepts-no-new-built-in-apps.md) Sage is a built-in that is moving out of core, while that same decision asks for app capabilities to be generic App Kit seams. Whether this seam ships ahead of a consumer, ships with a consumer, or is withdrawn is the maintainer's call on the public App Kit contract.
The PR stays DRAFT pending that ruling; no code change is made for this finding.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 2, 2026
Bound a Job SDK kind's run-record count and express when a finished run is
still using its resources, so old records are pruned and a terminal-but-
still-writing run is never evicted. All additive and opt-in per kind.
@dodgeblaster
dodgeblaster force-pushed the fix/7588-job-sdk-retention branch from e6caf22 to ece318e Compare November 2, 2026 17:11
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 2, 2026
@dodgeblaster
dodgeblaster marked this pull request as ready for review November 2, 2026 18:26
@dodgeblaster
dodgeblaster requested review from a team and KiroCrewCaptain as code owners November 2, 2026 18:26
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Request for a maintainer ruling on the public App Kit contract in this PR

The author (@dodgeblaster) would like to ship this contract as it stands:

  • register(..., retention=None, live=None, on_evict=None): three optional, default-off arguments. With none of them passed, an app behaves exactly as on main.
  • JobRun.seq: a stored, per-SDK ordering field that the retention sweep uses to pick which records to keep.

Why ship it now, before an in-repo app uses it. Apps that move onto the Job SDK will need bounded retention and a liveness predicate. Without them, a job's history grows without limit, or an app evicts by status alone and drops a run that is still in use. Code Review Sage already hit that status-only eviction bug in its own registry. With apps leaving the core (the Nov 1 direction, and the level-1 seams in §32 of docs/system-specs/modules/app-kit-platform.md), this generic App Kit hook is the place for the capability to live, not each app's own copy.

What is being asked. Under docs/decisions/README.md rule 4, only a maintainer can settle a public contract. So we ask a maintainer to:

  1. Rule on whether register(retention, live, on_evict) and JobRun.seq are acceptable as the public Job SDK contract, as they stand.
  2. If you agree, clear the First Principles "public API with no consumer" block. That block is the only check still failing; every other lane and shard is green on the current head.

This account will not post an /ai-review override. The ruling and any override are a maintainer's call. If you would rather the shape changed, say how, and the PR will follow.

@bolichen97

Copy link
Copy Markdown
Contributor

Maintainer ruling on the public Job SDK contract at ece318e: accepted as it stands.

register(..., retention=None, live=None, on_evict=None) and JobRun.seq may ship before an in-repo consumer. The reason is recorded in the request above. Apps moving onto the Job SDK need bounded retention and a liveness predicate. Code Review Sage already hit the status-only eviction bug in its own registry. The three arguments are optional and default off, so an app that passes none of them behaves exactly as on main. That justifies the "zero consumers" items 1 to 4.

What this ruling asks in return: the first app that migrates should use these arguments, rather than adding its own retention again, and that PR should link back here.

I will follow up with the code review of this head and the First Principles override.

@bolichen97 bolichen97 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.

Correction to my earlier comment on this PR: the final maintainer decision is no override. That comment accepted the public contract ahead of a consumer, and it is withdrawn. I am sorry for the mixed signal.

Requesting changes at ece318e, as the First Principles lane asks:

  • Defer register(..., retention=, live=, on_evict=) and the persisted JobRun.seq (items 1 to 4) until an app actually calls them. Land them in the same PR as that first consumer's migration, or link that consumer PR from this one.
  • The parts that stand on their own can go ahead now: the job_evicted audit event, reconcile not recreating a record retention removed, the store's delete and no-follow scan, and the spec section. Splitting them out is fine.

The code itself read well: the no-follow bounded scan, the seq seeding with a ceiling, the live-run exclusion and the sweep that never raises. So this is only about when the public arguments land, not how they work.

@bolichen97

Copy link
Copy Markdown
Contributor

One addition to my request for changes above at ece318e, which already withdraws the earlier acceptance of the three parameters.

The two ways forward, more concretely:

  • (a) Land retention, live and on_evict together with a real consumer migration, for example Code Review Sage moving its own registry onto sdk.register, or
  • (b) drop items 1 to 4 (the three parameters and the seq counter), and keep items 5 to 8: the job_evicted audit event, the reconcile fix, the store's delete and no-follow scan, and the spec section.

If ordering is still needed under (a), the First Principles lane's simpler option is worth taking. Sort on a nanosecond completion time stamped at the terminal write, instead of _SeqCounter with its wall-clock floor, 64-bit bounds and per-SDK seeding.

@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #33196; thanks for the start.

bolichen97 added a commit that referenced this pull request Nov 8, 2026
The Job SDK writes one record file per run and removes them only when
the app is disabled, so a kind's store grows with every run.
register() takes an opt-in per-kind retention count: after each
terminal write the sweep removes that kind's oldest finished records
until at most that many remain. It never removes a run still running
or one whose own sweep has not run yet, and it reads each record
without following a link. aws_control's two backup kinds opt in at
100, at or above every reader's window.

The liveness predicate and eviction callback are left to #33058.
Builds on #22711.

Closes #7588
bolichen97 added a commit that referenced this pull request Nov 8, 2026
The Job SDK writes one record file per run and removes them only when
the app is disabled, so a kind's store grows with every run.
register() takes an opt-in per-kind retention count: after each
terminal write the sweep removes that kind's oldest finished records
until at most that many remain. It never removes a run still running
or one whose own sweep has not run yet, and it reads each record
without following a link. aws_control's two backup kinds opt in at
100, at or above every reader's window.

The liveness predicate and eviction callback are left to #33058.
Builds on #22711.

Closes #7588
bolichen97 added a commit that referenced this pull request Nov 8, 2026
The Job SDK writes one record file per run and removes them only when
the app is disabled, so a kind's store grows with every run.
register() takes an opt-in per-kind retention count: after each
terminal write the sweep removes that kind's oldest finished records
until at most that many remain. It never removes a run still running
or one whose own sweep has not run yet, and it reads each record
without following a link. aws_control's two backup kinds opt in at
100, at or above every reader's window.

The liveness predicate and eviction callback are left to #33058.
Builds on #22711.

Closes #7588
bolichen97 added a commit that referenced this pull request Nov 9, 2026
The Job SDK writes one record file per run and removes them only when
the app is disabled, so a kind's store grows with every run.
register() takes an opt-in per-kind retention count: after each
terminal write the sweep removes that kind's oldest finished records
until at most that many remain. It never removes a run still running
or one whose own sweep has not run yet, and it reads each record
without following a link. aws_control's two backup kinds opt in at
100, at or above every reader's window.

The liveness predicate and eviction callback are left to #33058.
Builds on #22711.

Closes #7588
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 9, 2026
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Closing this PR as superseded by #33196.

The remaining parts of this PR are therefore superseded for now. This isn't a judgement on anyone's work. The branch fix/7588-job-sdk-retention is kept in case #33058 wants to start from it.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Job SDK has no retention, and status-only liveness makes eviction unsafe

2 participants