Commit Graph
85 Commits
Author SHA1 Message Date
kyle 4718b6f2eb fix(store): log format v1 with CRC and crash recovery 2026-10-19 15:35:42 -07:00
kyle 848721a70d fix(store): boot counter, durable releases, clock marker 2026-10-19 14:16:40 -07:00
kyle 6e2dc6f996 fix(hosts): one monotonic millisecond clock 2026-10-19 12:54:28 -07:00
kyle 2738de4959 fix(core): ack only observations the store kept
Exchange::accept enqueued a pending ack whenever
!(duplicate && addressed && released) held, even when the backend
store.insert returned Err (store full / backend error). On Err the
released flag computed to false, so an ack was still enqueued: a
receiver that did not keep the message acked it. For an addressed
offer that releases the sender's custody for a message nobody holds;
for a broadcast it fires a false confidence event at the sender.

Gate the ack enqueue on res.is_ok(): enqueue only when the store
actually retained the observation. The existing released-holder
exception still applies among kept copies. No bounce is recorded on
Err (already the case).

Adds a unit test exercising a capped store (StoreError::Full) for
both a broadcast and an addressed offer, and a tines-sim property
that drives custody with CappedStore-backed nodes and asserts the
"at least one holder" invariant still holds when stores fill.
2026-10-19 12:35:17 -07:00
kyle 836ab74e81 docs: fleet-fixes implementation plan 2026-10-19 12:02:33 -07:00
kyle 55cc7952bc docs: security assessment specs (fleet-fixes, host-hardening, 1.0 §10, threat model) 2026-10-19 12:02:33 -07:00
kyle 3b1a644b24 docs: tines-core 1.0 design spec (draft v4) 2026-10-18 23:47:54 -07:00
kyle 9281f9b5ae test(tines): give the unknown-belief ipc test its own store dir 2026-10-18 23:44:58 -07:00
kyle 22d003efb4 style(ros2): cargo fmt 2026-10-18 21:17:14 -07:00
kyle 69715a1505 fix(ros2): rclrs 0.8 API + bytes payload mapping
Rewrite tines-ros2/src/node.rs against the rclrs 0.8 API (Context::
default_from_env -> create_basic_executor -> create_node; type-inferred
subscriptions; thiserror-based RclrsError) and switch payloads from
std_msgs String to UInt8MultiArray:

* live topics publish the raw Observation.bytes as data (no UTF-8 lossy);
* inbound callbacks use msg.data verbatim;
* receipts are a 32-byte UInt8MultiArray (peer[..16] ++ id[..16]);
* supply the required MultiArrayLayout { dim: [], data_offset: 0 }.

Bump ros_env 0.1 -> 0.3 so the crate's std_msgs pins rclrs 0.8's rosidl
runtime 0.7 (was 0.6), and update Cargo.lock. Add #[allow(dead_code)] on
ManagedTopic::subscriber (drop-guard for the rcl subscription handle).

Keep the ROS2-free build green; no changes outside tines-ros2/ (and the
Cargo.lock entry).
2026-10-18 21:03:32 -07:00
kyle 049d4095b8 fix(store): crash-safe reopen, bounded record decode, durability docs 2026-10-18 19:16:47 -07:00
kyle 12f72aa6a2 ci: Dockerfile to verify tines-ros2 against ROS 2 Jazzy 2026-10-18 17:59:14 -07:00
kyle 4f61bbde00 fix(tines): harden IPC against malformed frames and lock poison
serve() now replies with Response::Error on a malformed JSON frame and
keeps the connection serving instead of dropping it on the parse error;
the per-connection loop only breaks on a clean disconnect
(UnexpectedEof). node.lock().unwrap() is replaced with poison-safe
into_inner() so one panicking handler can't take down the daemon.
Drop duplicate tines-core/tines-store/serde/serde_json from
dev-dependencies (only heapless is genuinely test-only).
2026-10-18 17:15:14 -07:00
kyle 20436badd0 feat(service): standalone tines service with Unix-socket IPC
New `tines` crate (added to workspace members) hosting a `Node<LogStore,
BtTransport>` and serving a tiny request/response IPC over a Unix-domain
socket for robots without ROS2. Four operations: `observe`, `belief`,
`events`, and `status`, over length-prefixed JSON frames.

The `serve` loop now serves each connection request-by-request (previously
it handled one request per connection, dropping the socket after the first
response). Integration tests drive `handle`/`serve` with a mock transport
that auto-acks observed broadcasts and echoes an empty Summary, so a
confidence event fires without a real BLE radio.
2026-10-18 16:41:02 -07:00
kyle 0926af9b28 fix(ros2): resolve borrow conflict in publish_one 2026-10-18 14:57:02 -07:00
kyle 7be09f8e9a Task 9: tines-ros2 — pure topic_name escaping (default, tested) + optional rclrs TinesNode (feature ros2)
Adds the ninth fleet-deployment crate. Default build is ROS2-free: topic_name
hex-escapes arbitrary tines topics into valid ROS2 names under /tines/ (deterministic,
injective) and wires Node<LogStore, BtTransport>. The rclrs-backed self-contained
TinesNode lives under #[cfg(feature="ros2")] with an off-by-default ros2 feature, so
the crate builds/tests without a ROS2 toolchain. Adds scripts/check-ros2.sh (needs a
ROS2 toolchain; not run in CI), registers the crate in workspace members, and passes
sh scripts/ci.sh.
2026-10-18 14:46:57 -07:00
kyle d089d9edaa feat(bt): BLE transport over BlueZ with identity-preserving Addr
Task 8 of the fleet-deployment plan. Adds the tines-bt crate: a real
`Transport` over the `bluer` crate (D-Bus BlueZ).

- `Addr` = peer's advertised `NodeId`, so identity survives BLE
  address rotation; advertising payload (flags + 16-bit service UUID +
  NodeId in service data) fits legacy 31-byte EIR (`advertise()`).
- `BtTransport` drops any inbound frame whose `from` differs from the
  connection's advertised NodeId (protocol violation at the transport;
  core never sees a mismatch).
- Connection symmetry: the node with the numerically smaller NodeId is
  the BLE central/initiator (`is_central`), independent of which side
  opens the radio.
- `mtu()` reports the real L2CAP CoC MTU (falling back to the ATT MTU);
  the transport does NOT split frames — core folds summaries/fragments
  to `mtu()`.
- Radio I/O sits behind the narrow `Radio` trait (a `poll`-driven event
  stream), so the pure logic (payload assembly, mismatch-drop, central
  rule) is unit-tested with a mock radio and never needs hardware.
- `BluerRadio` drives the stack on a detached tokio task: powers the
  adapter, advertises, monitors for the service UUID, opens an L2CAP
  byte pipe, and surfaces inbound bytes tagged with the peer NodeId.

Adds `tests/adv.rs` (8 mock-Radio integration tests covering the 31-byte
limit, NodeId round-trip, MTU clamp, mismatch-drop, per-frame MTU, and
central rule). Added to workspace members; workspace CI (fmt, doc,
test, clippy -D warnings) is green.
2026-10-18 14:06:48 -07:00
kyle ef53204fca fix(store): rebase ages per-entry so non-idle flush doesn't under-count
LogStore::new folded `(now - last_clock)` into every entry's age_ms, but
age_ms is persisted at INSERT time and stored_at was never caught up at
flush. So an observation inserted before the last flush lost the
`last_flush - insert_time` after restart (a store that was non-idle
between insert and flush reported an age too small by that gap).

Fix by anchoring each entry's age to its own insert tick: carry
`stored_at` on the Obs record and fold `(now - stored_at)` per-entry at
load, instead of a single global fold against the last clock marker.
flush() now also advances each in-memory age to its current value so the
representation stays coherent within a run.

This is exact for idle stores and observations inserted before the last
flush. Adds tests/persistence.rs::ages_rebase_after_nonidle_flush
(insert A at tick 1000, flush at 3000, reopen at 9000 -> asserts true
age 8100, not 6100).
2026-10-18 13:14:33 -07:00
kyle 43b73f88cd feat(store): add tines-store persistent append-only LogStore
Add the host-side std `tines-store` crate implementing the `tines_core::Store`
trait over a durable, append-only single-file log so a robot's memory survives
reboot.

- Log format: length-prefixed `[u32 LE][postcard]` records (Obs/Trim/Meta).
- On load the index is rebuilt by replaying the log, then every age is
  rebased to load time: elapsed time since the last persisted clock marker is
  folded into `age_ms` and `stored_at` reset to load `now`, so ages continue
  instead of freezing across a reboot.
- Persisted state: released-id set, `next_seq`, and a clock marker in a `Meta`
  record; dedupe to the oldest Obs and let the last event per id win so a
  re-inserted id survives a trim.
- Implements `next_seq` and `flush`; `trim` writes Trim records best-effort.
- Registered as a workspace member; std-only, `#![forbid(unsafe_code)]`.
- Adds persistence tests (append durability, rebase-on-load, released/seq
  persistence). Full gate (fmt, clippy, docs, tests, no_std thumb build) is green.
2026-10-18 12:43:42 -07:00
kyle f9613b1c32 test(sim): custody chain and receipt properties 2026-10-18 12:14:51 -07:00
kyle 32fd86e31b docs: plan — Node::drain_events returns heapless::Vec 2026-10-18 12:00:31 -07:00
kyle d099f09b63 feat(core): Node::drain_events for confidence events 2026-10-18 11:56:38 -07:00
Tines Subagent 29c30a6b33 task-4: revert on_ack release to custody chain; fix drain_ack_buffer overflow
Revert on_ack release gating to release-on-any-ack (custody chain): release
custody on the first exact Ack from ANY peer the node dispatched the
observation to (relay or recipient), not just the recipient.

drain_ack_buffer send_n==0 bug: re-keep only the target addr's own pulled
entries instead of removing buffer.entries[0] (which dropped an unrelated
peer's oldest pending ack).

Rename the tines-sim addressed proptest to
addressed_always_held_by_carrier_or_recipient and reconcile its assertion to
the custody-chain holder invariant. Reword the misleading "Ids shrink
monotonically" comment. Add unit tests: ack_releases_custody_from_a_relay and
drain_ack_buffer_overflow_drops_only_target_peer.

Gate green: tines-core 106 lib tests, tines-sim suite, sh scripts/ci.sh.
2026-10-18 11:48:40 -07:00
kyle fafda104ea feat(core): ack send path with custody/broadcast buffers
Buffer pending acks (acks for addressed, bcast_acks for broadcast,
ACK_BUFFER_CAP=256, overflow drops oldest), skip a released-duplicate
offer in accept(), and emit Ack frames in next_frame after a due summary
and before addressed/broadcast traffic, draining up to ACK_IDS_CAP ids
per destination and splitting across frames to fit mtu.

Release custody on an Ack only when the Ack confirms delivery to the
intended recipient: an Ack from a peer that merely holds an
epidemic-forwarded copy no longer releases custody, so the local copy
stays available to forward toward the recipient once the only contact to
it closes.
2026-10-18 11:21:49 -07:00
kyle 26a47c0d30 docs: plan — Exchange::drain_events is pub(crate) 2026-10-18 09:25:28 -07:00
kyle 6643b107ab feat(core): ack validation, custody release, confidence events 2026-10-18 09:13:35 -07:00
kyle 2a23cc390d feat(core): Ack wire frame (last Frame variant) 2026-10-18 07:39:07 -07:00
kyle 8703e723d5 docs: plan — 0.3.0 bump is the workspace version 2026-10-18 07:26:49 -07:00
kyle 0bb4d568ea feat(core): Store::release and is_released (0.3.0) 2026-10-18 07:22:45 -07:00
kyle 7d8ccbcf7d docs: fleet deployment v1 implementation plan 2026-10-18 07:15:45 -07:00
kyle e7fe26fc3c docs: fleet deployment v1 design spec (approved) 2026-10-18 07:12:20 -07:00
kyleandClaude Opus 5.5 eefc67e275 chore: ship LICENSE in each crate
Symlink the root Apache-2.0 LICENSE into tines-core and tines-sim so
`cargo package` includes the license text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:29:59 -07:00
kyle 3961a21a26 Licenses for crates.
CI / ci (push) Successful in 1m2s
2026-10-18 05:28:23 -07:00
kyleandClaude Opus 5.5 8b233c787f chore: release 0.2.1 with crates.io metadata
Share version, edition, license, authors, repository and readme through
[workspace.package]; add per-crate documentation, keywords and
categories. Fixes `cargo publish` warning about missing documentation,
homepage or repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:26:39 -07:00
kyleandClaude Opus 5.5 5c8bfe89ac chore: release 0.2.0; document the store contract and on_send_error
CI / ci (push) Canceled after 0s
Bump tines-core and tines-sim to 0.2.0 (Peer::in_flight changed type).
Add CHANGELOG.md. README gains a "Writing a store" section and a note on
calling Exchange::on_send_error when driving Exchange without Node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:24:30 -07:00
kyleandClaude Opus 5.5 203550bfc4 docs: expand README with diagrams; bring AGENTS.md up to date
CI / ci (push) Canceled after 0s
README: protocol, fragmentation, poll and addressed-delivery diagrams;
observation fields and identity; transport, belief and trim guidance;
simulator example; constants table.

AGENTS.md: drop the completed plan's task-by-task workflow and Task 14
notes, point at both specs, use scripts/ci.sh as the gate, and update
the identity-hash constraint to include `to`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:14:56 -07:00
kyleandClaude Opus 5.5 9a055b5b57 refactor(core): scan only addressed ids for custody; share frag plan
- Add Store::for_each_addressed_id (default: every id; MemStore filters)
  so custody selection no longer clones every broadcast observation on
  each poll.
- Factor fragment sizing into frag::plan and MAX_FRAGMENTS, used by both
  frag::fragment and the exchange, and by the reassembler's bounds.
- Document `to` in the Observation::id hash input, matching the
  addressed-delivery plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:09:07 -07:00
kyleandClaude Opus 5.5 cc39318673 fix(core): harden exchange send path from full-codebase review
- Cut every fragment of a stream from one encoding (age frozen at the
  first fragment) and bounds-check the slice: re-encoding mid-stream
  corrupted fragments and could panic when the tick went backwards.
- Fold the bloom summary to fit the MTU instead of sending a ~540-byte
  frame that small-MTU links reject; drop the sim's summary MTU
  exemption that hid this.
- Finish a peer's in-flight stream before starting another, and count
  an addressed message as delivered only after its last fragment.
- Alternate custody and broadcast per peer, rotate through addressed
  candidates, and evict the oldest bounce record when full, so neither
  path starves.
- Add Exchange::on_send_error; Node::poll uses it so Busy/Unreachable
  sends are retried rather than silently dropped.
- Clear bounce records per contact, record duplicates against their
  sender, and skip addressed messages that cannot fit the MTU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:08:08 -07:00
kyleandClaude Opus 5.5 111a40236d ci: test the no-alloc build and harden the workflow
Run clippy, docs and tests for tines-core with --no-default-features,
gating the MemStore-based tests on `alloc` so they compile there. Fail on
rustdoc warnings, pass --locked everywhere, and pin the toolchain to
1.99.0. In the workflow, use read-only permissions, cancel superseded
runs, add a 20-minute timeout, and pin actions to commit SHAs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 05:07:12 -07:00
kyle 6907f000a2 ci: add GitHub Actions workflow
CI / ci (push) Successful in 2m10s
2026-10-18 04:30:00 -07:00
kyle d10e3cd88e test(core): close deferred coverage gaps 2026-10-18 04:28:38 -07:00
kyle 277daae89f fix(core): rebuild_send_queue excludes addressed messages 2026-10-18 03:57:08 -07:00
kyle 1d646344e6 style: cargo fmt --all 2026-10-18 03:28:51 -07:00
kyle c9ee3684f0 test(sim): addressed relay scenario and property tests 2026-10-18 03:22:35 -07:00
kyle db39dc1df0 feat(core): Node::observe_to and belief excludes addressed-to-others 2026-10-18 02:56:17 -07:00
kyle 8ad0a7415f feat(core): addressed store-and-forward in the exchange 2026-10-18 02:39:36 -07:00
kyle c59834737b feat(core): reject expired or malformed addressed messages 2026-10-18 02:03:52 -07:00
kyle 2c932e96c0 feat(core): summaries carry only broadcast observations 2026-10-18 01:55:29 -07:00
kyle 65c4aa72c0 feat(core): Store::for_each_broadcast_id 2026-10-18 01:49:01 -07:00
kyle 085b4d35da feat(core): Observation gains to/lifetime_ms; identity includes to 2026-10-18 01:41:24 -07:00