Skip to content

docs: fill in contract-scoped project context - #3

Merged
yvesfracari merged 1 commit into
feat/escrow-contractfrom
docs/contract-context
Jul 13, 2026
Merged

docs: fill in contract-scoped project context#3
yvesfracari merged 1 commit into
feat/escrow-contractfrom
docs/contract-context

Conversation

@yvesfracari

Copy link
Copy Markdown
Contributor

Stacked on #1.

This repo now owns the contract-scoped design context for BYOS (the architecture repo was temporary exploration and is going away), so this PR brings that context in for humans and agents. API, operations, and grant material stays out.

New

  • CONTEXT.md — domain language and architecture map, scoped to the contracts: what BYOS is, the glossary (sub-solver, proposal, Trampoline, Escrow, Track A/B, attribution, c_l, ...), the two-risk-classes table, and the contract design posture.
  • ADR-0003 — trampoline deployment & settlement integration. Now states explicitly that Escrow.deposit() triggers the factory deploy.
  • ADR-0004 — penalty schedule & attribution. Contract-scoped extract: debit amounts and triggers, Track A/B debit-freeze flows, one-sub-solver-per-tx attribution, minimum escrow, shortfall policy. Dispute handling and gatekeeping operations live with the BYOS service.
  • ADR-0005 — trampoline execution authority & proposal signature. What the Trampoline verifies on-chain: signature-gated execute, the ProposalData EIP-712 struct (interactionsHash closes the fabricated-fault vector), factory-bound domain separator, storage-free nonces.
  • docs/adr/README.md — index of the five accepted ADRs plus the two known open questions (residue disposition, upgrade-key posture).
  • docs/reference/ — CoW protocol background: slashing framework, auction mechanics, solver CIPs.
  • docs/agents/ — issue tracker and triage label conventions.

Changed

  • ADR-0001/0002: fixed references that pointed at files that only existed in the architecture repo; code anchors are now GitHub permalinks pinned at cowprotocol/contracts@c6b61ce (paths verified at that commit); ADR-0001 notes that ADR-0005 settled its execution-authority and payload-shape forks. The RFP is cited by its forum URL.
  • AGENTS.md: vocabulary now lives only in CONTEXT.md; added a "before working" section (read CONTEXT + ADRs, flag ADR conflicts, where issues live).
  • README: Trampoline listed as a planned contract; ADR list expanded.
  • Escrow.sol: TODO in deposit() for the deploy-at-deposit-time factory hook from ADR-0003 (lands with the Trampoline factory).

No behavior changes; forge build and forge fmt --check pass.

Bring the contract-relevant design context into this repo, which now owns
the contract ADRs (the architecture repo was temporary exploration):

- CONTEXT.md: domain language and architecture map, scoped to the contracts
- ADR-0003: trampoline deployment & settlement integration
- ADR-0004: penalty schedule & attribution (contract-scoped extract)
- ADR-0005: trampoline execution authority & EIP-712 proposal signature
- docs/adr/README.md: index plus known open questions
- docs/reference/: CoW slashing framework, auction mechanics, solver CIPs
- docs/agents/: issue tracker and triage label conventions

Fix the broken references in ADR-0001/0002 (CONTEXT.md, economics note,
old ADR-0006 numbering) and convert code anchors to GitHub permalinks
pinned at cowprotocol/contracts@c6b61ce. The RFP is cited by its forum
URL. AGENTS.md points at CONTEXT.md for vocabulary instead of carrying
its own glossary, and README lists the Trampoline as a planned contract.

Escrow.deposit() gets a TODO for the deploy-at-deposit-time factory hook
settled in ADR-0003; the hook lands with the Trampoline factory.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Approved: documentation-only scope with a non-functional TODO in Escrow.sol; Foundry tests and fmt passed. Cursor Bugbot and Cursor Security Agent checks were not present on this PR; no reviewers assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@yvesfracari
yvesfracari merged commit 983c9e0 into feat/escrow-contract Jul 13, 2026
3 checks passed
jean-neiverth pushed a commit that referenced this pull request Jul 13, 2026
Bring the contract-relevant design context into this repo, which now owns
the contract ADRs (the architecture repo was temporary exploration):

- CONTEXT.md: domain language and architecture map, scoped to the contracts
- ADR-0003: trampoline deployment & settlement integration
- ADR-0004: penalty schedule & attribution (contract-scoped extract)
- ADR-0005: trampoline execution authority & EIP-712 proposal signature
- docs/adr/README.md: index plus known open questions
- docs/reference/: CoW slashing framework, auction mechanics, solver CIPs
- docs/agents/: issue tracker and triage label conventions

Fix the broken references in ADR-0001/0002 (CONTEXT.md, economics note,
old ADR-0006 numbering) and convert code anchors to GitHub permalinks
pinned at cowprotocol/contracts@c6b61ce. The RFP is cited by its forum
URL. AGENTS.md points at CONTEXT.md for vocabulary instead of carrying
its own glossary, and README lists the Trampoline as a planned contract.

Escrow.deposit() gets a TODO for the deploy-at-deposit-time factory hook
settled in ADR-0003; the hook lands with the Trampoline factory.
jean-neiverth added a commit that referenced this pull request Jul 13, 2026
* feat: implement escrow contract per ADR-0002

Implement the full BYOSEscrow contract with owner/operator role
separation, cooldown-based all-or-nothing withdrawals, freeze/unfreeze
for Track B investigations, debit authority for Track A/B penalties,
and permissionless debit sweeping to owner.

* refactor: rename BYOSEscrow to Escrow per ADR-0002

The ADR defines the contract as simply "Escrow". Aligns contract name,
test file, test directory, and deploy script with the specification.

* fix: import ordering in deploy script for forge fmt

* fix: exclude block-timestamp lint rule in foundry config

The block-timestamp lint warns about validator manipulation of
block.timestamp, but this is irrelevant for day-scale cooldowns.
Foundry 1.7.1 runs the linter during build and deny=warnings makes
this a hard error in CI.

* test: add withdrawal lifecycle state cleanup and post-withdrawal debit tests

Extend test_full_withdrawal_lifecycle with a second deposit/withdraw
cycle to verify no leftover deposits or totalDebited in contract state.

Add test_debit_after_withdrawal_reverts to confirm operator cannot
debit a sub-solver after their balance has been fully withdrawn.

* feat: two-step ownership transfer with acceptOwnership

Replace direct ownership transfer with a two-step process: owner calls
transferOwnership to set a pendingOwner, then pendingOwner calls
acceptOwnership to finalize. Prevents irrecoverable loss from typos.
A second transferOwnership call overrides any pending transfer.

* refactor: rename solver to subSolver in tests

Aligns test variable names with the domain terminology used in the
contract and ADR.

* refactor: extract _balance() helper for safe deposits-minus-debits

Consolidates the repeated deposits[s] - totalDebited[s] subtraction
into a single internal function with an explicit underflow guard.
Reverts with InsufficientBalance instead of a raw panic if the
invariant is ever violated.

* docs: add natspec and inline comments to Escrow contract

* refactor: replace deposits/totalDebited with single balances mapping

Collapses two per-sub-solver mappings into one. Deposits add to the
balance, debits subtract from it, withdrawal zeroes it. Eliminates
indefinite accumulation of stale accounting state, removes the
_balance() helper (no subtraction needed), and saves one SLOAD in
debit() and one SSTORE in executeWithdrawal().

* chore: remove BYOSTrampoline from escrow branch

BYOSTrampoline belongs in its own branch/PR. Removes the contract,
its tests, and the deploy script reference.

* docs: bring escrow and trampoline ADRs into this repo

Copied from cow-byos-architecture docs/adr/ as the canonical reference
for contract design decisions.

* docs: update escrow ADR to reflect implementation changes

- Single balances mapping instead of deposits/totalDebited
- Two-step ownership transfer (transferOwnership + acceptOwnership)
- Updated interface, view semantics, and alternatives considered

* docs: add README and AGENTS.md

README covers project overview, contract table, architecture links,
and development instructions. AGENTS.md provides guidelines for AI
agents: repo structure, conventions, domain language, and testing
patterns.

* docs: fill in contract-scoped project context (#3)

Bring the contract-relevant design context into this repo, which now owns
the contract ADRs (the architecture repo was temporary exploration):

- CONTEXT.md: domain language and architecture map, scoped to the contracts
- ADR-0003: trampoline deployment & settlement integration
- ADR-0004: penalty schedule & attribution (contract-scoped extract)
- ADR-0005: trampoline execution authority & EIP-712 proposal signature
- docs/adr/README.md: index plus known open questions
- docs/reference/: CoW slashing framework, auction mechanics, solver CIPs
- docs/agents/: issue tracker and triage label conventions

Fix the broken references in ADR-0001/0002 (CONTEXT.md, economics note,
old ADR-0006 numbering) and convert code anchors to GitHub permalinks
pinned at cowprotocol/contracts@c6b61ce. The RFP is cited by its forum
URL. AGENTS.md points at CONTEXT.md for vocabulary instead of carrying
its own glossary, and README lists the Trampoline as a planned contract.

Escrow.deposit() gets a TODO for the deploy-at-deposit-time factory hook
settled in ADR-0003; the hook lands with the Trampoline factory.

* fix: revert executeWithdrawal when balance is zero

Prevents a no-op withdrawal (e.g. after full debit during cooldown)
from silently succeeding. Now reverts with NothingToWithdraw instead.

---------

Co-authored-by: Pedro Yves Fracari <55461956+yvesfracari@users.noreply.github.com>
@yvesfracari
yvesfracari deleted the docs/contract-context branch July 17, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants