Memory and snapshot sync route tests pass when the sender's schema version is dropped

Chiusa Adatta ai principianti
#11,996 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js

Direzione di ricerca

Inizia con server/routes/memory.test.js e server/routes/dataSync.test.js, quindi confronta i relativi casi con le chiamate alle route in server/routes/memory.js e server/routes/dataSync.js. Aggiungi test che passino i dati della versione dello schema ai servizi simulati e verifichino come ciascuna route gestisce una risposta 409 o blockedBySchema. Il lavoro è completo quando le mutazioni di inoltro elencate fanno fallire i test delle route e i casi limite HTTP passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

effort:low model:light plan planner:fable-5-1 test-quality tests

Slice audited: federation route tests (test-quality audit, 2026-10-18).

Problem

Two sync routes forward the sender's version envelope to the service gate that refuses or reshapes cross-version payloads (server/lib/schemaVersions.js). Their route tests never send that envelope, so forwarding is untested.

  1. server/routes/memory.js:88-90 and :101-103 forward schemaVersion to memorySync.getChangesSince / applyRemoteChanges, which gate at server/services/memorySync.js:39 and :107. server/routes/memory.test.js:175, :184, :193 assert getChangesSince('10', 50) and :263 asserts applyRemoteChanges(memories); no case sends ?schemaVersion= or body.schemaVersion. Mutation probe: made both handlers always call the two-argument form.
Test Files  2 passed (2)   Tests  49 passed (49)
  1. server/routes/dataSync.js:186 calls dataSync.applyRemote(category, data, { portosMeta }), the only thing that lets the version gate at server/services/dataSync.js:1362 fire for this route. server/routes/dataSync.test.js:388 ("leaves the write direction alone — apply is gated by its schema-version check, not this") posts no portosMeta and asserts { portosMeta: undefined }, the one value that disables the gate it names. Mutation probe: replaced the forwarded value with the constant { portosMeta: undefined }.
Test Files  1 passed (1)   Tests  42 passed (42)

Impact

syncOrchestrator.js:322 pulls GET /api/memory/sync?…&schemaVersion=N from a peer; the serving install uses that to shape rows and to 409 a newer puller. With forwarding lost, rows go out in the legacy shape with no version in the envelope and the puller applies them as version 0. For the snapshot apply route, a newer-schema snapshot posted to an older install is applied ungated, the corruption schemaVersions.js exists to prevent. The service-level gates are covered only in memorySync.db.test.js, which pregate does not run, so the route layer is the only guard in the default CI plan.

Fix (decided)

  • server/routes/memory.test.js: add GET …?schemaVersion=N asserting getChangesSince received ('10', 50, N), POST with schemaVersion asserting applyRemoteChanges(memories, N), and one case where the mocked service rejects with status 409 and the route passes the status through.
  • server/routes/dataSync.test.js:388: replace the assertion. Post a populated portosMeta: { portosVersion, schemaVersions: { digitalTwin: 99 } }, assert it is forwarded verbatim, and add one case where the mock returns blockedBySchema and the route surfaces it in the response.
  • No production code change.

Scope: small

Acceptance criteria

  • Forcing the two-argument calls in routes/memory.js fails routes/memory.test.js.
  • Forwarding { portosMeta: undefined } unconditionally in routes/dataSync.js fails routes/dataSync.test.js.
  • A 409 or blockedBySchema from the mocked service is asserted at the HTTP boundary in each file.
  • No production code change.
Lingua principale
JavaScript
Stelle
38
Fork
32
Merge medio
27m
PR unite (30g)
990

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di atomantic/PortOS

Tutte le issue di atomantic/PortOS

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.