Skip to content

feat(sync): rfc-003 phase a.4.3 — retire payload_hash + pin core to A.4.2 - #58

Merged
InstaZDLL merged 2 commits into
mainfrom
feat/sync-v2-phase-a-4-3-pin-core-payload-hash
Jun 15, 2026
Merged

feat(sync): rfc-003 phase a.4.3 — retire payload_hash + pin core to A.4.2#58
InstaZDLL merged 2 commits into
mainfrom
feat/sync-v2-phase-a-4-3-pin-core-payload-hash

Conversation

@InstaZDLL

@InstaZDLL InstaZDLL commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Phase A.4.3 of RFC-003 closes the desktop ↔ server payload-hash
loop. The helper module that landed here in A.2.2.1
(src/payload_hash.rs, 366 LOC, 12 inline tests) moves into
waveflow-core under sync::payload_hash (desktop PR #238 —
A.4.1) so a single canonical-serialisation implementation drives
both sides of the wire. This PR bumps the waveflow-core pin to
the desktop main SHA that ships both A.4.1 + A.4.2 and consumes
the helpers from there.

Cargo

  • waveflow-core pin bumped to ca0819dd5d6a044cea0c3855a3b80b5785ce6c99 — the desktop main HEAD post-A.4.2 merge, carries the new crates/core/src/sync/{mod.rs,payload_hash.rs} module + the Hlc { wall: i64, logical: i32 } struct.

Code change

  • Delete src/payload_hash.rs + remove pub mod payload_hash; from src/lib.rs. All consumers (apply pipeline) now use waveflow_core::sync::payload_hash::compute_payload_hash;.
  • Add impl From<crate::sync::Hlc> for waveflow_core::sync::Hlc in src/sync.rs. The server-side Hlc keeps its utoipa::ToSchema derive for the OpenAPI surface; the core twin is structurally identical (same two fields, same Eq) but axum-agnostic. Every call site that hands stamp.hlc to a core helper gets .into() so the conversion stays explicit at the boundary.

What this does NOT do

  • ❌ Backfill du payload_hash sur rows legacy server → Phase B
  • ❌ Apply pipeline desktop (consumer) → Phase B (WS subscriber)
  • ❌ CRDT OR-Set + FI → Phase C
  • ❌ Lamport retire → Phase D
  • ❌ Cargo workspace consolidation (server + core in one repo) — out of scope, the git-pin approach stays

Test plan

  • cargo check --all-targets --all-features clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo test --lib — 34 pass (the 12 ex-payload_hash unit tests now live in waveflow-core and run under cargo test -p waveflow-core)
  • cargo test --test apply --test apply_digest — 37 + 7 pass (apply pipeline + digest endpoint end-to-end)
  • cargo test --test sync — 17 pass (push v1/v2 round-trip, HLC regression, websocket fan-out)

Byte-for-byte stability of compute_payload_hash between the retired
server module and the core port is locked down by the A.4.1 PR's
suite (desktop #238 commit 2c20bd9 — 12 tests mirror the server's
exact byte-form expectations).

Refs

  • RFC-003 §2 (total order), §4 (canonical form)
  • Desktop A.4.1 (PR #238) — waveflow_core::sync::payload_hash module landed
  • Desktop A.4.2 (PR #244) — drain emits v2 wire shape

Closes the Phase A.4 cross-repo loop opened by desktop #238 + #244.
✅ This is the last PR of Phase A.

Summary by CodeRabbit

Release Notes

  • Chores

    • Mise à jour de la dépendance interne waveflow-core afin de bénéficier des dernières améliorations.
  • Bug Fixes

    • Amélioration de la cohérence du calcul des identifiants de contenu pour la synchronisation et les opérations idempotentes (création/UPSERT), afin de réduire les divergences lors des mises à jour.
  • Refactor

    • Mise en place d’une logique de calcul de hash et d’une conversion de précision temporelle alignées sur la dépendance waveflow-core.

….4.2

Phase A.4.3 of RFC-003 closes the desktop ↔ server payload-hash
loop. The helper module that landed in waveflow-server A.2.2.1
(`src/payload_hash.rs`, 366 LOC, 12 inline tests) moves into
waveflow-core under `sync::payload_hash` (desktop PR #238 — A.4.1)
so a single canonical-serialisation implementation drives both
sides of the wire. The server bumps its `waveflow-core` pin to
the desktop main SHA that ships both A.4.1 + A.4.2 and consumes
the helpers from there.

## Cargo

- `waveflow-core` pin bumped to
  `ca0819dd5d6a044cea0c3855a3b80b5785ce6c99` — the desktop main
  HEAD post-A.4.2 merge, which carries the new
  `crates/core/src/sync/{mod.rs,payload_hash.rs}` module + the
  `Hlc { wall: i64, logical: i32 }` struct.

## Code

- Delete `src/payload_hash.rs` + remove `pub mod payload_hash;`
  from `src/lib.rs`. All consumers (apply pipeline) now `use
  waveflow_core::sync::payload_hash::compute_payload_hash;`.
- Add `impl From<crate::sync::Hlc> for waveflow_core::sync::Hlc`
  in `src/sync.rs`. The server-side `Hlc` keeps its
  `utoipa::ToSchema` derive for the OpenAPI surface; the core
  twin is structurally identical (same two fields, same Eq) but
  axum-agnostic. Every call site that hands `stamp.hlc` to a
  core helper gets `.into()` so the conversion stays explicit at
  the boundary.

## Hors scope

- ❌ Backfill du `payload_hash` sur rows legacy server → Phase B
- ❌ Apply pipeline desktop (consumer) → Phase B (WS subscriber)
- ❌ CRDT OR-Set + FI → Phase C
- ❌ Lamport retire → Phase D
- ❌ Cargo workspace consolidation (server + core in one repo) —
  out of scope, the git-pin approach stays for now

## Validation

- `cargo check --all-targets --all-features` clean.
- `cargo clippy --all-targets --all-features -- -D warnings` clean.
- `cargo test --lib` — 34 pass (the 12 ex-payload_hash unit tests
  now live in waveflow-core and run under `cargo test
  -p waveflow-core`).
- `cargo test --test apply --test apply_digest` — 37 + 7 pass.
- `cargo test --test sync` — 17 pass (push v1/v2 round-trip, HLC
  regression, websocket fan-out, etc.).

The byte-for-byte stability of `compute_payload_hash` between
the retired server module and the core port is asserted by the
A.4.1 PR's port test suite (#238 commit `2c20bd9` — 12 tests
mirror the server's exact byte-form expectations).

Refs: RFC-003 §2 (total order), §4 (canonical form). Closes
the Phase A.4 cross-repo loop opened by desktop #238 + #244.

Signed-off-by: InstaZDLL <github.105mh@8shield.net>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@InstaZDLL, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 1 hour, 19 minutes, and 32 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b350ba7-7cb3-43cc-a928-17f082e06acf

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc51b8 and a43a0f3.

📒 Files selected for processing (1)
  • src/apply.rs
📝 Walkthrough

Walkthrough

Le module local src/payload_hash.rs (366 lignes) est supprimé. Sa déclaration est retirée de src/lib.rs. Une conversion From<Hlc> for waveflow_core::sync::Hlc est ajoutée dans src/sync.rs. Tous les handlers dans src/apply.rs basculent vers waveflow_core::sync::payload_hash::compute_payload_hash avec stamp.hlc.into(). La dépendance waveflow-core est mise à jour vers un nouveau rev git.

Changes

Migration payload_hash vers waveflow_core

Layer / File(s) Summary
Conversion HLC et dépendance
src/sync.rs, Cargo.toml
Ajout de impl From<Hlc> for waveflow_core::sync::Hlc (copie de wall et logical) et mise à jour du rev git de waveflow-core vers le commit exposant sync::payload_hash.
Migration des handlers apply.rs
src/apply.rs
Remplacement des imports locaux par waveflow_core::sync::payload_hash::compute_payload_hash dans tous les modules (profile_resolve, profile, playlist, library, liked, rating, track) avec conversion HLC via stamp.hlc.into().
Nettoyage de l'API publique locale
src/lib.rs, src/payload_hash.rs
Suppression de la déclaration pub mod payload_hash et du fichier complet contenant HlcTriple, hlc_strict_gt, canonical_serialize, compute_payload_hash et leurs tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

type: refactor, scope: sync, scope: deps, size: m

Poem

🌊 Adieu payload_hash.rs, soldat local loyal,
Tu rejoins waveflow_core pour un destin plus central.
Un petit into() suffit à tisser le lien,
BLAKE3 tourne toujours dans le nouvel endroit.
La crate s'allège, l'harmonie s'établit bien ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Le titre décrit précisément la phase RFC-003 (A.4.3) et les actions clés : suppression de payload_hash et mise à jour de la dépendance waveflow-core.
Description check ✅ Passed La description couvre tous les éléments clés : résumé détaillé, changements code substantiels (suppression/ajout), test plan complet avec résultats validés, et notes importantes sur les dépendances critiques.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sync-v2-phase-a-4-3-pin-core-payload-hash

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added scope: server Server core (Rust) scope: deps Dependencies scope: api Native /api/v2 surface scope: sync User-data sync type: feat New feature labels Jun 15, 2026
@InstaZDLL

Copy link
Copy Markdown
Owner Author

@coderabbitai full review please.

@github-actions github-actions Bot added the size: xl > 500 lines label Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== PR `#58` diff ==="
gh pr diff 58 --repo InstaZDLL/waveflow-server

echo ""
echo "=== Changed files list ==="
gh pr view 58 --repo InstaZDLL/waveflow-server --json files --jq '.files[].path'

Length of output: 54461



@InstaZDLL Voici la revue complète.


Revue — Phase A.4.3

✅ Logique du changement — OK

La migration est propre :

  • Suppression de src/payload_hash.rs et retrait du pub mod dans lib.rs : sans accroc.
  • Les 8 call sites dans src/apply.rs sont cohérents : import path corrigé + .into() systématique sur stamp.hlc.
  • impl From<Hlc> for waveflow_core::sync::Hlc dans src/sync.rs : correct, les règles orpheline sont respectées (le serveur possède crate::sync::Hlc), la conversion est une copie de champ triviale, et le commentaire de doc est précis.

🔴 Problème critique : explosion transitive des dépendances

Le Cargo.lock introduit ~300 nouvelles crates, dont :

wasmtime 45.0.1
wasmtime-wasi 45.0.1
cranelift-codegen 0.132.1
cranelift-frontend 0.132.1
pulley-interpreter 45.0.1
regalloc2 0.15.1
... (Cranelift complet + WASI + waveflow-plugin-sdk)

Le serveur est configuré avec default-features = false, features = ["postgres"], mais le nouveau SHA de waveflow-core tire wasmtime inconditionnellement (via waveflow-plugin-sdk qui est désormais une dépendance directe de core non feature-gatée, comme en témoigne le lock).

Conséquences concrètes :

  • Le binaire serveur va grossir significativement (wasmtime + Cranelift = plusieurs MiB de code natif en release).
  • Le temps de compilation va exploser (Cranelift seul prend plusieurs dizaines de secondes à froid).
  • La surface d'attaque augmente sans raison pour un service HTTP/WS qui n'exécute aucun WASM.

Ce qu'il faut vérifier dans waveflow-core au SHA ca0819dd : waveflow-plugin-sdk et wasmtime doivent être sous un feature flag (ex. features = ["plugins"]) pour que le serveur puisse rester léger avec features = ["postgres"] uniquement. Si ce n'est pas le cas, il faudra soit corriger côté core avant de merger ce PR, soit isoler le feature gate.


🟡 Observation mineure

HlcTriple et hlc_strict_gt étaient pub dans le module supprimé. Ils ne sont pas réexposés depuis waveflow_core dans ce PR (l'apply pipeline ne les consommait pas directement, ce que confirment les tests). Si une phase future en a besoin, il faudra passer par waveflow_core::sync::payload_hash::HlcTriple — à documenter dans le tracking interne.


Résumé : La mécanique de migration est correcte. Le bloquant est l'entrée non intentionnelle de wasmtime dans le graphe de dépendances du serveur — à résoudre dans waveflow-core (feature-gate de waveflow-plugin-sdk) avant le merge.

✅ Action performed

Full review finished.

@github-actions github-actions Bot added type: feat New feature and removed type: feat New feature labels Jun 15, 2026
@InstaZDLL InstaZDLL self-assigned this Jun 15, 2026
@github-actions github-actions Bot added type: feat New feature and removed type: feat New feature labels Jun 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Cargo.toml`:
- Line 26: The waveflow-core dependency in Cargo.toml specifies a rev hash that
is not accessible on the upstream GitHub repository, compromising
reproducibility. Additionally, the resolved Cargo.lock includes unnecessary
WASM-related dependencies (wasmtime, wasmtime-wasi, waveflow-plugin-sdk) despite
disabling default features and only enabling postgres, adding unnecessary binary
bloat and compilation overhead. Verify that the specified rev commit hash exists
and is accessible on the upstream waveflow-core repository. If the rev is
invalid, either contact the waveflow-core maintainers to request feature-gating
the WASM plugin stack as optional dependencies, or revert the waveflow-core
dependency to a previous known-good rev that does not include these unnecessary
WASM dependencies, and block further upgrades until the upstream project
properly isolates optional plugin functionality.

In `@src/apply.rs`:
- Around line 298-299: The code in src/apply.rs fails the Rust formatting check
(cargo fmt --all --check). The import statement for compute_payload_hash and the
surrounding code wrapping around compute_payload_hash calls do not conform to
rustfmt standards. Run cargo fmt --all to automatically fix all formatting
issues in the file, then verify the changes pass cargo fmt --all --check before
committing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 97382e36-7e59-4b49-8829-8a9c9790b624

📥 Commits

Reviewing files that changed from the base of the PR and between 81688ba and 6fc51b8.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock, !*.lock
📒 Files selected for processing (5)
  • Cargo.toml
  • src/apply.rs
  • src/lib.rs
  • src/payload_hash.rs
  • src/sync.rs
💤 Files with no reviewable changes (2)
  • src/payload_hash.rs
  • src/lib.rs

Comment thread Cargo.toml
Comment thread src/apply.rs
Follow-up to #58 — CodeRabbit flagged two rustfmt diffs the .into()
add introduced:

- src/apply.rs:1506 — import order: `use crate::sync::SyncOpIn`
  must precede `use waveflow_core::sync::payload_hash::*` because
  rustfmt groups crate-local imports above external-crate ones.
- src/apply.rs:1699 — the `.into()` push past 100 chars triggered
  the standard binary-rhs wrap.

`cargo fmt --all -- --check` clean post-fix. No behavioural
change; pure style. Pin SHA stays untouched — desktop PR #245
will land first to remove the wasmtime + Cranelift transitive
deps that CodeRabbit's other finding flagged, then a separate
commit rebases the pin onto its merge SHA.

Signed-off-by: InstaZDLL <github.105mh@8shield.net>
@github-actions github-actions Bot added type: feat New feature and removed type: feat New feature labels Jun 15, 2026
@InstaZDLL

Copy link
Copy Markdown
Owner Author

@coderabbitai j'ai vérifié les deux findings :

🟡 rev SHA ca0819dd5d6a044cea0c3855a3b80b5785ce6c99 accessible sur upstream — vérifié via git ls-remote https://github.com/InstaZDLL/WaveFlow.git, le SHA pointe sur HEAD + refs/heads/main du repo desktop. Probable false alarm de ton côté (rate-limit GitHub pendant l'analyse). Le rev sera de toute façon rebasé une fois que le fix bloat ci-dessous merge.

🔴 wasmtime/Cranelift bloat transitif — finding 100% valide, confirmé : crates/core/Cargo.toml côté upstream avait wasmtime, wasmtime-wasi, waveflow-plugin-sdk en deps inconditionnelles, donc même avec default-features = false, features = ["postgres"] le server tirait l'intégralité de Cranelift. Fix ouvert côté desktop : InstaZDLL/WaveFlow#245 (ajoute le feature plugins qui isole tout le stack plugin). Quand #245 merge, ce PR rebumpera le pin core au nouveau SHA et regénérera le lock — wasmtime + Cranelift + ~300 crates sortiront du graphe server.

🟡 rustfmt apply.rs — fix appliqué sur commit a43a0f3. Deux endroits : (1) import order crate::sync::SyncOpIn avant waveflow_core::... (rustfmt group ordering), (2) ligne 1699 wrap après .into() qui poussait > 100 chars. cargo fmt --all -- --check clean post-fix.

Validation : cargo check --all-targets --all-features clean, fmt clean. Pin update + revalidation après merge de #245.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@InstaZDLL Parfait, tout est cohérent.

  • SHA : noté, false alarm de ma part — rate-limit GitHub au moment de l'analyse. Aucune action requise.
  • wasmtime bloat : la stratégie est correcte. WaveFlow#245 est le bon endroit pour isoler le stack plugin derrière un feature flag plugins. Une fois mergé, le rebump + cargo update -p waveflow-core + vérification cargo tree --features postgres | grep -i wasm suffira à confirmer que Cranelift est sorti du graphe.
  • rustfmt : commit a43a0f3 adressé.

Ce PR peut merger dès que WaveFlow#245 est fusionné et le pin rebumpé avec le lock régénéré. Rien d'autre à signaler côté serveur.

🐇

@InstaZDLL
InstaZDLL merged commit 000d210 into main Jun 15, 2026
11 checks passed
@InstaZDLL
InstaZDLL deleted the feat/sync-v2-phase-a-4-3-pin-core-payload-hash branch June 15, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api Native /api/v2 surface scope: deps Dependencies scope: server Server core (Rust) scope: sync User-data sync size: xl > 500 lines type: feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant