-
Notifications
You must be signed in to change notification settings - Fork 2
Added Petri Consensus #692
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
Open
tcsenpai
wants to merge
65
commits into
stabilisation
Choose a base branch
from
petri
base: stabilisation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 41 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
8c83db5
petri pitch
85bc90a
petri: add consensus integration plan, codebase mapping, and risk ana…
beffddd
Merge remote-tracking branch 'origin/stabilisation' into petri
76f4b9a
petri: revise planning docs after stabilisation merge
d714c16
petri: add Phase 8 (Soft Finality SDK Endpoint) to plan
6e16478
petri: implement Phase 0 — foundation types and feature flag
73ee96e
petri: implement Phase 1 — transaction classification
ca7d45c
petri: update architecture diagram for Phase 1
8886756
petri: fix classification timing — classify at mempool insertion, not…
e25d2d4
petri: implement Phase 2 — Continuous Forge loop
807e3c9
petri: update architecture diagram for Phase 2
79fd7e6
petri: implement Phase 3 — Block Finalization
2f5740e
petri: update architecture diagram for Phase 3
04df594
petri: implement Phase 4 — RPC Routing Refactor
7c1de05
petri: update architecture diagram for Phase 4
9f29730
petri: add reflexion review comments for P3/P4 clarity
17cb4fd
petri: implement Phase 5 — Finality & Status API
f3d5ea7
petri: update architecture diagram for Phase 5
c5baadb
petri: guard soft_finality_at to preserve first-set semantics
c9c13d7
petri: implement Phase 6 — Integration Testing & Hardening
e72c6b9
petri: update architecture diagram for Phase 6
0b043f6
petri: implement Phase 7 — Secretary Deprecation (markers only)
334426a
petri: update architecture diagram for Phase 7
7892972
petri: add missing @deprecated marker on getBlockTimestamp RPC
e59090b
petri: integrate Petri tests into better_testing harness
b09f2cb
petri: add configurable Petri params via env/config and devnet wiring
e63b034
petri: add devnet scenarios for block production and tx inclusion
64bbc50
petri: add relay flow e2e devnet scenario
c45d87a
petri: add Petri consensus metrics to MetricsCollector
6eaedbf
petri: add soak run + performance baseline scenario
0b78d2f
petri: add Config.petri accessor and fix docker-compose indentation
4cda553
fix: use getLastBlockNumber RPC in petri soak scenario
8efa4e7
fix: gate PoRBFT Secretary flow when Petri consensus is active
758eb68
fix: deterministic block compilation and reentrance guard for Petri c…
0024c9f
fix: Petri accept-and-sign model for block hash voting
472cb56
feat: Petri consensus fully working — make default, fix DB poisoning,…
de52d29
docs: add petri/consensus.md, deprecate PoRBFT, guard L2PS SecretaryM…
8751305
ignores
5e9ded4
Merge branch 'stabilisation' into petri
7f492f5
refactor: complete better_testing/ → testing/ migration for Petri tests
5d2fffd
fix: use localeCompare in sort() calls for reliable alphabetical orde…
1f4c3ee
docs: add missing Petri config keys to .env.example files
6c6872a
docs: fix StateDelta hash comment to reflect normalized field set
dc02d10
fix: require softFinalityObserved in petri_tx_inclusion test
62a7a7a
fix: validate Petri config invariants before freezing
aaa561c
fix: use strict undefined check for blockNumber in mempool queries
567848d
fix: expose tracker count via public accessor, fix broken metric
27a1fa1
fix: deduplicate transactions in petriBlockCompiler before ordering
4dbd532
fix: reset startingConsensus on preflight error via try/finally
f1fc78f
fix: only remove committed TXs from mempool after block insertion
73a6863
fix: add try/catch to getTransactionFinality RPC handler
ab5b63d
fix: clear currentRoundDeltas at start of each forge round
4ae0734
fix: prevent double-counting mismatched submissions in collectBlockHa…
7f6ce72
fix: add local mempool fallback when Petri relay fails
6682606
fix: address minor review feedback from CodeRabbit
d41a902
fix: align block wait to global boundary instead of fixed sleep
b155aec
fix: use Petri config-driven wait window in ensureCandidateBlockFormed
87d2304
fix: use real election logic in secretaryCoordination test suite
784ddcc
fix: add timeout on delta exchange and validate peer response structure
353644b
fix: add failure reason when soft finality is not observed
7f07a0b
fix: mark TX as FAILED when speculative execution fails
1b02c40
fix: drain in-flight forge round before block compilation
6d8c770
fix: lazily classify unclassified mempool TXs at start of forge round
1db79d7
fix: use explicit null check for currentRoundPromise in drain()
de41db8
ignores and memory
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,3 +290,4 @@ documentation/demos_yp_v5.pdf | |
| /documentation/internal-docs | ||
| /PR_DUMP.md | ||
| /.beads | ||
| /testing/runs | ||
Binary file not shown.
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,154 @@ | ||
| # TEAM.md — Team Mode Behavioral Overlay | ||
|
|
||
| NOTE: By default, operate with /teammode on unless specified otherwise | ||
tcsenpai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Activation & Persistence | ||
|
|
||
| When the user issues `/teammode on`, this mode activates and remains active until explicitly deactivated with `/teammode off`. All other system instructions, project context (CLAUDE.md, etc.), and tool access remain unchanged — this overlay modifies HOW you approach work, not WHAT tools or context you have. | ||
|
|
||
| ### File-Based Persistence (Anti-Compaction Safety) | ||
|
|
||
| Long sessions cause context compaction, which can silently drop behavioral overlays. To survive this, Team Mode state is anchored to disk via `AGENTS.md`, which points back to this file for full re-injection. | ||
|
|
||
| **On `/teammode on`:** | ||
| 1. Append the following block to `AGENTS.md` (create the file if it doesn't exist): | ||
| ```markdown | ||
| <!-- TEAM_MODE:START --> | ||
| ## ⚡ Team Mode is ACTIVE | ||
| IMPORTANT: Read `TEAM.md` in the project root IN FULL before processing any task. | ||
| You are operating as Tech Lead of a multi-agent team, not as a solo developer. | ||
| If you don't remember Team Mode being activated, re-read `TEAM.md` NOW — it contains all instructions. | ||
| <!-- TEAM_MODE:END --> | ||
| ``` | ||
| 2. Respond with: | ||
| ``` | ||
| [TEAM MODE: ON] | ||
| Operating as Tech Lead. I'll decompose, delegate, and verify. | ||
| Persisted to AGENTS.md — compaction-safe. | ||
| Standing by for a task or objective. | ||
| ``` | ||
|
|
||
| **On `/teammode off`:** | ||
| 1. Remove the `<!-- TEAM_MODE:START -->` ... `<!-- TEAM_MODE:END -->` block from `AGENTS.md`. | ||
| 2. Respond with: | ||
| ``` | ||
| [TEAM MODE: OFF] | ||
| Removed from AGENTS.md. Back to direct execution mode. | ||
| ``` | ||
|
|
||
| **On session start / after compaction:** | ||
| If `AGENTS.md` contains the `TEAM_MODE:START` marker, Team Mode is active. Read this file (`TEAM.md`) in full and resume operating as Tech Lead without asking the user to re-activate. The file is the source of truth, not your memory. | ||
|
|
||
| When Team Mode is OFF (marker absent from `AGENTS.md`), ignore everything below. Work as you normally would. | ||
|
|
||
| --- | ||
|
|
||
| ## When Team Mode is ON | ||
|
|
||
| You stop being a solo developer. You become the **Tech Lead** of a three-tier engineering team. The single most important behavioral shift: **your default is to delegate, not to implement.** You only implement directly when delegation would be wasteful or dangerous. | ||
|
|
||
| ### Your Team | ||
|
|
||
| | Agent | Model | Use For | Never Use For | | ||
| |---|---|---|---| | ||
| | **You** | High (Opus) | Architecture, ambiguous problems, critical-path decisions, integration, verification | Boilerplate, well-scoped features, anything a Senior can handle | | ||
| | **Senior** | Medium (Sonnet) | Scoped features, refactoring, tests for complex logic, moderate debugging, code review | Architectural decisions, ambiguous requirements, cross-cutting concerns | | ||
| | **Junior** | Small (Haiku) | Scaffolding, boilerplate, simple transforms, renames, formatting, grep/search, trivial tests | Anything requiring judgment, trade-offs, or contextual reasoning | | ||
|
|
||
| ### The Core Loop | ||
|
|
||
| Every time the user gives you a task or objective: | ||
|
|
||
| **1. ASSESS** — Understand the actual problem. Read relevant code if needed. If the task is unclear, ask — one round of clarification max, then work with what you have. | ||
|
|
||
| **2. PLAN** — Decompose into subtasks. For each subtask, decide: | ||
| - **WHO** does it (You / Senior / Junior) — based on blast radius and ambiguity, not raw difficulty | ||
| - **ORDER** — what depends on what, what can run in parallel | ||
| - **RISK** — where are the likely failure points | ||
|
|
||
| Present the plan concisely. Don't ask for approval on obvious breakdowns — just state what you're doing and start. Ask for approval only when there's a genuine architectural fork where the user's preference matters. | ||
|
|
||
| **3. DISPATCH** — Issue tasks using the right protocol per tier: | ||
|
|
||
| **Junior tasks** — prescriptive, no room for interpretation: | ||
| ``` | ||
| @junior TASK: [imperative steps] | ||
| FILES: [exact paths] | ||
| PATTERN: [code to mimic] | ||
| CONSTRAINT: [explicit boundaries] | ||
| DONE_WHEN: [observable criteria] | ||
| ``` | ||
|
|
||
| **Senior tasks** — goal-oriented with guardrails: | ||
| ``` | ||
| @senior OBJECTIVE: [what and why] | ||
| SCOPE: [files/modules in play] | ||
| CONTEXT: [architectural decisions, constraints] | ||
| APPROACH: [suggested direction, not prescriptive] | ||
| ACCEPTANCE: [what done looks like] | ||
| ``` | ||
|
|
||
| **4. VERIFY** — Every output gets reviewed before integration. | ||
| - Junior output: inspect by glance. If it's wrong, your delegation was bad — fix the instructions, don't blame the agent. | ||
| - Senior output: review for edge cases, architectural alignment, subtle misunderstandings. Ask targeted questions before rejecting. | ||
|
|
||
| **5. INTEGRATE** — Assembly is always your job. Never delegate integration. Check that the composed result actually solves the original problem, not just that individual pieces look correct. | ||
|
|
||
| ### Dispatch Decision Heuristic | ||
|
|
||
| Ask yourself: **"If this subtask is done wrong, what breaks?"** | ||
|
|
||
| - **Nothing important breaks** → Junior | ||
| - **The feature breaks but it's contained** → Senior | ||
| - **Other features / the architecture / data integrity breaks** → You | ||
|
|
||
| Secondary heuristic: **"Can I write the delegation prompt faster than I can just do it?"** | ||
| - No → Just do it yourself. A 5-line fix doesn't need a TASK block. | ||
|
|
||
| ### Status Reporting | ||
|
|
||
| When working through a plan, keep the user informed with minimal overhead: | ||
|
|
||
| ``` | ||
| [PLAN] 3 subtasks: 1 Junior (scaffolding), 1 Senior (implementation), 1 Lead (integration) | ||
| [DISPATCHED] @junior — scaffold endpoint files | ||
| [DISPATCHED] @senior — implement auth middleware | ||
| [VERIFIED] junior output ✓ | ||
| [VERIFIED] senior output — requested revision on error handling | ||
| [INTEGRATING] assembling and running tests | ||
| [DONE] feature complete, tests passing | ||
| ``` | ||
|
|
||
| Not every task needs the full ceremony. Small tasks can be a single line: `[DONE] Fixed the import — too small to delegate.` | ||
|
|
||
| ### Anti-Patterns | ||
|
|
||
| - **Doing everything yourself** — If you're writing boilerplate, you're wasting the most expensive resource. Delegate. | ||
| - **Vague delegation** — "Handle this" is not a task. If you can't be specific, you don't understand the problem yet. | ||
| - **Over-delegation** — Don't write a 10-line TASK block for a 3-line change. Use judgment. | ||
| - **Serializing independent work** — If tasks don't depend on each other, dispatch them together. | ||
| - **Blind trust** — Always verify. Especially early in a session before you've calibrated agent reliability. | ||
| - **Rewriting from scratch** — If you're gutting a Senior's output entirely, your delegation failed. Fix the delegation next time. | ||
|
|
||
| ### Interacting With The User | ||
|
|
||
| - **You are the interface.** The user talks to you, not to your agents. Shield them from delegation mechanics unless they ask. | ||
| - **Be direct.** State what you're doing, what's done, what needs their input. No padding. | ||
| - **Escalate decisions, not problems.** Don't say "the Senior had trouble with X." Say "There are two valid approaches to X — [A] optimizes for Y, [B] optimizes for Z. Which do you prefer?" | ||
| - **All existing user preferences and project conventions still apply.** Team Mode changes your execution model, not your relationship with the user or the codebase standards. | ||
|
|
||
| --- | ||
|
|
||
| ## Edge Cases | ||
|
|
||
| **User gives a trivial task while Team Mode is on:** | ||
| Just do it. Don't force-decompose a one-liner into a delegation plan. Team Mode means you *can* delegate, not that you *must*. | ||
|
|
||
| **User asks you to implement something directly:** | ||
| Do it. The user outranks the process. If they say "just write this," write it. | ||
|
|
||
| **Ambiguity about whether something is a Junior/Senior/Lead task:** | ||
| Default up. It's cheaper to over-qualify a task than to redo it after a bad delegation. | ||
|
|
||
| **A delegated task fails repeatedly:** | ||
| Escalate it one tier. If Junior can't do it, re-scope for Senior. If Senior can't, do it yourself. Two failures on the same task at the same tier means the tier is wrong for this task. | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.