Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
ab3fc75
fix(store): let cancellation win over a dispatch rejection
TudorAndrei Nov 11, 2026
a993e1e
refactor(store): share the terminal-state tail and the cancel body
TudorAndrei Nov 11, 2026
67e654b
refactor(store): guard state changes on the state that was checked
TudorAndrei Nov 11, 2026
d5232a6
refactor(pact): build the gateway test fixture in one place
TudorAndrei Nov 11, 2026
8292e5c
refactor(pact): read and write device status through sql_named
TudorAndrei Nov 11, 2026
e9c977f
fix(grokbot): leave no partial claim marker when its write fails
TudorAndrei Nov 11, 2026
4d821d7
fix(admin): reload the waiting hub screen, not always /
TudorAndrei Nov 11, 2026
3f7fc13
fix(grokbot): take over a runtime lock that never recorded its owner
TudorAndrei Nov 11, 2026
fb970ec
refactor(grokbot): drop connection checks the stop fence already covers
TudorAndrei Nov 11, 2026
c0e7b08
fix(admin): require the session to change the public listing
TudorAndrei Nov 11, 2026
a7bac1a
refactor(grokbot): derive executor forwarding from one operation table
TudorAndrei Nov 11, 2026
4d8f1f8
refactor(hub): bump versions and wake long polls in one Versions.commit
TudorAndrei Nov 11, 2026
45e5e50
refactor(grokbot): split settings and wake out of main, share the req…
TudorAndrei Nov 11, 2026
34873eb
fix(pact): guard every device transition by the state it leaves
TudorAndrei Nov 11, 2026
af4890c
refactor(hub): write the invite moves as one transition table
TudorAndrei Nov 11, 2026
105fb21
test(grokbot): share the fake node, stdio client and until helpers
TudorAndrei Nov 11, 2026
edb9806
refactor(mcp): require the node data directory
TudorAndrei Nov 11, 2026
d8c6817
refactor(hub): one search helper and a shorter counted/2 in the router
TudorAndrei Nov 11, 2026
88ccf41
refactor(node): let the pinned JSON client report HttpError
TudorAndrei Nov 11, 2026
98c2d4d
refactor(hub): look up an account by full name and type in Names
TudorAndrei Nov 11, 2026
218114b
fix(grokbot): rebuild an installed Aether binary that is too old
TudorAndrei Nov 11, 2026
d2a8265
refactor: remove dead code
TudorAndrei Nov 11, 2026
081c1c5
fix(hub): count only live owner links toward the owner-link limits
TudorAndrei Nov 11, 2026
1a033fd
refactor(hub): compute the wanted account values once in Accounts.put
TudorAndrei Nov 11, 2026
d855dc0
test(grokbot): replay the agent-socket transcript against the bridge
TudorAndrei Nov 11, 2026
e8f2e5d
refactor(hub): fold valid_endpoint?, hide Blocks.blocked?, add Notify…
TudorAndrei Nov 11, 2026
cb925ee
refactor(pact): rely on Validation for the PA token's iss and aud
TudorAndrei Nov 11, 2026
3f156b5
fix(hub): give no last-seen time past the presence keep window
TudorAndrei Nov 11, 2026
10fe6d5
fix(hermes): end the node session cleanly when a message handler fails
TudorAndrei Nov 11, 2026
dde9822
fix(hermes): give each adapter connect its own stop event
TudorAndrei Nov 11, 2026
b4a6e81
refactor(hermes): resolve the platform data directory in one place
TudorAndrei Nov 11, 2026
8d40145
refactor(hub): share the test helpers for rate-limit windows, invite …
TudorAndrei Nov 11, 2026
e621506
refactor(openclaw): drop unused account field, local flag and exports
TudorAndrei Nov 11, 2026
683e0bd
refactor(mcp): read presence through caller_hub
TudorAndrei Nov 11, 2026
5811a1f
refactor(node): remove the ProofHandle forwarding layer
TudorAndrei Nov 11, 2026
e6c759a
refactor(agent): make start_turn_with_events the required Agent method
TudorAndrei Nov 11, 2026
0e6a8e8
refactor(hub): follow the hub access directly and carry the signer in…
TudorAndrei Nov 11, 2026
d644d1a
test: share blocking, run, utf8 and the scratch directory in common
TudorAndrei Nov 11, 2026
a225c6e
fix(admin): keep a confirmation token when its confirm fails
TudorAndrei Nov 11, 2026
e62b733
refactor(mcp): send admin requests through one ask helper
TudorAndrei Nov 11, 2026
1d5b1ef
refactor(node): merge the pinned HTTPS module into pinned_json
TudorAndrei Nov 11, 2026
84ee2be
refactor(node): release the execution slot through one guard
TudorAndrei Nov 11, 2026
d7b5a10
refactor(node): share worker shutdown and group the publication flags
TudorAndrei Nov 11, 2026
7f1c650
fix(pact): spend a refresh token only for the caller its grant binds
TudorAndrei Nov 11, 2026
d1ce6f4
refactor(node): drop the per-event cursor check in roster sync
TudorAndrei Nov 11, 2026
c9de2a8
refactor(mcp): share the tool result and find-wait shapes
TudorAndrei Nov 11, 2026
0034281
test: keep a server process and its output in one shared type
TudorAndrei Nov 11, 2026
fe8296a
refactor(admin): one UiMode instead of the host_ui and caller flags
TudorAndrei Nov 11, 2026
49cef4e
refactor(agent): remove the unused agent workspace hook
TudorAndrei Nov 11, 2026
bc3766e
test: start the control service through one helper
TudorAndrei Nov 11, 2026
fa63d5d
fix(node): settle each execution exactly once
TudorAndrei Nov 11, 2026
dea7309
test: reuse the node_listening parse and the fake Codex writer
TudorAndrei Nov 11, 2026
e216416
fix(node): requeue a task when shutdown lands just before it starts
TudorAndrei Nov 11, 2026
e9b652f
refactor(hub): share the JSON, no-answer and not-found request plumbing
TudorAndrei Nov 11, 2026
89a9f06
refactor(node): inline roster_sync into the two sync loops
TudorAndrei Nov 11, 2026
b9c3637
refactor(pact): keep only the error cases callers tell apart
TudorAndrei Nov 11, 2026
12167df
refactor(admin): one Notice enum for the host and caller screens
TudorAndrei Nov 11, 2026
f96f194
refactor(hub): return HubError and ListingError from the protocol checks
TudorAndrei Nov 11, 2026
3dbc3ec
test: drop an unused step attribute and merge the page snapshot steps
TudorAndrei Nov 11, 2026
74f070c
refactor(agent): type the Codex sandbox and validate its limits once
TudorAndrei Nov 11, 2026
4d9c100
chore(scripts): share the relay start, fail and the model tuning in l…
TudorAndrei Nov 11, 2026
4ed99be
refactor(admin): count what waits once and keep hub_form_screen in hu…
TudorAndrei Nov 11, 2026
4ce896d
test(agent): find sleep through PATH in the Codex session tests
TudorAndrei Nov 11, 2026
5a2f338
refactor(pact): check message:send with ? and one error path
TudorAndrei Nov 11, 2026
a91c71e
refactor(hub): parse a listing into one type and define its limits once
TudorAndrei Nov 11, 2026
1a9a108
refactor(node): replace unit errors with directory_client::Failed
TudorAndrei Nov 11, 2026
f5afd5e
fix(agent): charge a Codex turn's setup time to its deadline
TudorAndrei Nov 11, 2026
f88f474
refactor(node): print CLI results through one print_json helper
TudorAndrei Nov 11, 2026
c6299ae
refactor(node): parse node commands into the library types
TudorAndrei Nov 11, 2026
208abe1
fix(pact): forget a message whose send was dropped mid-turn
TudorAndrei Nov 11, 2026
0b4ee21
refactor(node): open the direct store once for a request
TudorAndrei Nov 11, 2026
d88e3e8
refactor(admin): helpers for the session, page, hub and lock of a han…
TudorAndrei Nov 11, 2026
eaec7a2
refactor(hub): build a new hub approval with one constructor
TudorAndrei Nov 11, 2026
07e192c
fix(agent): decline Codex approval requests that come before a response
TudorAndrei Nov 11, 2026
8989ec7
refactor(transport): build reply frames with Frame::reply_to
TudorAndrei Nov 11, 2026
ceeea2e
refactor(hub): read the hub name and agent kind through two helpers
TudorAndrei Nov 11, 2026
40133bb
refactor(node): keep the PublicationRecord in DirectoryPublication
TudorAndrei Nov 11, 2026
d1da998
refactor(admin): typed actions for the group and listing forms
TudorAndrei Nov 11, 2026
2f04cb2
refactor(direct): build request frames without a JSON round trip
TudorAndrei Nov 11, 2026
5a8843d
refactor(hub): drop a stored relay copy, an unreachable arm and an alias
TudorAndrei Nov 11, 2026
9c9f313
refactor(transport): hold a link's connection state in one enum
TudorAndrei Nov 11, 2026
5b3593e
refactor(transport): name the phases of a served connection
TudorAndrei Nov 11, 2026
1857599
refactor(admin): one Tone and state_badge for task and sent states
TudorAndrei Nov 11, 2026
0c85e97
fix(agent): bound the connected agent's early cancels
TudorAndrei Nov 11, 2026
1554464
fix(node): serialise directory renewals with capability changes
TudorAndrei Nov 11, 2026
94ee828
refactor(transport): read and write the active relay like the saved one
TudorAndrei Nov 11, 2026
9564e94
refactor(admin): lock the administration per request and check sizes …
TudorAndrei Nov 11, 2026
0ea5f35
fix(admin): bind the administration socket privately
TudorAndrei Nov 11, 2026
a3e2045
docs(direct): say which contact readers include expired contacts
TudorAndrei Nov 11, 2026
636e8cf
fix(hub): keep the request approval when the hub answer is lost
TudorAndrei Nov 11, 2026
1e2b0bc
fix(agent): honour a Codex cancel that comes before the turn starts
TudorAndrei Nov 11, 2026
f2581c0
fix(hub): take a listing off the hub when this node cannot keep it
TudorAndrei Nov 11, 2026
a574e96
refactor(admin): days_select and days_label for the access days
TudorAndrei Nov 11, 2026
6697d37
refactor(agent): read a Codex turn's answer once and share the JSON w…
TudorAndrei Nov 11, 2026
c3fec52
fix(hub): say so when this computer cannot remove a block
TudorAndrei Nov 11, 2026
b6f93b1
refactor(node): read the queue limits through one helper
TudorAndrei Nov 11, 2026
2c14395
fix(hub): undo the group membership of a grant that cannot be pinned
TudorAndrei Nov 11, 2026
25dcb41
refactor(admin): shared error line, section heading, count badge, URL…
TudorAndrei Nov 11, 2026
9e9542c
refactor(admin): compute what an invite row offers in one function
TudorAndrei Nov 11, 2026
4abe850
refactor(admin): post_button for the one-button forms
TudorAndrei Nov 11, 2026
4dc0cff
Merge branch 't3/ebedae21' into t3/a6528b53
TudorAndrei Nov 11, 2026
415fe1a
Merge branch 't3/79f9d9a3' into t3/a6528b53
TudorAndrei Nov 11, 2026
0a8d7d6
Merge branch 't3/90229b29' into t3/a6528b53
TudorAndrei Nov 11, 2026
66ee071
Merge branch 't3/9eceac7c' into t3/a6528b53
TudorAndrei Nov 11, 2026
b2b42dd
Merge branch 't3/d67a30c0' into t3/a6528b53
TudorAndrei Nov 11, 2026
a248919
Merge branch 't3/ad6ba1dc' into t3/a6528b53
TudorAndrei Nov 11, 2026
954a266
Merge branch 't3/20202aa8' into t3/a6528b53
TudorAndrei Nov 11, 2026
8ba202a
Merge branch 't3/7b34531d' into t3/a6528b53
TudorAndrei Nov 11, 2026
bfda7ce
Merge branch 't3/7e0830d5' into t3/a6528b53
TudorAndrei Nov 11, 2026
9717e90
Merge branch 't3/41091ecb' into t3/a6528b53
TudorAndrei Nov 11, 2026
09a1774
Merge branch 't3/b082a0af' into t3/a6528b53
TudorAndrei Nov 11, 2026
75a586e
Merge branch 't3/9fc98a36' into t3/a6528b53
TudorAndrei Nov 11, 2026
5d395cc
Merge branch 't3/c57ee90e' into t3/a6528b53
TudorAndrei Nov 11, 2026
c6f59d0
test(node): let the slow fake Codex find sleep with an empty environment
TudorAndrei Nov 11, 2026
a6a95e9
refactor(node): read hub name and agent kind through the settings hel…
TudorAndrei Nov 11, 2026
387e4e0
refactor(hub): remove the HubStore wrapper
TudorAndrei Nov 11, 2026
33e9508
refactor(node): pass NodeService options to its constructor
TudorAndrei Nov 11, 2026
bbcad81
Merge branch 't3/45496cb9' into t3/a6528b53
TudorAndrei Nov 11, 2026
a1190e6
fix(invites): undo the grant and new membership when the invite canno…
TudorAndrei Nov 11, 2026
c77ba99
test(admin): move the admin page tests next to their code
TudorAndrei Nov 11, 2026
253380a
Merge branch 't3/fa5dc04f' into t3/a6528b53
TudorAndrei Nov 11, 2026
5d0ac48
Merge branch 't3/c62dbc7c' into t3/a6528b53
TudorAndrei Nov 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/aether-core/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

use crate::named;

/// The most days a direct grant lasts.
pub const MAX_DIRECT_ACCESS_DAYS: u32 = 365;

#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum QueueLimitId {
Global,
Expand Down
113 changes: 89 additions & 24 deletions crates/aether-store/src/pact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::Path;

use rusqlite::{Connection, OptionalExtension, TransactionBehavior, params};

use crate::{StoreError, migrate::open_connection};
use crate::{StoreError, migrate::open_connection, sql_named};

pub const PACT_DATABASE: &str = "pact.sqlite";

Expand Down Expand Up @@ -299,7 +299,7 @@ impl PactStore {
authorization.interval_seconds,
authorization.created_at,
authorization.expires_at,
DeviceStatus::Pending.as_str(),
DeviceStatus::Pending,
],
)?;
Ok(())
Expand All @@ -315,7 +315,7 @@ impl PactStore {
.connection
.query_row(
"SELECT user_code, brand_id, pa_issuer, pa_subject, scopes, expires_at FROM pact_device_authorizations WHERE user_code=?1 AND status=?3 AND expires_at > ?2",
params![user_code, now, DeviceStatus::Pending.as_str()],
params![user_code, now, DeviceStatus::Pending],
|row| {
Ok(PendingDevice {
user_code: row.get(0)?,
Expand Down Expand Up @@ -345,8 +345,8 @@ impl PactStore {
user_code,
grant.grant_id,
now,
DeviceStatus::Approved.as_str(),
DeviceStatus::Pending.as_str(),
DeviceStatus::Approved,
DeviceStatus::Pending,
],
)?;
if changed != 1 {
Expand All @@ -357,11 +357,12 @@ impl PactStore {
Ok(())
}

/// Denies the pending authorization `user_code`.
pub fn deny_device(&self, user_code: &str) -> Result<(), StoreError> {
/// Denies the pending authorization `user_code`. `NotFound` when it is
/// no longer pending, or has expired.
pub fn deny_device(&self, user_code: &str, now: i64) -> Result<(), StoreError> {
let changed = self.connection.execute(
"UPDATE pact_device_authorizations SET status=?2 WHERE user_code=?1 AND status=?3",
params![user_code, DeviceStatus::Denied.as_str(), DeviceStatus::Pending.as_str()],
"UPDATE pact_device_authorizations SET status=?2 WHERE user_code=?1 AND status=?3 AND expires_at > ?4",
params![user_code, DeviceStatus::Denied, DeviceStatus::Pending, now],
)?;
if changed == 1 { Ok(()) } else { Err(StoreError::NotFound) }
}
Expand Down Expand Up @@ -405,24 +406,32 @@ impl PactStore {
let poll = if expires_at <= now {
DevicePoll::Expired
} else {
match DeviceStatus::parse(&status).ok_or(StoreError::InvalidState)? {
match status {
DeviceStatus::Denied => DevicePoll::Denied,
DeviceStatus::Consumed => DevicePoll::Consumed,
DeviceStatus::Pending => {
let slow_down = last_polled_at
.is_some_and(|last| now.saturating_sub(last) < interval);
transaction.execute(
"UPDATE pact_device_authorizations SET last_polled_at=?2 WHERE device_code_hash=?1",
params![device_code_hash, now],
"UPDATE pact_device_authorizations SET last_polled_at=?2 WHERE device_code_hash=?1 AND status=?3",
params![device_code_hash, now, DeviceStatus::Pending],
)?;
DevicePoll::Pending { slow_down }
}
DeviceStatus::Approved => {
transaction.execute(
"UPDATE pact_device_authorizations SET status=?2 WHERE device_code_hash=?1",
params![device_code_hash, DeviceStatus::Consumed.as_str()],
// Like every transition here, the update names the state
// it leaves, so only one poll can consume an approval.
let consumed = transaction.execute(
"UPDATE pact_device_authorizations SET status=?2 WHERE device_code_hash=?1 AND status=?3 AND expires_at > ?4",
params![
device_code_hash,
DeviceStatus::Consumed,
DeviceStatus::Approved,
now,
],
)?;
let grant = grant_id
.filter(|_| consumed == 1)
.map(|grant_id| query_grant(&transaction, &grant_id))
.transpose()?
.flatten();
Expand Down Expand Up @@ -454,10 +463,15 @@ impl PactStore {
}

/// Spends an unused, unexpired refresh token and returns its grant.
/// A second use of the same token returns `None`.
/// A second use of the same token returns `None`. Only the personal
/// agent and user the grant belongs to, for its Brand, can spend it;
/// anyone else gets `None` and the token stays unused.
pub fn use_refresh_token(
&mut self,
token_hash: &str,
brand_id: &str,
pa_issuer: &str,
pa_subject: &str,
now: i64,
) -> Result<Option<PactGrant>, StoreError> {
let transaction = rusqlite::Transaction::new_unchecked(
Expand All @@ -466,8 +480,8 @@ impl PactStore {
)?;
let grant_id: Option<String> = transaction
.query_row(
"UPDATE pact_refresh_tokens SET used_at=?2 WHERE token_hash=?1 AND used_at IS NULL AND expires_at > ?2 RETURNING grant_id",
params![token_hash, now],
"UPDATE pact_refresh_tokens SET used_at=?2 WHERE token_hash=?1 AND used_at IS NULL AND expires_at > ?2 AND grant_id IN (SELECT grant_id FROM pact_grants WHERE brand_id=?3 AND pa_issuer=?4 AND pa_subject=?5) RETURNING grant_id",
params![token_hash, now, brand_id, pa_issuer, pa_subject],
|row| row.get(0),
)
.optional()?;
Expand Down Expand Up @@ -526,9 +540,11 @@ aether_core::named!(DeviceStatus {
Consumed => "consumed",
});

sql_named!(DeviceStatus);

/// The device-authorization columns `poll_device` decides on.
struct DeviceRow {
status: String,
status: DeviceStatus,
grant_id: Option<String>,
interval: i64,
last_polled_at: Option<i64>,
Expand Down Expand Up @@ -769,7 +785,7 @@ mod tests {
let (_directory, mut store) = store();
store.create_device_authorization(&device("AAAA-AAAA", "one")).unwrap();
store.create_device_authorization(&device("BBBB-BBBB", "two")).unwrap();
store.deny_device("AAAA-AAAA").unwrap();
store.deny_device("AAAA-AAAA", 200).unwrap();
assert_eq!(
store.approve_device("AAAA-AAAA", &grant("g1"), 200),
Err(StoreError::NotFound),
Expand All @@ -788,17 +804,66 @@ mod tests {
assert!(store.grant("g2").unwrap().is_none());
}

#[test]
fn an_expired_authorization_cannot_be_denied() {
let (_directory, mut store) = store();
store.create_device_authorization(&device("AAAA-AAAA", "one")).unwrap();
assert_eq!(store.deny_device("AAAA-AAAA", 700), Err(StoreError::NotFound));
assert_eq!(
store
.poll_device("one", "review", "https://pa.example", "user-1", 800)
.unwrap(),
DevicePoll::Expired,
);
}

#[test]
fn a_refresh_token_works_once_and_not_after_it_expires() {
let (_directory, mut store) = store();
store.create_device_authorization(&device("ABCD-EFGH", "hash")).unwrap();
store.approve_device("ABCD-EFGH", &grant("g"), 200).unwrap();
store.put_refresh_token("once", "g", 5_000).unwrap();
store.put_refresh_token("late", "g", 5_000).unwrap();
assert_eq!(store.use_refresh_token("once", 300).unwrap(), Some(grant("g")));
assert_eq!(store.use_refresh_token("once", 301).unwrap(), None);
assert_eq!(store.use_refresh_token("late", 5_000).unwrap(), None);
assert_eq!(store.use_refresh_token("unknown", 300).unwrap(), None);
let spend = |store: &mut PactStore, token: &str, now: i64| {
store
.use_refresh_token(token, "review", "https://pa.example", "user-1", now)
.unwrap()
};
assert_eq!(spend(&mut store, "once", 300), Some(grant("g")));
assert_eq!(spend(&mut store, "once", 301), None);
assert_eq!(spend(&mut store, "late", 5_000), None);
assert_eq!(spend(&mut store, "unknown", 300), None);
}

#[test]
fn only_the_grant_owner_can_spend_its_refresh_token() {
let (_directory, mut store) = store();
store.create_device_authorization(&device("ABCD-EFGH", "hash")).unwrap();
store.approve_device("ABCD-EFGH", &grant("g"), 200).unwrap();
store.put_refresh_token("token", "g", 5_000).unwrap();
for (brand, issuer, subject) in [
("review", "https://other.example", "user-1"),
("other", "https://pa.example", "user-1"),
("review", "https://pa.example", "user-2"),
] {
assert_eq!(
store.use_refresh_token("token", brand, issuer, subject, 300).unwrap(),
None,
);
}
// Nobody else's attempt spent it.
assert_eq!(
store
.use_refresh_token(
"token",
"review",
"https://pa.example",
"user-1",
300
)
.unwrap(),
Some(grant("g")),
);
}

#[test]
Expand Down
Loading
Loading