-
Notifications
You must be signed in to change notification settings - Fork 7
Move the conducted episode's rules into the driver #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # `conduct` | ||
|
|
||
| One completion-driven episode as a host steps it: the desk episode, a child | ||
| episode for every conversation an `ask` opens, and the rules between them | ||
| that no single fold can hold. | ||
|
|
||
| | file | holds | | ||
| | --- | --- | | ||
| | `mod.rs` | `Conductor`, `ConductPolicy`, `Door`, `starters`; opening the desk, beginning a wave, proposing turns, opening a turn with its brief, recording what it called | | ||
| | `wave.rs` | After a wave: the phase machine that hands the host one `Step` at a time -- commits in conversations, silent askees, commits on the desk with their consequences, conclusions, the turn wall | | ||
| | `child.rs` | A conversation: its root, its two seats, its own driver state, its turns, its nudge; and one that concluded | | ||
| | `steps.rs` | `Turn`, `Note`, `Commit`, `Event`, `Refusal`, `Step` | | ||
| | `test.rs` | Every rule, driven by a host that is only a journal | | ||
|
|
||
| The rules, each with the decision it comes from: | ||
|
|
||
| - **A conversation runs first** (ADR 0023): it is what unblocks a desk turn. | ||
| It concludes when the seat asked completes, at `child_turn_wall`, or when | ||
| nothing is due anywhere; its outcome reaches the asker as a private row, | ||
| which releases the asker's hold. The seats that had it are shown it whole | ||
| once, on their next desk turn. | ||
| - **Nudges** (ADR 0024): a desk seat that holds open work, ran for it and | ||
| has been shown everything is told once per assignment and owed a turn. A | ||
| seat asked that took its turn without answering is told once and owed a | ||
| turn; a second silence stands. | ||
| - **Sorting**: a broadcast or an ask made inside a conversation is desk | ||
| work; only a post or a completion is a row of the conversation. | ||
| - **Refusals**: a completion the ledger refuses is explained to the seat on | ||
| the desk. A spent broadcast budget completes the seat with the work. | ||
| - **Walls**: turns per conversation, turns per episode. | ||
|
|
||
| The conductor appends nothing. It hands the host a `Note` to append, a | ||
| `Commit` to append and report the sequence of, or an `Event` to log, and | ||
| takes the sequence back through `committed`. The host owns the journal, | ||
| the rendering of a row, the prompt, and running the turn. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| //! One open conversation: a thread of the desk, run as its own episode. | ||
|
|
||
| use tinyhivemind::Sequence; | ||
|
|
||
| use crate::driver::{ConversationView, DriverState}; | ||
|
|
||
| /// A conversation rooted at an ask row, whose participant is the seat asked, | ||
| /// with the asker recorded here (ADR 0023). One question, one answer: the | ||
| /// seat asked concludes with `complete_episode`, and its message is the | ||
| /// answer; a follow-up is a further ask. | ||
| #[derive(Clone, Debug)] | ||
| pub(super) struct Child { | ||
| pub(super) root: Sequence, | ||
| pub(super) asker: String, | ||
| pub(super) askee: String, | ||
| pub(super) state: DriverState, | ||
| /// Turns taken in it so far. | ||
| pub(super) turns: u64, | ||
| /// The last thing the seat asked said in it: the conclusion, cross-posted. | ||
| pub(super) last_by_askee: Option<String>, | ||
| /// Whether the seat asked has been told once that it has not answered. | ||
| pub(super) nudged: bool, | ||
| /// Whether the seat asked took a turn in this wave. | ||
| pub(super) turned: bool, | ||
| } | ||
|
|
||
| impl Child { | ||
| pub(super) fn new(root: Sequence, by: &str, to: &str, state: DriverState) -> Self { | ||
| Self { | ||
| root, | ||
| asker: by.to_owned(), | ||
| askee: to.to_owned(), | ||
| state, | ||
| turns: 0, | ||
| last_by_askee: None, | ||
| nudged: false, | ||
| turned: false, | ||
| } | ||
| } | ||
|
|
||
| /// Whether `seat` is one of its two. | ||
| pub(super) fn involves(&self, seat: &str) -> bool { | ||
| self.asker == seat || self.askee == seat | ||
| } | ||
|
|
||
| /// The other seat, from `seat`'s side. | ||
| pub(super) fn other(&self, seat: &str) -> String { | ||
| if seat == self.asker { | ||
| self.askee.clone() | ||
| } else { | ||
| self.asker.clone() | ||
| } | ||
| } | ||
|
|
||
| /// Over: the seat asked completed, or the wall was reached. | ||
| pub(super) fn is_over(&self, wall: u64) -> bool { | ||
| self.state.quiescent() || self.turns >= wall | ||
| } | ||
|
|
||
| /// What reaches the asker when it concludes. | ||
| pub(super) fn outcome(&self, forced: bool) -> String { | ||
| if forced { | ||
| "the conversation did not conclude in time; take what was said and proceed".to_owned() | ||
| } else { | ||
| self.last_by_askee | ||
| .clone() | ||
| .unwrap_or_else(|| "concluded".to_owned()) | ||
| } | ||
| } | ||
|
|
||
| /// How `seat` sees it, with the transcript the host holds. | ||
| pub(super) fn view(&self, seat: &str, transcript: Vec<String>) -> ConversationView { | ||
| ConversationView { | ||
| root: self.root, | ||
| other: self.other(seat), | ||
| opened_it: seat == self.asker, | ||
| transcript, | ||
| concluded: false, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// A conversation that concluded, kept for the context of the seats that had | ||
| /// it: shown whole once to each, on its next desk turn. | ||
| #[derive(Clone, Debug, Eq, PartialEq)] | ||
| pub(super) struct Concluded { | ||
| pub(super) root: Sequence, | ||
| pub(super) asker: String, | ||
| pub(super) askee: String, | ||
| } | ||
|
|
||
| impl Concluded { | ||
| pub(super) fn involves(&self, seat: &str) -> bool { | ||
| self.asker == seat || self.askee == seat | ||
| } | ||
|
|
||
| pub(super) fn view(&self, seat: &str, transcript: Vec<String>) -> ConversationView { | ||
| ConversationView { | ||
| root: self.root, | ||
| other: if seat == self.asker { | ||
| self.askee.clone() | ||
| } else { | ||
| self.asker.clone() | ||
| }, | ||
| opened_it: seat == self.asker, | ||
| transcript, | ||
| concluded: true, | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Name the
test/directory, nottest.rs.The module ships
test/mod.rswithconversations.rs,desk.rs,door.rs, andsupport.rs. The table entry does not match the source layout.📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents