Add Fleet Torrent erasure extension with shard DHT and gossip.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

Content-addressed shard DHT on seeder agents with subnet_primary_seeder election, cross-subnet fleet_torrent_gossip, BGP swarm magnets, C2 torrent manifest, and k-of-n peer fetch with C2 fallback.
This commit is contained in:
AetherForge
2026-06-07 09:24:55 -07:00
parent 588735e7e7
commit 894b7a50ae
40 changed files with 2285 additions and 1 deletions

View File

@@ -11,6 +11,8 @@ import (
"github.com/google/uuid"
"crypto-miner-server/internal/ai"
dbpkg "crypto-miner-server/internal/db"
"crypto-miner-server/internal/strategy"
)
// TimelineBranchStatus tracks ghost-branch exploration on a Path Tracer target hop.
@@ -205,9 +207,16 @@ func (h *PathTracerHandler) Fork(w http.ResponseWriter, r *http.Request) {
if parentID == "" {
parentID = sess.ID
}
hospice := map[string]bool{}
if h.hub != nil {
hospice = h.hub.HospiceStrainSet()
}
var spawned []*TimelineBranch
for _, persona := range normalized {
lanes := ai.PersonaSpreadTierOrder(persona)
if len(lanes) > 0 && strategy.LaneInHospice(lanes[0], hospice) {
continue
}
branch := &TimelineBranch{
ID: uuid.New().String(),
ParentID: parentID,
@@ -226,6 +235,11 @@ func (h *PathTracerHandler) Fork(w http.ResponseWriter, r *http.Request) {
sess.TimelineBranches = append(sess.TimelineBranches, branch)
spawned = append(spawned, branch)
}
if len(spawned) == 0 {
h.mu.Unlock()
http.Error(w, "all fork personas map to hospice strains — parent selection blocked", http.StatusConflict)
return
}
h.mu.Unlock()
h.persistSession(sess)
@@ -234,6 +248,25 @@ func (h *PathTracerHandler) Fork(w http.ResponseWriter, r *http.Request) {
go h.runGhostBranch(sess.ID, b)
}
h.broadcastTimelineEvent(sess, "fork", spawned[0])
if h.hub != nil && h.hub.db != nil {
why := map[string]interface{}{
"session_id": sess.ID,
"fork_hop_index": req.ForkHopIndex,
"target_agent_id": target.AgentID,
"personas": normalized,
"branches_spawned": len(spawned),
}
_ = (&OathLedgerBridge{DB: h.hub.db, Hub: h.hub}).Record(
AuthUsername(r), dbpkg.OathForkMerge, target.AgentID, agentStrainFromDB(h.hub.db, target.AgentID),
dbpkg.OathOutcomePending, why,
map[string]interface{}{
"event": "fork",
"session_id": sess.ID,
"fork_hop_index": req.ForkHopIndex,
"branches_spawned": len(spawned),
},
)
}
writeJSON(w, map[string]interface{}{
"ok": true,
@@ -279,6 +312,14 @@ func (h *PathTracerHandler) Merge(w http.ResponseWriter, r *http.Request) {
http.Error(w, "cannot merge canonical root", http.StatusBadRequest)
return
}
if h.hub != nil && len(winner.SpreadLanes) > 0 {
hospice := h.hub.HospiceStrainSet()
if strategy.LaneInHospice(winner.SpreadLanes[0], hospice) {
h.mu.Unlock()
http.Error(w, "branch spread strain is in hospice — fork-merge parent selection blocked", http.StatusConflict)
return
}
}
if winner.Status != BranchWon && winner.Status != BranchRunning {
h.mu.Unlock()
http.Error(w, "branch must be running or won to merge", http.StatusConflict)
@@ -308,6 +349,26 @@ func (h *PathTracerHandler) Merge(w http.ResponseWriter, r *http.Request) {
h.mu.Unlock()
h.persistSession(sess)
h.broadcastTimelineEvent(sess, "merge", winner)
if h.hub != nil && h.hub.db != nil {
why := map[string]interface{}{
"session_id": sess.ID,
"merged_branch_id": winner.ID,
"merged_persona": winner.Persona,
"merged_spread_lane": sess.MergedSpreadLane,
"merged_hashrate": sess.MergedHashrate,
}
_ = (&OathLedgerBridge{DB: h.hub.db, Hub: h.hub}).Record(
AuthUsername(r), dbpkg.OathForkMerge, winner.TargetAgentID, agentStrainFromDB(h.hub.db, winner.TargetAgentID),
dbpkg.OathOutcomeSuccess, why,
map[string]interface{}{
"event": "merge",
"session_id": sess.ID,
"merged_branch_id": winner.ID,
"merged_persona": winner.Persona,
"merged_spread_lane": sess.MergedSpreadLane,
},
)
}
writeJSON(w, map[string]interface{}{
"ok": true,