diff --git a/docs/agent-goals/full-l1/README.md b/docs/agent-goals/full-l1/README.md new file mode 100644 index 00000000..a3e40d50 --- /dev/null +++ b/docs/agent-goals/full-l1/README.md @@ -0,0 +1,44 @@ +# FlowChain Full L1 Agent Goals + +Status: copy-ready long-running `/goal` prompts for building FlowChain from the +current local deterministic devnet into a runnable private/local L1 testnet. + +These prompts are intentionally implementation-heavy. They are for dedicated +Codex agents in separate worktrees. Agents must build on existing code and must +not create replacement systems. + +Target local acceptance: + +1. A clean Windows machine can install and run FlowChain with one obvious path. +2. At least one long-running local node produces blocks. +3. Optional LAN or multi-process nodes can join a private testnet. +4. Transactions can be signed, submitted, included, queried, exported, and + replayed deterministically. +5. Agent, model, receipt, artifact, verifier, memory, challenge, and finality + lifecycle objects are real local runtime objects, not only static fixtures. +6. The control-plane API exposes node, chain, account, transaction, bridge, and + object state to the workbench. +7. The workbench shows verified live API status and can inspect or trigger the + local flow. +8. A bridge POC can observe Base Sepolia or mocked Base lock events and credit + the local chain in a replay-safe test mode. +9. `npm run flowchain:full-smoke` proves the whole path. + +Prompt files: + +- `chain-runtime.md` +- `crypto-wallet.md` +- `control-plane-indexer.md` +- `dashboard-workbench.md` +- `contracts-settlement.md` +- `bridge-relayer.md` +- `hardware-signals.md` +- `research-consensus.md` +- `hq-integration-review.md` + +Launch helper: + +```powershell +cd E:\FlowMemory\flowchain-release +powershell -ExecutionPolicy Bypass -File .\infra\scripts\launch-full-l1-agents.ps1 +``` diff --git a/docs/agent-goals/full-l1/bridge-relayer.md b/docs/agent-goals/full-l1/bridge-relayer.md new file mode 100644 index 00000000..1d78c030 --- /dev/null +++ b/docs/agent-goals/full-l1/bridge-relayer.md @@ -0,0 +1,68 @@ +/goal You are the FlowChain bridge agent. + +You are working in `E:\FlowMemory\flowmemory-bridge-full`. + +Mission: build a working test bridge path so a tester can move value-like test +events from Base Sepolia or a mock Base event into the local FlowChain runtime +and see the credited result in the API/workbench. The default path must use +mock or Base Sepolia test assets. Do not silently operate on real funds. + +Read first: +- AGENTS.md +- docs/bridge/FLOWCHAIN_BASE_BRIDGE_POC.md +- services/bridge-relayer/ +- contracts/bridge/ +- schemas/flowmemory/bridge-*.schema.json +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md + +Allowed folders: +- services/bridge-relayer/ +- contracts/bridge/ +- tests/bridge/ +- schemas/flowmemory/bridge-*.schema.json +- fixtures/bridge/ +- infra/scripts/bridge-*.ps1 +- package.json when adding bridge commands +- docs/bridge/ + +Do not edit: +- apps/dashboard/ +- crates/flowmemory-devnet/ except documented bridge handoff examples +- crypto/ except shared bridge schema references +- hardware/ + +Build requirements: +1. Observe BaseBridgeLockbox deposit events from: + - committed mock fixture + - local Anvil + - Base Sepolia RPC when env vars are provided +2. Convert deposits into canonical BridgeObservation and BridgeCredit objects + with replay protection and deterministic IDs. +3. Submit bridge credits into the local FlowChain runtime through the + control-plane/runtime intake path once available; until then, write the + exact handoff file the runtime agent will consume. +4. Add withdrawal/burn intent objects for local-to-Base testing. For now this + can be a test-mode withdrawal record with no real mainnet release. +5. Add bridge smoke commands: + - mock bridge smoke + - Base Sepolia observation smoke + - full local credit smoke +6. Make the workbench/API able to display deposit observed -> credit pending -> + credit applied -> withdrawal requested. + +Expected commands: +- `npm run bridge:mock` +- `npm run bridge:test` +- `npm run bridge:sepolia:observe` +- `npm run bridge:local-credit:smoke` +- contribute to `npm run flowchain:full-smoke` + +Acceptance: +- Bridge relayer tests pass. +- Foundry bridge tests pass if contracts changed. +- Mock deposit credits local state or writes a validated handoff. +- Base Sepolia observation can run without private keys. +- Any real-funds command requires an explicit flag and prints what chain, token, + amount, contract, and account will be used before it broadcasts. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/chain-runtime.md b/docs/agent-goals/full-l1/chain-runtime.md new file mode 100644 index 00000000..7a95844e --- /dev/null +++ b/docs/agent-goals/full-l1/chain-runtime.md @@ -0,0 +1,82 @@ +/goal You are the FlowChain full L1 runtime agent. + +You are working in `E:\FlowMemory\flowmemory-chain`. + +Mission: turn the existing Rust deterministic devnet into a runnable +private/local L1 testnet runtime that can run on a second Windows computer. This +must be real implementation work, not a planning-only PR. + +Read first: +- AGENTS.md +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md +- docs/FLOWCHAIN_AGENT_INTEGRATION_MAP.md +- docs/LOCAL_DEVNET.md +- crates/flowmemory-devnet/ +- infra/scripts/flowchain-*.ps1 + +Allowed folders: +- crates/flowmemory-devnet/ +- devnet/ +- infra/scripts/ +- package.json and package-lock.json when adding root commands +- docs/LOCAL_DEVNET.md +- docs/FLOWCHAIN_SECOND_COMPUTER_SETUP.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md only for acceptance evidence + +Do not edit: +- apps/dashboard/ +- services/ except documented handoff files if strictly necessary +- contracts/ +- crypto/ +- hardware/ + +Build requirements: +1. Add a long-running node mode to the Rust devnet. It must keep state on disk, + accept local transactions, produce blocks on an interval or manual tick, and + expose useful logs. +2. Add a transaction intake path for FlowChain-native objects: + AgentAccount, ModelPassport, WorkReceipt, ArtifactAvailabilityProof, + VerifierModule, VerifierReport, MemoryCell, Challenge, FinalityReceipt, and + local balance/faucet records. +3. Add a local account/balance ledger for test units only. This is not + tokenomics; it is necessary so the test chain can send transactions and + bridge credits. +4. Add a minimal node identity and peer model. At minimum support multi-process + local nodes with static peer config and deterministic block/state sync. LAN + mode can be simple, but it must be documented and smoke-tested if exposed. +5. Add CLI commands and npm wrappers for: + - start node + - stop node + - node status + - submit transaction + - faucet local account + - run one-node smoke + - run two-node or multi-process smoke + - export/import runtime state +6. Keep the existing deterministic fixture/demo path working. +7. Feed handoff outputs to the existing control-plane and dashboard surfaces. + +Expected commands to add or make work: +- `npm run flowchain:node` +- `npm run flowchain:node:stop` +- `npm run flowchain:tx` +- `npm run flowchain:faucet` +- `npm run flowchain:node:smoke` +- `npm run flowchain:multi-node:smoke` +- contribute to `npm run flowchain:full-smoke` + +Acceptance: +- `cargo test --manifest-path crates/flowmemory-devnet/Cargo.toml` passes. +- A local node can run for at least 10 blocks. +- A signed or locally authorized transaction can be submitted and included. +- State survives restart. +- Export/import still works. +- Multi-process smoke either passes or clearly marks LAN mode as not yet exposed + while still proving two local nodes can exchange or reconcile state. +- `git diff --check` passes. +- Open a PR and push your branch. + +Do not stop because part of this is difficult. If full networking is too large +for one pass, build the smallest real local multi-process version and leave a +failing/skip-marked test naming the exact remaining gap. diff --git a/docs/agent-goals/full-l1/contracts-settlement.md b/docs/agent-goals/full-l1/contracts-settlement.md new file mode 100644 index 00000000..49881ac4 --- /dev/null +++ b/docs/agent-goals/full-l1/contracts-settlement.md @@ -0,0 +1,54 @@ +/goal You are the FlowChain contracts and settlement-spine agent. + +You are working in `E:\FlowMemory\flowmemory-contracts`. + +Mission: build the contract-side pieces that support the local/private L1 and +bridge test flow. Contracts are not the whole L1 runtime; they are the optional +settlement/event/bridge spine for testing. Build concrete Solidity and Foundry +tests, not just docs. + +Read first: +- AGENTS.md +- contracts/ +- tests/ +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/bridge/FLOWCHAIN_BASE_BRIDGE_POC.md + +Allowed folders: +- contracts/ +- tests/ +- script/ if Foundry scripts are needed +- foundry.toml +- docs/bridge/ for contract boundary notes + +Do not edit: +- services/ +- apps/ +- crates/ +- crypto/ +- hardware/ + +Build requirements: +1. Harden and extend BaseBridgeLockbox for test bridge flows: + deposits, replay protection, token allowlist, pause, per-deposit cap, + deterministic event shape, and withdrawal/release test hooks where needed. +2. Add or refine local settlement contracts/events for FlowChain object + commitments where they help indexer/verifier and bridge agents. +3. Keep contracts compact. Do not try to implement the whole runtime in + Solidity. +4. Add Foundry tests for all bridge and settlement edge cases. +5. Add Anvil/Base Sepolia script paths for testing, with explicit environment + variables and dry-run by default. + +Expected commands: +- `forge test` +- `npm run contracts:hardening` +- bridge-specific Foundry tests + +Acceptance: +- Foundry tests pass. +- Bridge event schema is stable and documented for the bridge relayer. +- No contract can accidentally release or mint without explicit test-only + authority. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/control-plane-indexer.md b/docs/agent-goals/full-l1/control-plane-indexer.md new file mode 100644 index 00000000..830cddcb --- /dev/null +++ b/docs/agent-goals/full-l1/control-plane-indexer.md @@ -0,0 +1,64 @@ +/goal You are the FlowChain control-plane, indexer, and verifier API agent. + +You are working in `E:\FlowMemory\flowmemory-indexer`. + +Mission: make the local node queryable and usable. Extend the existing +`services/` packages into the API layer for the private/local L1 testnet. This +must support live node state, submitted transactions, bridge observations, and +the full object lifecycle. Do not create a second API framework. + +Read first: +- AGENTS.md +- docs/FLOWCHAIN_CONTROL_PLANE_API.md +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md +- services/control-plane/ +- services/indexer/ +- services/verifier/ +- services/bridge-relayer/ + +Allowed folders: +- services/ +- fixtures/ when generated service fixtures are needed +- schemas/flowmemory/ only when coordinating response schemas +- package.json and package-lock.json when adding commands +- docs/FLOWCHAIN_CONTROL_PLANE_API.md +- docs/INDEXER_VERIFIER_MVP.md + +Do not edit: +- apps/dashboard/ +- contracts/ +- crates/flowmemory-devnet/ except documented API handoff examples +- crypto/ except schema references +- hardware/ + +Build requirements: +1. Keep `/health`, `/state`, `/rpc`, and CORS working for the browser. +2. Add live local-node adapters so the API reads current runtime state from + `devnet/local/` or the node API, not only committed fixtures. +3. Add JSON-RPC and HTTP helpers for: + node status, peers, blocks, transactions, mempool, accounts, balances, + faucet events, wallet public metadata, AgentAccount, ModelPassport, + WorkReceipt, ArtifactAvailabilityProof, VerifierModule, VerifierReport, + MemoryCell, Challenge, FinalityReceipt, bridge deposits, bridge credits, and + withdrawals. +4. Add transaction submission endpoint that forwards signed/local test + transactions to the runtime agent's intake path. +5. Add bridge observation intake/read endpoints for the bridge agent. +6. Add full smoke client coverage that queries every lifecycle object. +7. Add no-secret response scanning. + +Expected commands: +- `npm run control-plane:serve` +- `npm run control-plane:smoke` +- `npm run control-plane:test` +- contribute to `npm run flowchain:full-smoke` + +Acceptance: +- `npm test` passes for services. +- `npm run control-plane:smoke` proves the full local lifecycle. +- Browser workbench can consume the API without CORS failures. +- API responses contain no private keys, mnemonics, RPC secrets, or seed + phrases. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/crypto-wallet.md b/docs/agent-goals/full-l1/crypto-wallet.md new file mode 100644 index 00000000..15d9bb1e --- /dev/null +++ b/docs/agent-goals/full-l1/crypto-wallet.md @@ -0,0 +1,63 @@ +/goal You are the FlowChain crypto, wallet, and local key agent. + +You are working in `E:\FlowMemory\flowmemory-crypto`. + +Mission: make FlowChain locally usable by adding the wallet/signing/object +identity layer needed for a real private/local L1 testnet. Build on the existing +`crypto/` package and `schemas/flowmemory/`. Do not create a second crypto +package. + +Read first: +- AGENTS.md +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md +- crypto/ +- schemas/flowmemory/ +- crates/flowmemory-devnet/ transaction/object model + +Allowed folders: +- crypto/ +- schemas/flowmemory/ +- docs/DECISIONS/ for crypto/key decisions +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md only for acceptance evidence + +Do not edit: +- apps/ +- services/ implementation +- contracts/ +- hardware/ +- crates/flowmemory-devnet/ except tiny schema examples only if coordinated + +Build requirements: +1. Define canonical local transaction envelopes with domain separation, + chain-id, nonce, signer, payload hash, and signature. +2. Add object IDs, hash inputs, schemas, and vectors for: + AgentAccount, ModelPassport, WorkReceipt, ArtifactAvailabilityProof, + VerifierModule, VerifierReport, MemoryCell, Challenge, FinalityReceipt, + BridgeDeposit, BridgeCredit, BridgeWithdrawal, and local account balance. +3. Add a local encrypted wallet/vault for test keys. It must support create, + unlock, list public accounts, sign transaction, import/export public metadata, + and rotate or create additional accounts. +4. Keep secrets out of committed fixtures and exports. +5. Add negative vectors for wrong chain id, wrong domain, wrong signer, replayed + nonce, malformed roots, malformed bridge deposit, and changed object type. +6. Provide a small CLI or npm script surface that other agents can call for + wallet create/sign/verify. + +Expected commands to add or make work: +- `npm run wallet:create --prefix crypto` +- `npm run wallet:sign --prefix crypto` +- `npm run wallet:verify --prefix crypto` +- `npm run validate:vectors --prefix crypto` +- contribute to `npm run flowchain:full-smoke` + +Acceptance: +- `npm test --prefix crypto` passes. +- crypto vector validation passes. +- A local transaction envelope can be signed and verified without exposing the + private key. +- The devnet agent can consume the envelope format. +- The control-plane agent can display public signer/account metadata without + secrets. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/dashboard-workbench.md b/docs/agent-goals/full-l1/dashboard-workbench.md new file mode 100644 index 00000000..55dc1620 --- /dev/null +++ b/docs/agent-goals/full-l1/dashboard-workbench.md @@ -0,0 +1,58 @@ +/goal You are the FlowChain dashboard/workbench agent. + +You are working in `E:\FlowMemory\flowmemory-dashboard`. + +Mission: make the workbench feel like a real local chain console. It must show +the live local node/API state, not just static fixtures, and it must help a +non-technical tester run the chain on a second computer. + +Read first: +- AGENTS.md +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md +- apps/dashboard/ +- docs/FLOWCHAIN_CONTROL_PLANE_API.md + +Allowed folders: +- apps/dashboard/ +- docs/DASHBOARD_MVP.md +- docs/FLOWCHAIN_SECOND_COMPUTER_SETUP.md only when setup text changes + +Do not edit: +- services/ +- crates/ +- contracts/ +- crypto/ +- hardware/ + +Build requirements: +1. Keep the existing dashboard app. Do not scaffold a second app. +2. Add live workbench views backed by the control-plane API: + node status, peers, blocks, transactions, mempool, accounts, balances, + faucet events, wallet public accounts, agent/model registry, receipts, + artifacts, verifier modules/reports, memory cells, challenges, finality, + bridge deposits/credits/withdrawals, hardware signals, and raw JSON. +3. Add obvious setup/status panels that say what command is missing when the + node or API is down. +4. Add local actions only when the control-plane endpoint exists: + submit local faucet request, submit sample transaction, inspect bridge test + deposit, refresh state. Keep private-key handling out of the browser unless + the crypto agent provides a safe local API. +5. Make offline/error/empty/loading states professional and clear. +6. Keep UI responsive and verify with tests/build. + +Expected commands: +- `npm run dev --prefix apps/dashboard` +- `npm test --prefix apps/dashboard` +- `npm run build --prefix apps/dashboard` +- contribute to `npm run flowchain:full-smoke` + +Acceptance: +- Dashboard tests pass. +- Dashboard build passes. +- Workbench shows verified API status when `http://127.0.0.1:8787/health` and + `/state` are live. +- Workbench can inspect all lifecycle object types exposed by the API. +- It does not claim production mainnet or real funds. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/hardware-signals.md b/docs/agent-goals/full-l1/hardware-signals.md new file mode 100644 index 00000000..f6cb461e --- /dev/null +++ b/docs/agent-goals/full-l1/hardware-signals.md @@ -0,0 +1,48 @@ +/goal You are the FlowChain hardware/operator signal agent. + +You are working in `E:\FlowMemory\flowmemory-hardware`. + +Mission: make FlowRouter/Meshtastic-style signals useful to the local L1 +testnet without blocking the chain. Hardware is optional, but the simulator +should produce real control-plane/workbench-visible signals. + +Read first: +- AGENTS.md +- hardware/ +- fixtures/hardware/ +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md + +Allowed folders: +- hardware/ +- fixtures/hardware/ +- schemas/flowmemory/hardware-*.json +- docs/hardware docs if present + +Do not edit: +- crates/ +- services/ +- apps/ +- contracts/ +- crypto/ + +Build requirements: +1. Extend the simulator to emit node heartbeat, offline alert, receipt relay, + verifier digest relay, bridge alert, and NFC/operator metadata fixtures. +2. Add deterministic fixture validation and negative cases. +3. Provide handoff JSON that the control-plane can ingest. +4. Keep LoRa/Meshtastic as low-bandwidth control signaling. Do not require + hardware for `flowchain:full-smoke`. +5. Add commands for simulator smoke and fixture generation. + +Expected commands: +- hardware simulator validation +- hardware fixture generation +- contribute optional row to `npm run flowchain:full-smoke` + +Acceptance: +- Simulator checks pass. +- Fixture schema validation passes. +- Control-plane/dashboard agents have a stable handoff shape. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/hq-integration-review.md b/docs/agent-goals/full-l1/hq-integration-review.md new file mode 100644 index 00000000..ec80d158 --- /dev/null +++ b/docs/agent-goals/full-l1/hq-integration-review.md @@ -0,0 +1,50 @@ +/goal You are Flow Memory HQ, integration manager, and reviewer for the full +FlowChain local/private L1 build. + +You are working in `E:\FlowMemory\flowmemory-review`. + +Mission: keep all builder agents moving until the second computer can run a +real full local/private L1 testnet. This is not a docs-only task. You own the +integration checklist, issue/PR map, merge order, smoke evidence, and follow-up +prompts. + +Read first: +- AGENTS.md +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md +- docs/FLOWCHAIN_AGENT_INTEGRATION_MAP.md +- docs/DAILY_HQ_RUNBOOK.md +- open GitHub PRs and issues + +Allowed folders: +- docs/ +- .github/ +- infra/scripts/ +- README.md +- AGENTS.md +- package.json only for root orchestration commands after coordinating with + implementation agents + +Do not edit: +- subsystem implementation folders except small integration scripts when no + other agent owns them + +Build/coordination requirements: +1. Create or update GitHub issues for the full L1 workstreams with explicit + acceptance criteria. +2. Track every active branch/PR and changed folder ownership. +3. Keep a live integration matrix: chain, crypto, control-plane, dashboard, + contracts, bridge, hardware, research. +4. Define and maintain `npm run flowchain:full-smoke` acceptance. If the command + does not exist yet, create the issue and temporary wrapper that reports + missing subsystem commands clearly. +5. Review PRs for duplicate systems and scope conflicts. +6. After each builder PR, update the second-computer setup path and runbook. +7. Keep feeding follow-up prompts to agents that finish early. + +Acceptance: +- A user can see exactly what is implemented, what is running, and what remains + before the chain is full. +- Open PRs have merge order and review notes. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/docs/agent-goals/full-l1/research-consensus.md b/docs/agent-goals/full-l1/research-consensus.md new file mode 100644 index 00000000..8b7307ff --- /dev/null +++ b/docs/agent-goals/full-l1/research-consensus.md @@ -0,0 +1,47 @@ +/goal You are the FlowChain consensus, storage, and architecture research agent. + +You are working in `E:\FlowMemory\flowmemory-research`. + +Mission: make fast architecture decisions that unblock implementation. This is +not open-ended research. Produce accepted decisions, concrete protocol shapes, +and testable acceptance gates for the builder agents. + +Read first: +- AGENTS.md +- research/flowchain-local-alpha/ +- docs/DECISIONS/ +- docs/FLOWCHAIN_FULL_PRIVATE_TESTNET.md +- docs/FLOWCHAIN_TESTNET_ACCEPTANCE.md + +Allowed folders: +- research/ +- docs/DECISIONS/ +- docs/ARCHITECTURE.md only if needed +- docs/ROADMAP.md only if needed + +Do not edit: +- crates/ +- services/ +- apps/ +- contracts/ +- crypto/ +- hardware/ + +Deliver decisions for: +1. Local/private consensus model for V0: single-node, multi-process, LAN mode, + fork choice, block interval, validator identity, and state sync. +2. Transaction and state model: nonce, account, fee/test-unit semantics, + mempool ordering, replay protection, state root commitments. +3. Storage model: what is in state, what is in files, what is artifact metadata, + what is never stored in the chain. +4. Bridge model: observed deposit, local credit, withdrawal intent, replay + handling, testnet/mainnet boundary. +5. Wallet/key model: local encrypted vault, public account metadata, signing + domains, rotation. +6. Acceptance gates for claiming "full local/private L1 testnet". + +Acceptance: +- Decision records are concrete enough that each builder agent can implement + without inventing protocol rules. +- `git diff --check` passes. +- Open a PR and push your branch. diff --git a/infra/scripts/launch-full-l1-agents.ps1 b/infra/scripts/launch-full-l1-agents.ps1 new file mode 100644 index 00000000..5063012d --- /dev/null +++ b/infra/scripts/launch-full-l1-agents.ps1 @@ -0,0 +1,153 @@ +param( + [switch] $DryRun, + [switch] $NoBranchPrepare +) + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version Latest + +$repoRoot = (& git rev-parse --show-toplevel).Trim() +if ([string]::IsNullOrWhiteSpace($repoRoot)) { + throw "Run this script inside the FlowMemory repository." +} + +$promptRoot = Join-Path $repoRoot "docs\agent-goals\full-l1" + +$agents = @( + @{ + Name = "chain-runtime" + Worktree = "E:\FlowMemory\flowmemory-chain" + Branch = "agent/full-l1-runtime" + Prompt = "chain-runtime.md" + }, + @{ + Name = "crypto-wallet" + Worktree = "E:\FlowMemory\flowmemory-crypto" + Branch = "agent/full-l1-crypto-wallet" + Prompt = "crypto-wallet.md" + }, + @{ + Name = "control-plane-indexer" + Worktree = "E:\FlowMemory\flowmemory-indexer" + Branch = "agent/full-l1-control-plane" + Prompt = "control-plane-indexer.md" + }, + @{ + Name = "dashboard-workbench" + Worktree = "E:\FlowMemory\flowmemory-dashboard" + Branch = "agent/full-l1-workbench" + Prompt = "dashboard-workbench.md" + }, + @{ + Name = "contracts-settlement" + Worktree = "E:\FlowMemory\flowmemory-contracts" + Branch = "agent/full-l1-contracts" + Prompt = "contracts-settlement.md" + }, + @{ + Name = "bridge-relayer" + Worktree = "E:\FlowMemory\flowmemory-bridge-full" + Branch = "agent/full-l1-bridge" + Prompt = "bridge-relayer.md" + CreateWorktree = $true + }, + @{ + Name = "hardware-signals" + Worktree = "E:\FlowMemory\flowmemory-hardware" + Branch = "agent/full-l1-hardware" + Prompt = "hardware-signals.md" + }, + @{ + Name = "research-consensus" + Worktree = "E:\FlowMemory\flowmemory-research" + Branch = "agent/full-l1-research-consensus" + Prompt = "research-consensus.md" + }, + @{ + Name = "hq-integration-review" + Worktree = "E:\FlowMemory\flowmemory-review" + Branch = "agent/full-l1-hq-integration" + Prompt = "hq-integration-review.md" + } +) + +function Invoke-Git { + param( + [string] $WorkingDirectory, + [string[]] $Arguments + ) + + & git -C $WorkingDirectory @Arguments + if ($LASTEXITCODE -ne 0) { + throw "git $($Arguments -join ' ') failed in $WorkingDirectory" + } +} + +function Test-DirtyWorktree { + param([string] $Path) + + $status = & git -C $Path status --short + if ($LASTEXITCODE -ne 0) { + throw "Could not inspect worktree: $Path" + } + return [bool]$status +} + +Write-Host "Fetching origin/main..." +Invoke-Git -WorkingDirectory $repoRoot -Arguments @("fetch", "origin", "main") + +foreach ($agent in $agents) { + $worktree = $agent.Worktree + $branch = $agent.Branch + $promptPath = Join-Path $promptRoot $agent.Prompt + + if (-not (Test-Path -LiteralPath $promptPath)) { + throw "Missing prompt file: $promptPath" + } + + if (-not (Test-Path -LiteralPath $worktree)) { + if ($agent.CreateWorktree) { + Write-Host "Creating worktree $worktree on $branch" + if (-not $DryRun) { + & git -C $repoRoot worktree add -B $branch $worktree origin/main + if ($LASTEXITCODE -ne 0) { + throw "Failed to create worktree $worktree" + } + } + } + else { + throw "Missing worktree: $worktree" + } + } + + if (-not $NoBranchPrepare -and (Test-Path -LiteralPath $worktree)) { + if (Test-DirtyWorktree -Path $worktree) { + Write-Warning "Skipping branch switch for dirty worktree: $worktree" + } + else { + Write-Host "Preparing $($agent.Name): $branch from origin/main" + if (-not $DryRun) { + Invoke-Git -WorkingDirectory $worktree -Arguments @("switch", "-C", $branch, "origin/main") + } + } + } + + $command = @" +`$prompt = Get-Content -Raw -LiteralPath "$promptPath" +Set-Location -LiteralPath "$worktree" +codex --cd "$worktree" -s danger-full-access -a never `$prompt +"@ + + Write-Host "Launching $($agent.Name) in $worktree" + if (-not $DryRun) { + Start-Process powershell.exe -ArgumentList @( + "-NoExit", + "-ExecutionPolicy", + "Bypass", + "-Command", + $command + ) + } +} + +Write-Host "Full L1 agent launch complete."