Commit graph

53 commits

Author SHA1 Message Date
Snider
85de30a528 feat(compat): implement spec-described aliases across all packages
Add compatibility aliases documented in specs but missing from code:

- node: NewNodeManagerWithPaths, NewPeerRegistryWithPath (deprecated
  constructor aliases), RegisterWithTransport (deprecated method alias),
  ConnectedPeers (count alias), GetLogsPayload (type alias)
- levin: Short-form Value constructors (Uint64Val, StringVal, ObjectVal,
  etc.) matching spec naming
- logging: WithComponent, GetLevel, GetGlobal (deprecated method aliases)
- ueps: TagCurrentLay, TagTargetLay (short-form tag constant aliases)

All aliases delegate to the canonical AX-compliant names. Tests cover
every alias with round-trip verification where applicable.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 12:25:22 +01:00
Snider
5ed4451555 feat(ax): AX compliance sweep — comments as usage examples, remove linter-injected aliases
All checks were successful
Security Scan / security (push) Successful in 8s
Test / test (push) Successful in 1m31s
Applied AX principles 1, 2, and 9 across the node, dispatcher, transport, peer,
worker, bundle, and logging packages:

- Added usage-example comments to all public methods missing them (AX-2):
  dispatcher.RegisterHandler, Handlers; peer.AddPeer, UpdatePeer, RemovePeer,
  AllowPublicKey, RevokePublicKey, IsPublicKeyAllowed, IsPeerAllowed, RecordSuccess,
  RecordFailure, RecordTimeout, SelectOptimalPeer, SelectNearestPeers, Count,
  PeersByScore, AllowedPublicKeys, ListAllowedPublicKeys; transport.Start, Stop, Send,
  Connections, Broadcast, PeerConnection.Send, Close, GracefulClose
- Removed redundant inline comments that restate code (bundle.go, transport.go, worker.go)
- Added _Bad and _Ugly test categories to logging/logger_test.go to satisfy the
  TestFilename_Function_{Good,Bad,Ugly} naming convention (AX-10)
- Removed all linter-injected short-form alias files (*_compat.go, *_alias_test.go)
  that violated AX-1 (Err* aliases, Uint64Val, WithComponent, GetLevel, GetGlobal, etc.)

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 12:20:52 +01:00
Virgil
1badcf1877 fix(transport): expose accepted peers before handshake ack
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 05:44:02 +00:00
Virgil
1c8592a5a0 refactor(node): align peer and handler names with AX
All checks were successful
Security Scan / security (push) Successful in 14s
Test / test (push) Successful in 1m27s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 05:32:08 +00:00
Virgil
aa001ce214 refactor(node): rename websocket handler and clarify UEPS comments
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 05:18:20 +00:00
Virgil
390e60860e refactor(node): remove legacy AX aliases
All checks were successful
Security Scan / security (push) Successful in 12s
Test / test (push) Successful in 1m34s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 05:08:09 +00:00
Virgil
79591c3635 refactor(node): trim legacy AX compatibility fields
Some checks failed
Test / test (push) Failing after 13m33s
Security Scan / security (push) Failing after 13m35s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 23:00:36 +00:00
Virgil
bd9efd1deb refactor(node): clarify AX-facing transport and worker names
All checks were successful
Security Scan / security (push) Successful in 11s
Test / test (push) Successful in 1m53s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 22:54:45 +00:00
Virgil
885070d241 refactor(node): adopt AX naming across core APIs
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m41s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 22:46:11 +00:00
Virgil
851b1294bd refactor(node): rename controller and worker core fields
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m42s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 22:38:29 +00:00
Virgil
819862a1a4 refactor(node): tighten AX naming across core paths
All checks were successful
Security Scan / security (push) Successful in 11s
Test / test (push) Successful in 1m38s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 22:31:11 +00:00
Virgil
dec79b54d6 refactor(node): clarify filesystem and buffer pool names
All checks were successful
Security Scan / security (push) Successful in 10s
Test / test (push) Successful in 1m40s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 21:50:35 +00:00
Virgil
f5d1ee6021 refactor(node): align worker interfaces with AX naming
Some checks failed
Security Scan / security (push) Successful in 9s
Test / test (push) Failing after 59s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 21:34:57 +00:00
Virgil
c03b3410e6 refactor(node): remove legacy compatibility aliases
All checks were successful
Security Scan / security (push) Successful in 10s
Test / test (push) Successful in 1m29s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 21:27:45 +00:00
Virgil
7ce21cdba1 refactor(node): adopt AX-native protocol names
All checks were successful
Security Scan / security (push) Successful in 10s
Test / test (push) Successful in 1m30s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 21:21:07 +00:00
Snider
8e640e2d42 feat(node): advertise agent identity in transport
Some checks failed
Security Scan / security (push) Successful in 8s
Test / test (push) Failing after 36s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 22:03:34 +01:00
Virgil
ca885ff386 refactor(node): clarify AX filesystem and message names
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m31s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 20:52:19 +00:00
Virgil
48cd87e081 refactor(node): clarify remaining AX fixture names
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m34s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 20:45:55 +00:00
Virgil
cbb3f01176 refactor(node): rename test helpers for AX clarity
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m28s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 20:40:59 +00:00
Virgil
0ca20d53ea test(node): migrate tests to AX-native constructors
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m28s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 20:35:50 +00:00
Virgil
15c961a5f4 fix(controller): remove response-channel close race
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m27s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 20:31:23 +00:00
Snider
6a70c6f234 fix(node): surface corrupted persisted state during load
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m27s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 21:17:43 +01:00
Virgil
4c8bced1e7 refactor(node): add AX-native accessors and usage docs
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 1m28s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 20:03:06 +00:00
Virgil
c678d20608 refactor(repo): prefer AX error names
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 19:44:05 +00:00
Virgil
2d63a8ba18 refactor(node): add AX-native aliases for component and path APIs
Some checks failed
Security Scan / security (push) Successful in 9s
Test / test (push) Failing after 52s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 19:32:26 +00:00
Virgil
d7681bf637 refactor(repo): complete AX v0.8.0 polish pass
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 16:26:18 +00:00
Virgil
04ae11da43 refactor(node): replace stdlib helpers with core primitives
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 14:37:02 +00:00
Virgil
be55b2499b chore(node): upgrade to core v0.8.0-alpha.1
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 14:31:25 +00:00
727b5fdb8d Merge pull request '[agent/claude] Migrate module path to dappco.re/go/core/p2p. Update go.mod ...' (#5) from agent/migrate-module-path-to-dappco-re-go-core into main
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 57s
2026-03-22 02:07:18 +00:00
Snider
6fd3fe1cd2 refactor(node): migrate module path to dappco.re/go/core/p2p
All checks were successful
Security Scan / security (pull_request) Successful in 8s
Test / test (pull_request) Successful in 2m2s
Update go.mod module line from forge.lthn.ai/core/go-p2p to
dappco.re/go/core/p2p. Migrate core dependency paths: go-log to
dappco.re/go/core/log v0.1.0, go-io to dappco.re/go/core/io v0.2.0.
Update all .go import paths across 18 source files. Borg, Poindexter,
and Enchantrix dependencies remain on forge.lthn.ai as they have not
been migrated upstream.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 02:06:51 +00:00
3f1f9a7d60 Merge pull request '[agent/claude:opus] Fix CodeRabbit findings. Verify each against current code, f...' (#4) from agent/fix-coderabbit-findings--verify-each-aga into main
All checks were successful
Security Scan / security (push) Successful in 10s
Test / test (push) Successful in 1m11s
2026-03-17 16:24:04 +00:00
Snider
b334cb4909 fix(bundle): document why os.OpenFile is used instead of coreio in extractTarball
All checks were successful
Security Scan / security (pull_request) Successful in 9s
Test / test (pull_request) Successful in 1m25s
The coreio abstraction hardcodes file permissions (0644) and has no
OpenFile equivalent. os.OpenFile is needed here to preserve tar header
mode bits — executable binaries require 0755.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 16:23:35 +00:00
Snider
3ea407c115 fix(node): DX audit — document conventions, wrap raw errors
All checks were successful
Security Scan / security (pull_request) Successful in 8s
Test / test (pull_request) Successful in 1m14s
Add coreerr.E() and coreio.Local conventions to CLAUDE.md coding
standards. Wrap two raw os.OpenFile/io.Copy errors in extractTarball
with coreerr.E for consistent error context.

Coverage: logging 86%, node 86%, levin 87%, ueps 92%.
No fmt.Errorf or os.ReadFile/os.WriteFile in production code.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 08:39:36 +00:00
Snider
66bc0b862f refactor: replace fmt.Errorf/os.* with go-log/go-io conventions
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 2m7s
Replace all fmt.Errorf and errors.New in production code with
coreerr.E("caller.Method", "message", err) from go-log. Replace
os.ReadFile/os.WriteFile/os.MkdirAll/os.Remove with coreio.Local
equivalents from go-io. Test files left untouched.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 20:38:55 +00:00
Snider
fe04cf93aa fix: improve UEPS packet validation and worker error handling
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:30:59 +00:00
Claude
030834905e
chore: use slices.Sorted(maps.Keys()) for ordered iteration
All checks were successful
Security Scan / security (pull_request) Successful in 14s
Test / test (pull_request) Successful in 2m5s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:14:50 +00:00
Claude
564b1860f9
chore: use min()/max() builtins (Go 1.21+)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:13:44 +00:00
Claude
2ac2974ec2
chore: extract repeated sentinel errors to package vars
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:13:09 +00:00
Claude
bee4e23a75
chore: fmt.Errorf(static) → errors.New
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:11:41 +00:00
Snider
50a6e12cf4 feat: modernise to Go 1.26 iterators and stdlib helpers
All checks were successful
Security Scan / security (push) Successful in 14s
Test / test (push) Successful in 2m51s
Add Peers, AllowedPublicKeys, ConnectedPeers, PeersByScore iterators
on PeerManager. Add Handlers on Dispatcher, Connections on Transport.
Use slices.Collect, maps.Keys/Values, slices.SortFunc internally.

Co-Authored-By: Gemini <noreply@google.com>
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 06:07:49 +00:00
Claude
df56e7569e
chore: migrate Snider deps from github.com to forge.lthn.ai
Update Borg, Poindexter, and Enchantrix dependency paths from
github.com/Snider/ to forge.lthn.ai/Snider/ across go.mod and imports.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:42:39 +00:00
Snider
ca04a88e35 refactor: apply go fix modernizers for Go 1.26
Automated fixes: interface{} → any, range-over-int, t.Context(),
wg.Go(), strings.SplitSeq, strings.Builder, slices.Contains,
maps helpers, min/max builtins.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 21:00:16 +00:00
Claude
f80166251b
feat(levin): connection with framed TCP packet I/O
Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 19:29:41 +00:00
Claude
101ef37985
feat(levin): portable storage section encode/decode
Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 19:27:31 +00:00
Claude
abc88f5c7a
feat(levin): portable storage varint encode/decode
Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 19:23:28 +00:00
Claude
7089e0990c
feat(levin): header encode/decode (33-byte Levin packet framing)
Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 19:23:24 +00:00
Claude
bf4ea4b215
test: add Phase 5 integration tests, benchmarks, and bufpool tests
- Full integration test: two nodes on localhost exercising identity
  creation, handshake, encrypted message exchange, UEPS packet routing
  via dispatcher, and graceful shutdown
- Benchmarks: identity key generation, ECDH shared secret derivation,
  KD-tree peer scoring (10/100/1000 peers), message serialisation,
  SMSG encrypt/decrypt, challenge-response, UEPS marshal/unmarshal
- bufpool.go tests: buffer reuse verification, oversized buffer
  discard, concurrent access, MarshalJSON correctness and safety
- Coverage: node/ 72.1% -> 87.5%, ueps/ 88.5% -> 93.1%

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 11:53:26 +00:00
Snider
c437fb3246 test: Phase 5 — integration tests, benchmarks, bufpool tests
- Integration: two-node localhost handshake + encrypted message exchange
  + controller ping/pong + UEPS packet routing via dispatcher + threat
  circuit breaker + graceful shutdown (3 test functions)
- Benchmarks: 13 benchmarks across node/ and ueps/ — identity keygen,
  ECDH shared secret, message serialise, SMSG encrypt/decrypt, HMAC
  challenge sign/verify, KD-tree peer scoring, UEPS marshal/unmarshal,
  bufpool throughput, challenge generation
- bufpool: 9 tests — get/put round-trip, buffer reuse, large buffer
  eviction, concurrent access (race-safe), buffer independence,
  MarshalJSON correctness + concurrency

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 06:09:21 +00:00
Claude
ac70d879a1
test(node): push coverage from 72.4% to 87.4%
Add comprehensive tests for previously uncovered controller, worker,
peer, bundle, transport, identity and message functions:

- Controller: StartRemoteMiner, StopRemoteMiner, GetRemoteLogs (0% -> 80%+),
  ConnectToPeer success path, handleResponse edge cases, PingPeer no-identity
- Worker: handleStartMiner with config/profile/errors (9% -> 91%),
  handleStopMiner success/failure (20% -> 90%), handleGetLogs with
  limits/not-found (14% -> 93%), handleDeploy miner/full bundles (24% -> 89%),
  HandleMessage unknown type and integration via WebSocket, handleGetStats
  with miner manager and no-identity
- Peer: safeKeyPrefix all branches (40% -> 100%), validatePeerName direct,
  scheduleSave timer firing (35% -> 94%), saveNow/Close dirty data,
  edge cases for Record*/Update*/Select* with non-existent peers
- Bundle: extractTarball path traversal/symlink/directory/empty,
  ExtractMinerBundle checksum mismatch, CreateMinerBundle errors,
  ReadBundle invalid JSON, StreamBundle empty bundle
- Transport: Broadcast with sender exclusion (0% -> 83%), Start/Stop
  lifecycle (0% -> 83%), CheckOrigin validation, ConnectedPeers
- Identity: DeriveSharedSecret/GetIdentity without identity, Delete no files
- Message: nil payload, ParsePayload nil, NewErrorMessage

Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 02:33:54 +00:00
Claude
a60dfdf93b
feat: implement UEPS packet dispatcher with threat circuit breaker
Implements Phase 4 of the go-p2p task queue. The Dispatcher routes
HMAC-verified UEPS packets to registered IntentHandlers by IntentID,
enforcing a threat circuit breaker that drops packets with ThreatScore
exceeding 50,000 (logged as threat events at WARN level).

Design choices:
- IntentHandler is a func type (not interface) for lightweight registration
- 1:1 mapping of IntentID to handler, replacement on re-register
- Threat check fires before intent routing (hostile packets never reach handlers)
- Sentinel errors (ErrThreatScoreExceeded, ErrUnknownIntent, ErrNilPacket)
- RWMutex protects handler map for concurrent safety

Tests: 10 test functions, 17 subtests — 100% dispatcher coverage.
Race detector clean. All 102 existing tests continue to pass.

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 00:23:10 +00:00