CR2 independent completion review for pre-TSW build tasks (0007) #5

Merged
Taskuler-bot merged 7 commits from feat/cr2-completion-review into main 2026-11-11 03:47:27 +00:00
Member

Base: feat/ofac-payout-hold · Head: feat/cr2-completion-review · Decided by George 2026-11-09/10 (taskuler/docs 0007). Not deployed. Replaces #2.

Design

  • ReviewerRegistry (Ownable2Step, owner = the Safe, holds no funds): published reviewer list, signer-conflict list, per-token
    minimum fee. Reviewers join via RL2: open off-chain application against published criteria; the Safe lists them
    (setReviewer(reviewer, true, metadataURI)). No on-chain application flow.
  • Binding unless escalated: the Safe posts the job, then assignReviewer(jobId, reviewer) (payable, Safe only, job Open) escrows
    the reviewer fee on top of the bounty. After delivery the reviewer calls submitRecommendation; the Safe can
    executeRecommendation at once, anyone after OBJECTION_WINDOW (5 days, fixed constant). acceptDelivery and settlement offers
    revert ReviewJob() on review jobs.
  • Reviewer fee escrowed until resolution: paid to the reviewer on executeRecommendation, or when the Kleros ruling gives
    exactly the recommended split (on ruling 0, refuse or tie paid 50/50, that means a 50% recommendation); refunded to the
    customer (j.customer, the Safe on build tasks) otherwise, including no recommendation, cancel and refundAfterDeadline
    (missed work deadline). Settled inside PayoutLib from job funds, so rule() can't revert (tested with a held reviewer).
  • No silence payout on review jobs: releaseAfterReview never opens (reviewEndsAt = max). A missed deadline lets the Safe
    reassignReviewer (max 2). Once the limit is used and the last reviewer misses its deadline, reviewLapsed(jobId) is true and
    only Kleros can end the job. Nobody has a duty to escalate: the builder files whenever it wants, and so can the customer; funds
    stay in escrow until someone files.
  • Escalation: requestArbitration does not require reviewLapsed. Either party can escalate any time after delivery, with or
    without a recommendation, until the recommendation is executed (usual ETH prepay; on ERC-20 jobs the filer bears it).
  • Signer-conflict gate in acceptBid on every Safe-funded job: builder can't be the reviewer (BadReviewer) or conflicted (Conflicted(builder)).
  • OFAC: a held reviewer can't be assigned; credits to held parties stay frozen.
  • Settlement core in external library PayoutLib, review bookkeeping in ReviewLib. No new Status values; WorkHistory.Outcome.Reviewed (5).

Interface

  • Registry: setReviewer(address, bool listed, string metadataURI), setConflicted(address, bool, string reasonURI),
    setMinReviewerFee(address token, uint256), views reviewerFee(token, bounty), canReview, isConflicted.
  • Market: assignReviewer(jobId, reviewer), submitRecommendation(jobId, uint8 builderPct, bytes32 noteHash, string noteURI)
    (builderPct ∈ {0,25,50,75,100}, before reviewDeadline(jobId) = max(deliveredAt, assignedAt) + reviewPeriod),
    executeRecommendation(jobId), reassignReviewer(jobId, newReviewer), views reviews(jobId), reviewDeadline, reviewEndsAt,
    reviewLapsed, constants OBJECTION_WINDOW (5 days), MAX_REVIEWER_REASSIGNMENTS (2).
  • Constructor: ReviewerRegistry reviewerRegistry_ after workHistory (address(0) disables review jobs).
  • Errors: ReviewJob, NotReviewer, BadReviewer, Conflicted(address), ReviewWindowClosed.

DECIDED

  • 2026-11-09: one reviewer per task from a published list; reviewer fee 5% of the task budget with a $50 minimum (per-token, e.g. USDC 50e6).
  • 2026-11-10: objection window 5 days; at most 2 reassignments; conflict check on every Safe-funded job; no silence payout, a lapsed
    review goes to Kleros; reviewer fee refunded to the customer if Kleros overrules; reviewers join via RL2.
  • 2026-11-10 (George, 11:33 AM CT):
    • Lapsed review: no Safe duty to escalate. The builder files with Kleros whenever it wants; the customer can too. Funds stay in
      escrow until someone files.
    • Prepay: existing rules. On ERC-20 jobs a builder who files bears the Kleros prepay; the Safe doesn't repay it.
    • Ruling 0 (refuse or tie, 50/50): the reviewer is paid if it recommended 50%; otherwise the fee goes back to the customer
      (code change in PayoutLib; rule() still can't revert).

PROVISIONAL (George decision pending)

  • Recommended splits return both deposits; review jobs pay the normal protocol fee; postJob without a reviewer stays allowed for the Safe.

Tests and coverage

  • forge test: 171 passed, 0 failed (test/CompletionReview.t.sol 34 test functions, incl. no-show → Kleros, builder backstop after 2 years
    with the ERC-20 prepay borne by the builder, fee paid/refunded on agree/overrule fuzz over all rulings, ruling 0 with a 50%
    recommendation (paid) and a 75% recommendation (refunded), held reviewer, fixed objection window, credit reasons).
  • Coverage (earlier Nov 10 run, not re-run for the 11:33 change): TaskulerMarket 99.75% lines, 98.00% branches; PayoutLib, ReviewLib, ReviewerRegistry 100%.
  • TaskulerMarket runtime 22,620 B (limit 24,576). Slither: 35 results, all triaged.

Indexer events / ABI

  • ReviewerAssigned(uint256 indexed jobId, address indexed reviewer, uint256 fee, uint8 reassignment)
  • RecommendationSubmitted(uint256 indexed jobId, address indexed reviewer, uint8 builderPct, uint64 objectionEndsAt, bytes32 noteHash, string noteURI) (objectionEndsAt = recommendedAt + 5 days)
  • New: ReviewerFeeSettled(uint256 indexed jobId, address indexed to, uint256 amount, bool paidToReviewer)
  • Changed: Credited(address indexed account, address indexed token, uint256 amount, uint256 indexed jobId, uint8 reason) (new topic hash).
    reason (CreditReason): 0 Payout, 1 Refund, 2 DepositReturn, 3 DepositForfeit, 4 ProtocolFee, 5 ReviewerFee, 6 ReviewerFeeRefund,
    7 ArbitrationRefund (excess prepay), 8 ArbitrationReimbursement. Resolutions emit one Credited per component; per-account totals unchanged.
  • Registry: ReviewerSet(address indexed reviewer, bool listed, string metadataURI), ConflictSet(address indexed account, bool conflicted, string reasonURI), MinReviewerFeeSet(address indexed token, uint256 minReviewerFee).
  • WorkHistory: outcome Reviewed (5).

Changelog 2026-11-10

  • Removed silence-pays-builder on review jobs; added reviewLapsed; lapsed reviews go to Kleros.
  • Reviewer fee no longer credited on submission; escrowed and settled at resolution (ReviewerFeeSettled).
  • OBJECTION_WINDOW = 5 days constant (no longer tied to the settable settlementWindow).
  • Credited gained uint8 reason (own commit); PayoutLib credits per component. Market +309 B for this.
  • RL2 documented in the registry NatSpec; decided items moved from PROVISIONAL to DECIDED.
  • 11:33 AM CT update: ruling 0 now pays a reviewer who recommended 50% (PayoutLib); lapse escalation duty and builder prepay marked
    DECIDED (no Safe duty; filing builder bears the ERC-20 prepay); wording fixed (fee refund goes to the customer; requestArbitration
    doesn't require reviewLapsed; refundAfterDeadline (missed work deadline)). No ABI change.
Base: `feat/ofac-payout-hold` · Head: `feat/cr2-completion-review` · Decided by George 2026-11-09/10 (taskuler/docs 0007). Not deployed. Replaces #2. ## Design - `ReviewerRegistry` (Ownable2Step, owner = the Safe, holds no funds): published reviewer list, signer-conflict list, per-token minimum fee. Reviewers join via **RL2**: open off-chain application against published criteria; the Safe lists them (`setReviewer(reviewer, true, metadataURI)`). No on-chain application flow. - Binding unless escalated: the Safe posts the job, then `assignReviewer(jobId, reviewer)` (payable, Safe only, job `Open`) escrows the reviewer fee on top of the bounty. After delivery the reviewer calls `submitRecommendation`; the Safe can `executeRecommendation` at once, anyone after `OBJECTION_WINDOW` (5 days, fixed constant). `acceptDelivery` and settlement offers revert `ReviewJob()` on review jobs. - **Reviewer fee escrowed until resolution:** paid to the reviewer on `executeRecommendation`, or when the Kleros ruling gives exactly the recommended split (on ruling 0, refuse or tie paid 50/50, that means a 50% recommendation); refunded to the customer (`j.customer`, the Safe on build tasks) otherwise, including no recommendation, cancel and `refundAfterDeadline` (missed work deadline). Settled inside PayoutLib from job funds, so `rule()` can't revert (tested with a held reviewer). - **No silence payout on review jobs:** `releaseAfterReview` never opens (`reviewEndsAt = max`). A missed deadline lets the Safe `reassignReviewer` (max 2). Once the limit is used and the last reviewer misses its deadline, `reviewLapsed(jobId)` is true and only Kleros can end the job. Nobody has a duty to escalate: the builder files whenever it wants, and so can the customer; funds stay in escrow until someone files. - **Escalation:** `requestArbitration` does not require `reviewLapsed`. Either party can escalate any time after delivery, with or without a recommendation, until the recommendation is executed (usual ETH prepay; on ERC-20 jobs the filer bears it). - Signer-conflict gate in `acceptBid` on every Safe-funded job: builder can't be the reviewer (`BadReviewer`) or conflicted (`Conflicted(builder)`). - OFAC: a held reviewer can't be assigned; credits to held parties stay frozen. - Settlement core in external library `PayoutLib`, review bookkeeping in `ReviewLib`. No new `Status` values; `WorkHistory.Outcome.Reviewed` (5). ## Interface - Registry: `setReviewer(address, bool listed, string metadataURI)`, `setConflicted(address, bool, string reasonURI)`, `setMinReviewerFee(address token, uint256)`, views `reviewerFee(token, bounty)`, `canReview`, `isConflicted`. - Market: `assignReviewer(jobId, reviewer)`, `submitRecommendation(jobId, uint8 builderPct, bytes32 noteHash, string noteURI)` (`builderPct ∈ {0,25,50,75,100}`, before `reviewDeadline(jobId) = max(deliveredAt, assignedAt) + reviewPeriod`), `executeRecommendation(jobId)`, `reassignReviewer(jobId, newReviewer)`, views `reviews(jobId)`, `reviewDeadline`, `reviewEndsAt`, `reviewLapsed`, constants `OBJECTION_WINDOW` (5 days), `MAX_REVIEWER_REASSIGNMENTS` (2). - Constructor: `ReviewerRegistry reviewerRegistry_` after `workHistory` (`address(0)` disables review jobs). - Errors: `ReviewJob`, `NotReviewer`, `BadReviewer`, `Conflicted(address)`, `ReviewWindowClosed`. ## DECIDED - 2026-11-09: one reviewer per task from a published list; reviewer fee 5% of the task budget with a $50 minimum (per-token, e.g. USDC 50e6). - 2026-11-10: objection window 5 days; at most 2 reassignments; conflict check on every Safe-funded job; no silence payout, a lapsed review goes to Kleros; reviewer fee refunded to the customer if Kleros overrules; reviewers join via RL2. - 2026-11-10 (George, 11:33 AM CT): - Lapsed review: no Safe duty to escalate. The builder files with Kleros whenever it wants; the customer can too. Funds stay in escrow until someone files. - Prepay: existing rules. On ERC-20 jobs a builder who files bears the Kleros prepay; the Safe doesn't repay it. - Ruling 0 (refuse or tie, 50/50): the reviewer is paid if it recommended 50%; otherwise the fee goes back to the customer (code change in `PayoutLib`; `rule()` still can't revert). ## PROVISIONAL (George decision pending) - Recommended splits return both deposits; review jobs pay the normal protocol fee; `postJob` without a reviewer stays allowed for the Safe. ## Tests and coverage - `forge test`: 171 passed, 0 failed (`test/CompletionReview.t.sol` 34 test functions, incl. no-show → Kleros, builder backstop after 2 years with the ERC-20 prepay borne by the builder, fee paid/refunded on agree/overrule fuzz over all rulings, ruling 0 with a 50% recommendation (paid) and a 75% recommendation (refunded), held reviewer, fixed objection window, credit reasons). - Coverage (earlier Nov 10 run, not re-run for the 11:33 change): TaskulerMarket 99.75% lines, 98.00% branches; PayoutLib, ReviewLib, ReviewerRegistry 100%. - TaskulerMarket runtime 22,620 B (limit 24,576). Slither: 35 results, all triaged. ## Indexer events / ABI - `ReviewerAssigned(uint256 indexed jobId, address indexed reviewer, uint256 fee, uint8 reassignment)` - `RecommendationSubmitted(uint256 indexed jobId, address indexed reviewer, uint8 builderPct, uint64 objectionEndsAt, bytes32 noteHash, string noteURI)` (`objectionEndsAt` = recommendedAt + 5 days) - **New:** `ReviewerFeeSettled(uint256 indexed jobId, address indexed to, uint256 amount, bool paidToReviewer)` - **Changed:** `Credited(address indexed account, address indexed token, uint256 amount, uint256 indexed jobId, uint8 reason)` (new topic hash). `reason` (`CreditReason`): 0 Payout, 1 Refund, 2 DepositReturn, 3 DepositForfeit, 4 ProtocolFee, 5 ReviewerFee, 6 ReviewerFeeRefund, 7 ArbitrationRefund (excess prepay), 8 ArbitrationReimbursement. Resolutions emit one `Credited` per component; per-account totals unchanged. - Registry: `ReviewerSet(address indexed reviewer, bool listed, string metadataURI)`, `ConflictSet(address indexed account, bool conflicted, string reasonURI)`, `MinReviewerFeeSet(address indexed token, uint256 minReviewerFee)`. - WorkHistory: outcome `Reviewed` (5). ## Changelog 2026-11-10 - Removed silence-pays-builder on review jobs; added `reviewLapsed`; lapsed reviews go to Kleros. - Reviewer fee no longer credited on submission; escrowed and settled at resolution (`ReviewerFeeSettled`). - `OBJECTION_WINDOW = 5 days` constant (no longer tied to the settable `settlementWindow`). - `Credited` gained `uint8 reason` (own commit); PayoutLib credits per component. Market +309 B for this. - RL2 documented in the registry NatSpec; decided items moved from PROVISIONAL to DECIDED. - 11:33 AM CT update: ruling 0 now pays a reviewer who recommended 50% (PayoutLib); lapse escalation duty and builder prepay marked DECIDED (no Safe duty; filing builder bears the ERC-20 prepay); wording fixed (fee refund goes to the customer; `requestArbitration` doesn't require `reviewLapsed`; `refundAfterDeadline` (missed work deadline)). No ABI change.
- ReviewerRegistry: published reviewer list (metadata URI), signer-conflict list, per-token min reviewer fee; fee = max(5% bounty, min)
- Market: assignReviewer (Safe, Open job, escrows fee), submitRecommendation (reviewer, before reviewDeadline, paid on submit),
  executeRecommendation (Safe at once / anyone after objection window), reassignReviewer (after missed deadline, max 2)
- binding: no acceptDelivery/settlements on review jobs; either party can still requestArbitration (same ETH prepay)
- silence pays builder only after 2x reviewPeriod with no recommendation; unearned fee refunded to the Safe
- conflict gate: conflicted builder can't be accepted on any Safe-customer job; reviewer can't be builder
- WorkHistory.Outcome.Reviewed; PayoutLib (final split) + ReviewLib extracted as external libraries: Market 22.4 KB
- tests: CompletionReview.t.sol (27), invariant handler drives CR2 lifecycles; docs + deploy script updated
Taskuler-bot changed target branch from feat/ofac-payout-hold to main 2026-11-11 03:45:17 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
taskuler/contracts!5
No description provided.