Skip to content

test(home): Clipboard source gate binds Chat's fixed target, and CI runs it - #415

Draft
SashaMIT wants to merge 4 commits into
developfrom
fix/clipboard-source-gate
Draft

SashaMIT wants to merge 4 commits into
developfrom
fix/clipboard-source-gate

Conversation

@SashaMIT

Copy link
Copy Markdown
Contributor

Summary

node scripts/home-clipboard-source-gate.mjs is part of just verify, and it fails on develop:

Error: capsules/chat-room/browser/chat-room.js must use the canonical Home Clipboard client and its fixed target binding

Cause: commit 32f1634d ("fix(chat): preserve conversation drafts and renew Home authority in place"). After that change, Chat builds its client options in clipboardOptions(), and it tears down and rebuilds the Home Clipboard client when Home renews its token (chat-room.js:18-24, :65-69). Chat still uses the canonical client, still has the one fixed targetId: "chat-room", and still calls homeClipboard.start(). But the gate matched the literal text createHomeClipboardClient({, which is now gone.

Evidence: the gate passes with 32f1634d^:capsules/chat-room/browser/chat-room.js (exit 0) and fails with 32f1634d:… (exit 1). git log -S 'createHomeClipboardClient({' names that commit.

Decision: the gate was wrong, the code is right. The renewed token has to reach a new client, so going back to two inline option objects would only duplicate the binding to satisfy a text match. This PR does not change Chat or any product behaviour.

Changes

  1. scripts/home-clipboard-source-gate.mjs: for each migrated capsule, the gate now requires:

    • the canonical client import,
    • a createHomeClipboardClient( call,
    • exactly one targetId: in the file, equal to the fixed binding,
    • homeClipboard.start().

    This is stricter than before in one way: a second or different target is now refused even when the call uses an inline object. The old check only asked whether the binding text appeared somewhere in the file.

  2. scripts/home-clipboard-source-gate.test.mjs (new): runs the real gate on a copied tree. Chat as it is now passes. These changes are refused: a different target, a second target, no start(), no canonical client, direct navigator.clipboard.

  3. CI did not run this gate. .github/ has no reference to it, so the break went unnoticed. scripts/test-source-gate.sh product-ui now runs the gate and its test, so both CI source-gate and the local pre-push gate run them. just verify runs test-source-gate.sh, so its separate line is removed.

Tests

node scripts/home-clipboard-source-gate.mjs   -> {"schema":"elastos.home.clipboard-source-gate/v1","ok":true,...}
node --test scripts/home-clipboard-source-gate.test.mjs
ok 1 - Chat's renewable Home Clipboard client passes the gate
ok 2 - the gate refuses Chat with a different target
ok 3 - the gate refuses Chat with a second target
ok 4 - the gate refuses Chat with no client start
ok 5 - the gate refuses Chat with no canonical client
ok 6 - the gate refuses Chat with direct navigator.clipboard

With develop's gate, test 1 fails (not ok 1). ./scripts/test-source-gate.sh product-ui exits 0. The prepush section reports 70 OK. git diff --check, check-product-data and public-copy-entropy-check are clean.

Gaps

  • The gate is a source-text check. The real Clipboard behaviour is proven by scripts/home-clipboard-headless-smoke.mjs, which this PR does not change.
  • This branch does not contain the zip 9 / RUSTSEC change. Until that lands in develop or is merged here, cargo-audit fails and CI cancels the run.

Generated by Claude Code

cargo-audit fails on every PR: zip 2.4.2 in elastos/Cargo.lock and in
capsules/object-provider/Cargo.lock (through its elastos-server path
dependency) has three advisories against ZipArchive::extract and the
stream extract API. The runtime calls neither; it reads each entry
itself. zip 9.0.4 is the patched release.

- elastos-server uses zip 9.0.4, still without default features. 9.x has
  no separate flate2 feature; deflate-flate2 now enables the dependency.
- Both lockfiles change only for zip: nix 0.31.3 and typed-path come in,
  derive_arbitrary goes. `cargo update -p zip` also moved unrelated range
  dependencies (windows-sys, getrandom); those lines stay as they were,
  and `cargo metadata --locked` accepts both files.
- ZipFile::name now returns a Result. The ZIP readers report an error as
  "invalid ZIP archive entry".
- Whole-archive extract keeps its rule for entry names. zip 9
  enclosed_name turns "/a.txt" into "a.txt" and folds "x/../a.txt" into
  "a.txt", so an entry that extract refuses today would be written. The
  runtime now checks the name with the rule zip 2.x applied: no NUL byte,
  no root or drive prefix, no climb above the archive root.

test_library_provider_extract_zip_refuses_absolute_dotdot_and_symlink_entries
covers absolute, "..", inner "..", backslash and symlink entries. It
passes on zip 2.4.2 and with this change, and fails on the Absolute.zip
case when extract uses zip 9 enclosed_name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6Qn9RX7LDqrwiAfNC2F2K
…call shape

32f1634 (renew Home authority in place) made Chat rebuild its Home Clipboard
client from a clipboardOptions() helper when Home renews its token. The client,
its fixed "chat-room" target and start() stayed the same, but the gate
matched the literal text "createHomeClipboardClient({", so `just verify`
failed on develop. The gate now requires the canonical client call, exactly
one targetId in the file, equal to the fixed binding, and start(). A second or
different target is now refused even when the call uses an inline object.
scripts/home-clipboard-source-gate.test.mjs runs the gate on a copied tree and
proves each refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6Qn9RX7LDqrwiAfNC2F2K
The Clipboard gate ran only in `just verify`, so CI did not see Chat's change
(32f1634) break it. scripts/test-source-gate.sh product-ui now runs the gate
and its refusal test, so CI source-gate and the local pre-push gate both run
them. `just verify` runs test-source-gate.sh, so its separate gate line is
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6Qn9RX7LDqrwiAfNC2F2K
zip 9 for RUSTSEC-2026-0367/0368/0369 so cargo-audit passes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6Qn9RX7LDqrwiAfNC2F2K
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Review: A. The 6 Clipboard gate tests pass and CI now runs them. Ready for Anders once CI is green.

Copy link
Copy Markdown
Contributor Author

CI on 4728164: source-home-linux (ubuntu-24.04) failed in the model-repair journey (run 39019721681, job 117389514977). The error was Installed Home journey failed: stage=model_interrupted_get_retry code=timeout check=restarted_home.

This failure is not caused by this PR:

No fix exists yet. I can't re-run the job from here (403). It needs one re-run.


Generated by Claude Code

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.

2 participants