Skip to content

refactor(sync): align test harness with HLC-transport protocol#4

Merged
haex-space merged 5 commits into
mainfrom
refactor/align-with-hlc-transport
Apr 22, 2026
Merged

refactor(sync): align test harness with HLC-transport protocol#4
haex-space merged 5 commits into
mainfrom
refactor/align-with-hlc-transport

Conversation

@haex-space

@haex-space haex-space commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Test cleanup: remove the batch-validation.spec.ts suite, the negative batchSeq evil scenario, and the dead batch properties from the shared SyncChange helper + crdt-behavior apply-change payloads
  • Docker infra: add local-vault Buildx named context so vault-a/vault-b can build from a local haex-vault checkout instead of always cloning from GitHub (set HAEX_VAULT_LOCAL_PATH + USE_LOCAL_VAULT=true in .env). Stays opt-in; default behavior is unchanged.
  • All pnpm docker:* scripts now pass --env-file .env so the root-level .env is honoured (docker-compose looks beside the compose file by default).

Why

Transaction-scope HLC is now the semantic grouping key on both haex-vault and haex-sync-server — batchId/batchSeq/batchTotal have been removed from the wire format. The E2E tests asserted behavior on fields that no longer exist, so three specs were either outdated or actively failing against the new server.

The local-vault mount is a dev-ergonomics fix for the same refactor push: we couldn't E2E-test in-flight haex-vault branches without a CI roundtrip, which made iterating on the CRDT pipeline painful.

Companion work

Test plan

  • tests/extensions — 14/14 pass
  • tests/spaces — 167/167 pass (fixed: admin deletes the shared space, send invite to Personal space)
  • tests/sync — 97/97 pass
  • Local vault-a build from mounted source compiles Tauri app and boots tauri-driver

Summary by CodeRabbit

  • New Features

    • Optional local vault support for Docker builds (use a local vault checkout during image builds).
  • Chores

    • Docker CLI scripts now load .env during compose operations.
    • Build configuration adds a toggle to choose local vs. cloned vault sources.
  • Bug Fixes / Tests

    • Removed batch metadata from sync change payloads; deleted batch-validation test suite and one negative batchSeq test.
  • Documentation

    • E2E versioning simplified to environment-variable refs; docs and examples updated/trimmed.

Until now the vault-a/vault-b images cloned haex-vault from GitHub via
HAEX_VAULT_REF, which made it impossible to E2E-test in-flight branches
before they are pushed. Developers hit a cycle of push → trigger CI →
wait even for trivial local iteration.

Introduce a `local-vault` build context (Buildx named context) that
defaults to a harmless dummy directory. When HAEX_VAULT_LOCAL_PATH and
USE_LOCAL_VAULT=true are set in .env, the Dockerfile copies sources from
the mount instead of cloning — node_modules, src-tauri/target, .nuxt
and .output are stripped so host/container architecture mismatches
cannot leak.

All pnpm docker:* scripts now pass --env-file .env explicitly so the
root-level .env is honoured (docker-compose would otherwise look beside
the compose file in docker/).
The server no longer carries batch_id/batch_seq/batch_total fields (see
haex-sync-server refactor/remove-batch-fields). Drop the entire
batch-validation.spec.ts suite, the negative-batchSeq evil scenario,
and the now-dead batch properties from the shared SyncChange helper and
the crdt-behavior apply_remote_changes test payloads.
@coderabbitai

coderabbitai Bot commented Apr 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@haex-space has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 57 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 6 minutes and 57 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f5ef8714-1b22-4702-8dad-55a30b52faaf

📥 Commits

Reviewing files that changed from the base of the PR and between 0208067 and 73d21af.

📒 Files selected for processing (1)
  • docker/Dockerfile
📝 Walkthrough

Walkthrough

Adds optional local haex-vault build support via USE_LOCAL_VAULT/HAEX_VAULT_LOCAL_PATH, updates Dockerfile and compose to accept an additional build context and conditional copy, passes .env into docker compose npm scripts, removes batch metadata from sync change types, and deletes related tests and versioning schema/examples/docs.

Changes

Cohort / File(s) Summary
Local Vault config & build
\.env.example, docker/Dockerfile, docker/docker-compose.yml
Introduce HAEX_VAULT_LOCAL_PATH and USE_LOCAL_VAULT; Dockerfile adds ARG/ENV USE_LOCAL_VAULT and conditionally copies a local-vault additional build context into /repos/haex-vault when available, otherwise falls back to git clone. Compose adds additional_contexts: local-vault and forwards USE_LOCAL_VAULT build arg.
Docker CLI scripts
package.json
All docker:* npm scripts now run docker compose --env-file .env -f docker/docker-compose.yml ...; removed several release/version-related scripts and versions:* scripts.
Sync change shape & tests
tests/helpers/sync-server-helpers.ts, tests/database/crdt-behavior.spec.ts, tests/sync/...
Removed batchId, batchSeq, batchTotal from exported SyncChange type; updated tests to omit those fields. Deleted tests/sync/batch-validation.spec.ts and removed the negative batchSeq test case.
Docs & versioning artifacts
README.md, \.claude/architecture.md, examples/.e2e-versions.example.json, schemas/e2e-versions.schema.json
Removed JSON schema/example and script-driven version-resolution docs; simplified E2E version configuration to direct environment-variable Git refs and removed references to related scripts and presets.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Docker as Docker Build
  participant Local as Local FS (additional_context: local-vault)
  participant GitHub as GitHub (haex-vault repo)

  Dev->>Docker: docker compose build (--env-file .env)
  Docker->>Docker: read ARG USE_LOCAL_VAULT
  alt USE_LOCAL_VAULT == "true" and Local has src
    Docker->>Local: bind-mount local-vault -> /tmp/local-vault
    Docker->>Docker: copy /tmp/local-vault/* -> /repos/haex-vault
    Docker->>Docker: remove node_modules, .nuxt, .output, src-tauri/target
  else
    Docker->>GitHub: git clone haex-vault @ HAEX_VAULT_REF -> /repos/haex-vault
  end
  Docker->>Docker: continue image build using /repos/haex-vault
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A little hop, a local tree,

I brought the vault right home to me.
I trimmed the batch and cleared the lane,
Compose reads env and builds again.
Carrots for CI — cozy and lean. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly aligns with the core test cleanup objective—removing batch validation tests and batch-related properties from the sync harness in response to the HLC-transport protocol refactor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 refactor/align-with-hlc-transport

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

@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 the current code and only fix it if needed.

Inline comments:
In `@docker/Dockerfile`:
- Around line 30-55: The current COPY --from=local-vault . /tmp/local-vault/
creates a persistent layer that leaks sensitive files; remove that COPY and
change the following RUN block to use an ephemeral BuildKit bind mount (e.g. RUN
--mount=type=bind,from=local-vault,target=/tmp/local-vault ...) so the
local-vault contents are only mounted for that RUN and not committed to an image
layer; update the conditional that checks USE_LOCAL_VAULT and the paths
(/tmp/local-vault, /repos/haex-vault) accordingly and document that this
requires Docker BuildKit/experimental features to be enabled.

In `@package.json`:
- Around line 17-18: The package.json contains npm scripts that reference a
removed script (scripts/resolve-versions.sh) causing failures; remove or replace
the broken entries "docker:build:release", "docker:build:nightly",
"docker:test:release", "versions:resolve", "versions:release", and
"versions:nightly" from package.json and update README.md to remove any usage
examples calling scripts/resolve-versions.sh or the removed npm scripts, or
alternatively restore the missing scripts/resolve-versions.sh implementation and
ensure the script path and executable bits are correct so the listed npm scripts
work again; pick one approach (delete/references update OR restore the shell
script) and apply it consistently across package.json and documentation.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e86afd6b-89d0-443c-ac6c-9224fe86ebec

📥 Commits

Reviewing files that changed from the base of the PR and between 3056b68 and fd606d0.

📒 Files selected for processing (9)
  • .env.example
  • docker/Dockerfile
  • docker/docker-compose.yml
  • docker/dummy-vault/.gitkeep
  • package.json
  • tests/database/crdt-behavior.spec.ts
  • tests/helpers/sync-server-helpers.ts
  • tests/sync/batch-validation.spec.ts
  • tests/sync/evil-scenarios.spec.ts
💤 Files with no reviewable changes (4)
  • tests/sync/evil-scenarios.spec.ts
  • tests/helpers/sync-server-helpers.ts
  • tests/database/crdt-behavior.spec.ts
  • tests/sync/batch-validation.spec.ts

Comment thread docker/Dockerfile Outdated
Comment thread package.json Outdated
- Remove npm scripts referencing scripts/resolve-versions.sh and
  scripts/fetch-project-versions.sh (deleted in 0c729f7), along with
  orphan schemas/ and examples/ files.
- Simplify README and .claude/architecture.md to match the current
  env-var-driven version config.
- Replace Dockerfile `COPY --from=local-vault` with a BuildKit bind
  mount so local-vault contents never land in an image layer.
  Addresses CodeRabbit findings on PR #4.

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docker/Dockerfile`:
- Around line 50-51: The shell commands use the unquoted variable
${HAEX_VAULT_REF} in the git clone --branch and git checkout invocations; wrap
the variable in double quotes (e.g., "--branch \"${HAEX_VAULT_REF}\"" and "git
checkout \"${HAEX_VAULT_REF}\"") so word-splitting and globbing cannot break the
git clone or checkout steps referenced in the Dockerfile's git clone lines and
the subsequent git checkout command.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 24efcbd4-718f-4edc-8d96-7bbc96f1eef4

📥 Commits

Reviewing files that changed from the base of the PR and between fd606d0 and 2fa33b9.

📒 Files selected for processing (6)
  • .claude/architecture.md
  • README.md
  • docker/Dockerfile
  • examples/.e2e-versions.example.json
  • package.json
  • schemas/e2e-versions.schema.json
💤 Files with no reviewable changes (2)
  • schemas/e2e-versions.schema.json
  • examples/.e2e-versions.example.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Comment thread docker/Dockerfile Outdated
Prevents word-splitting and globbing if the ref ever contains whitespace
or shell metacharacters. Flagged by CodeRabbit on PR #4.

@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.

🧹 Nitpick comments (2)
docker/Dockerfile (2)

55-59: Consider quoting HAEXTENSION_REF and VAULT_SDK_REF for consistency.

The fix for word-splitting was applied to HAEX_VAULT_REF but these refs remain unquoted. While they're unchanged lines and likely use simple refs, quoting them would provide consistent protection against edge cases with spaces or special characters.

-RUN git clone --depth 1 --branch ${HAEXTENSION_REF} https://github.com/haex-space/haextension.git || \
-    (git clone https://github.com/haex-space/haextension.git && cd haextension && git checkout ${HAEXTENSION_REF})
+RUN git clone --depth 1 --branch "${HAEXTENSION_REF}" https://github.com/haex-space/haextension.git || \
+    (git clone https://github.com/haex-space/haextension.git && cd haextension && git checkout "${HAEXTENSION_REF}")

-RUN git clone --depth 1 --branch ${VAULT_SDK_REF} https://github.com/haex-space/vault-sdk.git || \
-    (git clone https://github.com/haex-space/vault-sdk.git && cd vault-sdk && git checkout ${VAULT_SDK_REF})
+RUN git clone --depth 1 --branch "${VAULT_SDK_REF}" https://github.com/haex-space/vault-sdk.git || \
+    (git clone https://github.com/haex-space/vault-sdk.git && cd vault-sdk && git checkout "${VAULT_SDK_REF}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker/Dockerfile` around lines 55 - 59, Quote the variable expansions for
HAEXTENSION_REF and VAULT_SDK_REF in the Dockerfile git clone and checkout
commands to prevent word-splitting and handle special characters; update the RUN
lines that reference ${HAEXTENSION_REF} and ${VAULT_SDK_REF} (both in the
--branch arguments and the subsequent git checkout uses) to use quoted
expansions (e.g. "${HAEXTENSION_REF}" and "${VAULT_SDK_REF}").

11-11: Consider adding a non-root USER for production-like hardening.

Trivy flags that no USER command specifies a non-root user (DS-0002). For an E2E test environment with webtop, root may be intentional, but if the test workloads don't require elevated privileges, adding a non-root user would improve security posture.

This can be deferred if webtop services require root or if this image is only used in isolated CI environments.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker/Dockerfile` at line 11, The Dockerfile currently uses the base image
ghcr.io/haex-space/haex-e2e-base:latest without switching away from root; add a
non-root user and switch to it to satisfy Trivy's DS-0002 check. Modify the
Dockerfile to create a dedicated user (e.g., app or e2euser with a fixed
UID/GID), ensure ownership/permissions on any needed directories (workdir,
config, webtop data) are set, and add a USER <username> line before the image is
finalized; if the base image already provides a non-root user, simply switch to
that USER instead. Ensure any startup scripts or services referenced in the
Dockerfile run correctly as the non-root user and document if root is required
so this change can be deferred.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docker/Dockerfile`:
- Around line 55-59: Quote the variable expansions for HAEXTENSION_REF and
VAULT_SDK_REF in the Dockerfile git clone and checkout commands to prevent
word-splitting and handle special characters; update the RUN lines that
reference ${HAEXTENSION_REF} and ${VAULT_SDK_REF} (both in the --branch
arguments and the subsequent git checkout uses) to use quoted expansions (e.g.
"${HAEXTENSION_REF}" and "${VAULT_SDK_REF}").
- Line 11: The Dockerfile currently uses the base image
ghcr.io/haex-space/haex-e2e-base:latest without switching away from root; add a
non-root user and switch to it to satisfy Trivy's DS-0002 check. Modify the
Dockerfile to create a dedicated user (e.g., app or e2euser with a fixed
UID/GID), ensure ownership/permissions on any needed directories (workdir,
config, webtop data) are set, and add a USER <username> line before the image is
finalized; if the base image already provides a non-root user, simply switch to
that USER instead. Ensure any startup scripts or services referenced in the
Dockerfile run correctly as the non-root user and document if root is required
so this change can be deferred.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 254053b3-9c0d-4ffa-b937-2e3e040b50b0

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa33b9 and 0208067.

📒 Files selected for processing (1)
  • docker/Dockerfile

Same word-splitting/globbing risk as HAEX_VAULT_REF, fixed for consistency
across all three ref-driven clones.
@haex-space haex-space merged commit 0a6511b into main Apr 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant