Skip to content

Port over keyhive sync protocol orchestration and wire together#158

Open
jtfmumm wants to merge 6 commits into
mainfrom
jtfm/ark-orchestration
Open

Port over keyhive sync protocol orchestration and wire together#158
jtfmumm wants to merge 6 commits into
mainfrom
jtfm/ark-orchestration

Conversation

@jtfmumm
Copy link
Copy Markdown
Contributor

@jtfmumm jtfmumm commented May 11, 2026

This PR mostly ports over the remaining orchestration and periodic caching logic from automerge-repo-keyhive and wires this up in place of pre-existing stubs in this repo.

This changes the subduction CLI to be keyhive-aware. If we want this to be configurable, I'll need to refactor it (possibly in a future PR).

@jtfmumm jtfmumm force-pushed the jtfm/ark-orchestration branch from f6e7bb0 to d127df5 Compare May 11, 2026 11:38
@jtfmumm jtfmumm marked this pull request as ready for review May 11, 2026 11:40
@jtfmumm jtfmumm requested review from alexjg and expede as code owners May 11, 2026 11:40
}
/// Authorize a put to `sedimentree_id` by `author` against `keyhive`.
///
/// TODO: Only `author` is currently checked for [`Access::Edit`].
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're currently ignoring requestor here. Are we fine with this for the time being?

@@ -0,0 +1,156 @@
//! Custom composed handler that dispatches wire messages to sub-handlers,
//! forwarding unknown-protocol frames to a registered JS callback.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason this exists right now is that automerge-repo-keyhive is in a transitional state where it connects through the Rust subduction but for the client still uses the TS-side implementation of the keyhive sync protocol. Anything that's not a sync or ephemeral message is handled by its callback, which delegates to the TS protocol.

In the other direction, when automerge-repo-keyhive sends a keyhive message, it calls subduction.sendRawFrame and hands it off.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Once automerge-repo-keyhive is migrated to use the Rust protocol, I think this goes away.

Comment thread Cargo.toml
"Brooklyn Zelenka <hello@brooklynzelenka.com>"
]

# !@ FIXME: Replace local paths
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to update after keyhive release

@jtfmumm jtfmumm marked this pull request as draft May 11, 2026 16:05
@jtfmumm jtfmumm force-pushed the jtfm/ark-orchestration branch 3 times, most recently from 3f97589 to 49b2bea Compare May 12, 2026 09:55
@jtfmumm jtfmumm marked this pull request as ready for review May 12, 2026 10:05
@jtfmumm jtfmumm force-pushed the jtfm/ark-orchestration branch from b9ad1d9 to 4542ac9 Compare May 13, 2026 09:11
Comment on lines +232 to +235
let seed = key::load_signer_bytes(&args.key)?;
let signer = key::signer_from_seed(&seed);
let keyhive_signer = key::keyhive_signer_from_seed(&seed);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do this hardcoded inline rather than using the separate type?

Comment thread subduction_cli/src/keyhive.rs Outdated
Comment thread subduction_cli/src/keyhive.rs Outdated
}
}

impl KeyhiveConnection<Local> for CliConnKeyhiveAdapter {
Copy link
Copy Markdown
Member

@expede expede May 13, 2026

Choose a reason for hiding this comment

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

No Sendable? I need to double check, but I think Keyhive is now both Send and !Send (at your option)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right. I updated for the CLI path, which significantly simplifies things and gets us off that keyhive thread.

///
/// [`on_peer_disconnect`]: subduction_core::handler::Handler::on_peer_disconnect
pub async fn on_peer_connect(&self, peer_id: PeerId, conn: Conn) {
drop(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

will it not drop when the program exits this scope?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason this is here (and in a couple other spots) is that if you do let _ = self.tx.send... you run up against the let-underscore-drop lint. If instead, you just don't drop, you hit unused std::result::Result that must be used. So we're stuck in between let-underscore-drop and unused-must-use. You can actually do something like let _dropped = but that seemed worse than drop(.

What do you think?

Comment thread subduction_keyhive/src/handler.rs Outdated
@jtfmumm jtfmumm force-pushed the jtfm/ark-orchestration branch 2 times, most recently from 01938a9 to ceeeef2 Compare May 14, 2026 13:44
@jtfmumm jtfmumm force-pushed the jtfm/ark-orchestration branch from ceeeef2 to 2313520 Compare May 14, 2026 18:58
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.

3 participants