Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
commission feedback: dedup backfill-remapped legacy ids; GC feedback of pruned commissions
[._.]/ Adam Eivyf82fe0e3ae31
diff --git a/server/services/creativeCommissions/feedbackStore.js b/server/services/creativeCommissions/feedbackStore.jsindex 2e3df8349c..408e422fe5 100644--- a/server/services/creativeCommissions/feedbackStore.js+++ b/server/services/creativeCommissions/feedbackStore.js@@ -365,6 +365,23 @@ export async function deleteCommissionFeedback(id) {return { id, deleted: true };}+/**+ * Tombstone every live feedback record for a commission. Called when the+ * commission's own tombstone is hard-pruned: past that point no peer can+ * resurrect the commission, but its feedback rows would otherwise stay live+ * forever — enumerated by the sync listers and pushed to every new peer, with+ * no GC path (tombstone GC only prunes rows that are already tombstoned).+ */+export async function tombstoneFeedbackForCommission(commissionId) {+ const raw = await feedbackStore().listRawByCommission(commissionId);+ let tombstoned = 0;+ for (const rec of raw) {+ const res = await deleteCommissionFeedback(rec.id).catch(() => ({ deleted: false }));+ if (res.deleted) tombstoned += 1;+ }+ return { commissionId, tombstoned };+}+/*** Migrate a commission's INLINE `feedback[]` (Phase 2 storage) into the federated* store, then return true if any were moved (the caller clears the inline array).diff --git a/server/services/creativeCommissions/store.js b/server/services/creativeCommissions/store.jsindex 4d573ad8c9..9a462fbbdc 100644--- a/server/services/creativeCommissions/store.js+++ b/server/services/creativeCommissions/store.js@@ -75,6 +75,7 @@ import {listFeedbackForCommission,listFeedbackByCommissionIds,backfillInlineFeedback,+ tombstoneFeedbackForCommission,} from './feedbackStore.js';// Emits `commission:changed` on any create/update/delete (not on run-record@@ -441,7 +442,13 @@ function unionInlineFeedback(federated, inline) {if (!Array.isArray(inline) || inline.length === 0) return federated;const seenRun = new Set(federated.filter((f) => f.runId).map((f) => f.runId));const seenId = new Set(federated.map((f) => f.id));- const extra = inline.filter((f) => (f?.runId ? !seenRun.has(f.runId) : !seenId.has(f?.id)));+ // A run-less legacy inline entry is stored federated under the backfill's+ // remapped id (`cfeedback-<sanitized legacy id>`), so match that form too —+ // otherwise the reaction counts twice while the inline copy is retained.+ const backfilledId = (f) => `cfeedback-${String(f?.id || '').replace(/[^0-9a-z-]/gi, '-')}`;+ const extra = inline.filter((f) => (f?.runId+ ? !seenRun.has(f.runId)+ : !(seenId.has(f?.id) || seenId.has(backfilledId(f)))));if (extra.length === 0) return federated;return [...federated, ...extra].sort((a, b) => String(a.at).localeCompare(String(b.at)));}@@ -771,7 +778,13 @@ export async function mergeCommissionsFromSync(remoteRecords, { source = { via:/** Hard-remove tombstoned commissions older than the cutoff; evicts each base hash. */export async function pruneTombstonedCommissions(olderThanMs) {const result = await commissionStore().pruneTombstoned(olderThanMs);- for (const id of result.ids || []) await deleteSyncBaseHash(CREATIVE_COMMISSION_KIND, id).catch(() => {});+ for (const id of result.ids || []) {+ await deleteSyncBaseHash(CREATIVE_COMMISSION_KIND, id).catch(() => {});+ // The commission is gone everywhere its tombstone aged out — tombstone its+ // feedback too, so the rows GC through the normal path instead of staying+ // live (and peer-pushed) forever with no owner.+ await tombstoneFeedbackForCommission(id).catch(() => {});+ }return result;}