Skip to content

Commit bb17129

Browse files
committed
feat(runtime): seed-replayer reports skipped for host stamp-on-progress (cloud#853)
The `seed-replayer` service returned { inserted, updated, errors } but not `skipped`, so a cloud host could not distinguish an all-skip replay (seed data already present — a no-op) from the zero-summary early-returns that never ran the loader (no org / no metadata / no datasets). Both read as inserted=updated=0, so the host couldn't safely stamp its seed-once record for the all-skip case → re-replayed every cold boot. Return `skipped: result.summary.totalSkipped`; early-returns report skipped:0. Lets cloud#853's decideSeedStamp stamp on progress (incl. all-skip) while still declining a genuine no-loader zero summary. Additive, backward compatible. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01APnSDJneEDRh3Z51KGCLga
1 parent 80273c8 commit bb17129

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@objectstack/runtime": patch
3+
---
4+
5+
feat(runtime): seed-replayer reports `skipped` so hosts can stamp seed-once on progress
6+
7+
The `seed-replayer` kernel service returned `{ inserted, updated, errors }` but
8+
not `skipped`. A cloud host therefore could not tell an **all-skip replay**
9+
(the env's seed data is already present — a no-op) apart from the
10+
zero-summary early-returns that never ran the loader (no organization, no
11+
metadata service, no datasets). Both looked like `inserted = updated = 0`, so
12+
the host could not safely stamp its seed-once record for the all-skip case and
13+
re-ran the full remote replay on every cold boot.
14+
15+
Add `skipped: result.summary.totalSkipped` to the replayer's return; the
16+
early-returns report `skipped: 0`. This lets a host (cloud#853's
17+
`decideSeedStamp`) stamp on progress — including an all-skip replay — while
18+
still declining to stamp a genuine no-loader zero-summary. Additive and
19+
backward compatible; existing consumers ignore the new field.

packages/runtime/src/app-plugin.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,17 +765,17 @@ export class AppPlugin implements Plugin {
765765
const metadataNow = ctx.getService('metadata') as IMetadataService | undefined;
766766
const loggerRef = ctx.logger;
767767
const replayer = async (organizationId: string) => {
768-
if (!organizationId) return { inserted: 0, updated: 0, errors: [] as any[] };
768+
if (!organizationId) return { inserted: 0, updated: 0, skipped: 0, errors: [] as any[] };
769769
const md = metadataNow ?? (ctx.getService('metadata') as IMetadataService | undefined);
770770
if (!md) {
771771
loggerRef.warn('[seed-replayer] metadata service unavailable');
772-
return { inserted: 0, updated: 0, errors: [] as any[] };
772+
return { inserted: 0, updated: 0, skipped: 0, errors: [] as any[] };
773773
}
774774
const datasetsNow = (() => {
775775
try { return kernel?.getService?.('seed-datasets'); } catch { return merged; }
776776
})() ?? merged;
777777
if (!Array.isArray(datasetsNow) || datasetsNow.length === 0) {
778-
return { inserted: 0, updated: 0, errors: [] as any[] };
778+
return { inserted: 0, updated: 0, skipped: 0, errors: [] as any[] };
779779
}
780780
const seedLoader = new SeedLoaderService(ql, md, loggerRef);
781781
const { SeedLoaderRequestSchema } = await import('@objectstack/spec/data');
@@ -796,6 +796,12 @@ export class AppPlugin implements Plugin {
796796
return {
797797
inserted: result.summary.totalInserted,
798798
updated: result.summary.totalUpdated,
799+
// `skipped` lets a cloud host distinguish an all-skip
800+
// replay (data already present) from the zero-summary
801+
// early-returns above (which never ran the loader), so
802+
// it can stamp its seed-once record on progress rather
803+
// than re-replaying every cold boot (cloud#853).
804+
skipped: result.summary.totalSkipped,
799805
errors: result.errors,
800806
};
801807
};

0 commit comments

Comments
 (0)