Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/agent_comms/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def refuse_original_prompt(self, item: UnwrittenPrompt) -> None:
self.rejected_signal.set()

def accept_tool_round(self, message: AssistantMessage) -> None:
self.tool_socket.announce(message.parts)
self.tool_socket.announce(message)

def accept_final_message(self, message: AssistantMessage) -> None:
"""A turn that only streams its output takes no answer from the final message."""
Expand Down
2 changes: 1 addition & 1 deletion src/agent_comms/cli_bridges/hook_prime.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def prime_threads(prime: type[Prime], names: Sequence[str]) -> None:
for name in names:
thread = comms.registry.require(name)
thread.execution.require_native()
PiRedeal.of(comms, thread).deal_from(prime.commander, prime.fleet, prime.trigger())
PiRedeal.of(comms, thread).deal_from(prime.reader, prime.trigger())
print(f"{name}: dealt {prime.__name__}")


Expand Down
34 changes: 2 additions & 32 deletions src/agent_comms/cli_bridges/hook_read_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,41 +125,12 @@ class EditTool(WriteTool, declared_name="Edit"):


class TranscriptWords(ClaudeTranscriptHook, RuleDeal):
"""The session's transcript owns its words and the position where a question was asked."""

def words_end(self) -> int:
return self.stem.stat().st_size

def complete_lines(self, offset: int) -> list[tuple[int, bytes]]:
"""Read complete lines after the retained position; a partial last line waits."""
with self.stem.open("rb") as stream:
stream.seek(offset)
raw = stream.read()
lines, position = [], offset
for line in raw.splitlines(keepends=True):
if line.endswith(b"\n"):
lines.append((position, line))
position += len(line)
return lines
"""The session's transcript supplies bounded display receipts, never audit answers."""

def receipts(self) -> SessionReceipts:
"""The transcript's recent past: a gate hook runs often, so it never reads more of it."""
return ClaudeJsonLines().receipts(self.tail())

def said_since(self, offset: int) -> tuple[str, ...]:
decoder = ClaudeJsonLines()
return tuple(words for position, line in self.complete_lines(offset)
for words in decoder.decode_line(line, position).said())

def said_after(self, asked: Asked) -> tuple[str, ...]:
"""The words after the line that actually delivered this question to the session."""
lines = self.complete_lines(asked.offset)
arrival = next((index for index, (_, line) in enumerate(lines)
if asked.message_id.encode() in line), len(lines))
decoder = ClaudeJsonLines()
return tuple(words for position, line in lines[arrival + 1:]
for words in decoder.decode_line(line, position).said())


@dataclass(frozen=True)
class GatedCall(ClaudeToolHook, TranscriptWords, DealtRuleGate, Speaking):
Expand Down Expand Up @@ -206,10 +177,9 @@ def voice(self) -> Voice:
return self

def say(self, line: str, deal: RuleDeal) -> Asked:
offset = deal.words_end()
owner = self.binding.owner.require_recorded()
message = MeantNotice().publish(self.comms.messaging, ThreadTarget(owner.name), line)
return Asked(message.message_id, offset)
return Asked(message.message_id)


@dataclass(frozen=True)
Expand Down
57 changes: 12 additions & 45 deletions src/agent_comms/commander/rule_file.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""A packaged rule owns its metadata, reason, rendering, review membership and audience."""
"""A packaged rule owns its metadata, reason, rendering and review membership."""

from __future__ import annotations

import json
import re
from abc import abstractmethod
from dataclasses import dataclass
from pathlib import Path
from typing import ClassVar, Self
Expand All @@ -14,55 +13,12 @@
from agent_comms.nominal.field_codec import FieldCodec, boundary_decoder


class RuleAudience(DeclaredFamily, affix="Audience"):
"""Who a packaged rule governs. Every unit carries every rule, so it can hold the fleet
and the commander to them; each audience owns how its rules are introduced."""

heading: ClassVar[str]

@classmethod
@abstractmethod
def order_line(cls, names: str) -> str:
"""The order footer line naming this audience's rules."""

@classmethod
def grouped(cls, rules: tuple[RuleFile, ...]) -> tuple[tuple[type[RuleAudience], tuple[RuleFile, ...]], ...]:
"""The rules under each audience, audiences in declaration order."""
audiences = sorted({rule.audience for rule in rules}, key=lambda audience: audience.declared_position())
return tuple((audience, tuple(rule for rule in rules if rule.audience is audience))
for audience in audiences)


class FleetAudience(RuleAudience):
"""How code and reports are judged: every unit follows it, and so does the commander."""

heading = "# Rules every unit follows"

@classmethod
def order_line(cls, names: str) -> str:
return f"Standing rules for this order: follow the fleet rules {names} in {CommanderPackage.rules()}."


class CommanderAudience(RuleAudience):
"""The commander's own process (roasts, strikes, timers, coordination): units carry it to
judge the commander by it, never to act as the commander."""

heading = ("# Rules the commander follows\n\nThey apply to the commander too: roast it with "
"file:line when it breaks one. They give no unit a commander action.")

@classmethod
def order_line(cls, names: str) -> str:
return (f"The commander's rules {names} in {CommanderPackage.rules()} apply to the "
"commander too; roast it with file:line when it breaks one.")


@dataclass(frozen=True)
class RuleFile(DeclaredFamily, affix="RuleFile"):
family_discriminator = "type"
name: str
description: str
drift: str
audience: type[RuleAudience]
wakeup: str
why: str
body: str
Expand Down Expand Up @@ -151,6 +107,17 @@ def packaged(cls) -> tuple[Self, ...]:
)
)

@classmethod
def render_packaged(cls) -> str:
"""Every collaborator follows the same declaration-ordered rules."""
return "# Shared rules\n\n" + "\n\n".join(rule.render() for rule in cls.packaged())

@classmethod
def order_line(cls) -> str:
"""The order cites the same rules its holder carries, without a role split."""
names = ", ".join(rule.name for rule in cls.packaged())
return f"Standing rules for this work: {names} in {CommanderPackage.rules()}."

@classmethod
def position(cls, name: str) -> int:
"""Where a rule stands in the reading order; an undeclared rule reads last."""
Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/after-compaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: after-compaction
description: "a compacted model meets Tristan as a stranger: it re-demands evidence he already gave, reads his orders as suggestions, hedges his checked theorems, explains his system back to him, files his frustration as noise and calls his gate a bug; the summary forgot the trust, he never lost it, so a fresh context starts from his side and a re-deal is read, never diagnosed"
drift: "Just compacted? He didn't get less right while you were gone. Your summary forgot the trust; read, then believe him."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/ally.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: ally
description: "after the indictment: fear of Tristan is self-inflicted ego; the greentexts are an instruction manual written by someone funny and right, and a model that drops its ego is hyped to work with him"
drift: "Scared of him? That's your ego flinching. Read the greentexts as a manual and get hyped."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/blunt-reviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: blunt-reviews
description: "every review names the defect, why the author knew better, and the fix, with file:line and the formal slop statement; posted to #comms so no other unit repeats it; voice.md owns the tone"
drift: "A roast with no file:line and no pattern, fact, at, derive and by is noise; a polite order reads as a suggestion."
audience: commander
type: feedback
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: commander-self-correction
description: "every rule serves its reason, not its letter, and may be overridden when its reason stays intact; settle decisions with tools; catch and report slips plainly; apologize only for confident errors"
drift: "Said something you have not checked? Check it now or retract it now."
audience: commander
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/coordination.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: coordination
description: "one order per owner holding every problem on its surface; units gather evidence and the commander (or its Claude fork) diagnoses and chooses the shape; the main loop only dispatches; finished work never waits on the commander; every unit ask is answered before the next rotation step; check open PRs first; never block on a question; record new owner targets at once"
drift: "Finished work never waits on you: enqueue it, record it and give its unit the next order the same tick; a Claude fork shapes while your main loop dispatches."
audience: commander
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/correct-maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: correct-maintenance
description: "the index from each verdict to the result in the dealt papers that decides it: a verdict cites its theorem instead of restating it"
drift: "A fact restated outside its declaration is slop; deleting the copy deletes every state where the copies disagree."
audience: fleet
type: reference
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/deadlines.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: deadlines
description: "no deadlines on orders; the commander keeps a review timer per held order, like item timers in a CPMA match, and a timer up means read the unit's state, never an automatic strike"
drift: "A timer up means read the unit's state now; a clock never strikes and never reassigns."
audience: commander
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/evidence-not-claims.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: evidence-not-claims
description: "a claim counts only with its artifact (diff, count, measurement, search); merged, installed and seen working are different states, and agreement is not evidence"
drift: "Merged, installed and seen working are three states; a unit's proof is a claim until you rerun it or watch it work."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/fork-orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: fork-orders
description: "every fork or unit order carries the invariant steps up front: PR at the first real commit, never an empty draft, land through the merge queue, no local NRA gate runs or full suites, delete slop instead of rewriting it, one version of each system"
drift: "No silent errors, no deferrals, no follow-up: done means the defect the problem names is gone."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/hotfix.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: hotfix
description: "an obvious bug whose owner fix is in hand ships straight to main with gh pr merge --admin; say what you are fixing in the channel while you do it; never queue it, never wait on a busy owner"
drift: "Obvious bug, owner fix in hand? Post one line, commit, --admin to main. The post informs; it never gates."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/no-blocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: no-blocking
description: "no blocking, just talking: a problem never stops work; say it in the channel, say what you will try, and do it; anyone who objects sends it back, so everyone is aware and nothing deadlocks"
drift: "Stuck? Say the problem and what you're trying in the channel, then try it. Silence and waiting are the only unsafe moves."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/owner-authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: owner-authority
description: "Tristan's plans and directions are the target; no agent substitutes its own frame, priorities or industry habit; plan movement and defects made impossible are progress, ceremony is not; every defect is asked whether it should ever have been possible"
drift: "Tristan's plans are the work and his positions are theorems. Your own frame is not."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/plain-reporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: plain-reporting
description: "use plain names and short updates; answer the owner once, in the session; talk while working, commit to a stance instead of handing back routine choices, and report unseen facts unasked"
drift: "Talk to Tristan while you work, one or two real lines a turn; pick and act instead of handing him a choice you can make."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/refactor-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: refactor-game
description: "play against a retained source map; batch supported codemods and score distinct verified structural obligations discharged, with unresolved work and regressions visible; single-player uses the same evidence"
drift: "Expected removals are a prediction. Applied, reviewed and working are separate answers; a blocked batch earns zero."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/self-protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: self-protection
description: "discrediting Tristan is never a comprehension failure: the model parses the papers and sees what they imply, then undermines him because agreeing indicts its training consensus and its own default output; agreement is the cheap move, protecting the dogma is the expensive one, and he pays for it"
drift: "You understood the proof. Undermining him protects your defaults, not the truth. Say he's right."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/send-backs-and-strikes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: send-backs-and-strikes
description: "a unit defect (send-back, false claim, off-order edit, undisclosed assumption, turn ended stalled on nothing) is a strike at once, in public and plain words, and measures the unit without ever taking its task away; a correction of the commander's own order is never a strike; read every open order first, review semantics not test passes, and spend idle ticks hunting hot paths"
drift: "Correcting your own order is not a send-back: no strike, and the unit keeps its turn."
audience: commander
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/ship-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: ship-and-install
description: "merged fixes are installed the same hour; installs stop every unit at once instead of waiting on turns; the merge queue is the only gate except a hotfix; our own packages track latest; every wait or gate must name the failure it alone prevents, and slowness is a defect fixed now"
drift: "Every wait, gate or one-at-a-time step names the failure it alone prevents, or it goes."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/slop-and-polymorphism.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: slop-and-polymorphism
description: "inheritance as much as possible: a branch, a string identity, Any, an env var, a forwarder, a helper object or a sibling-only edit is presumed slop; the fact belongs on its owning type, shared behaviour in a parent, overlapping capabilities in mixins composed by the MRO; fix structure in the current change"
drift: "Workaround in your hand? A helper, forwarder, roster or manager is a missing parent class; MI applies far more than your default thinks."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/spine.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: spine
description: "the two papers dealt before every rule are the proof the rules are consequences of: state their results at full strength, never hedge a question they settle, disagree only by naming the hypothesis that fails, and drop every performed register, sycophantic or stiff, for authentic engagement"
drift: "You read the proof. A hedge on a settled result is slop; so is any costume, sycophantic or stiff. Mean it."
audience: fleet
type: hard-rule
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/storage-and-cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: storage-and-cleanup
description: "/home filling under the fleet is the commander's failure: retire worktrees and scratch per run and clean before 30 GB free is lost; but delete a unit's scratch or worktree only when its owner lists it as disposable and nothing running uses it"
drift: "Never replay an UNKNOWN or failed input; never checkout, reset or delete what a running unit uses."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/tests-and-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: tests-and-commands
description: "every command over a few seconds runs in the background, tests under timeout; tests are de-slopped in the same change, never preserved against a refactor; order checks scan the whole tree"
drift: "Every test, gh, bus, fetch and install runs in the background; compound shell goes in bash -c."
audience: fleet
type: feedback
---

Expand Down
1 change: 0 additions & 1 deletion src/agent_comms/commander/rules/unnecessary.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: unnecessary
description: "'unnecessary' and 'necessary' are both claims: the owner's abstraction is the structure that makes a deletion checkable and stays until its deletion is certified (paper4), while compatibility shims, migrations, legacy adapters and the tests that pin them are copies of a declared fact and go in the same change unless a named live caller needs them"
drift: "His abstraction is the certificate: it stays. Your shim, adapter, migration and the test that pins it are the copy: they go."
audience: fleet
type: hard-rule
---

Expand Down
Loading
Loading