harden: address adversarial review of Pods CRUD

Backend: atomic create with insert-retry-on-duplicate-key (removes slug
TOCTOU race + wrong 400s), resilient per-index creation so a unique-index
failure can't silently drop the constraint or block seeding, idempotent
race-safe seeding via $setOnInsert, type validation + size caps on all pod
fields/members, removeMember no-ops without a write, /api/outcome guarded.
Frontend: per-pod busy state (one mutation no longer disables every card),
joined pod derived from the list (can't go stale), create keeps inputs on error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kartikeya
2026-06-27 16:02:40 -07:00
parent 4ddc59be08
commit 7ff750ad5e
5 changed files with 163 additions and 78 deletions
+10 -2
View File
@@ -51,8 +51,16 @@ app.post('/api/sync-pr', async (req, res) => {
// Outcome ACK -> closes the continual-learning policy loop.
app.post('/api/outcome', async (req, res) => {
await recordOutcome(req.body as InterventionOutcome);
res.json({ ok: true });
try {
const o = (req.body ?? {}) as Partial<InterventionOutcome>;
if (typeof o.interventionId !== 'string' || !o.interventionId) {
return res.status(400).json({ error: 'interventionId is required' });
}
await recordOutcome(req.body as InterventionOutcome);
res.json({ ok: true });
} catch (e) {
res.status(500).json({ error: (e as Error).message });
}
});
// Memory counts — quick way to confirm Mongo persistence is working.