Context
Parent: #132 (Grove v2 architecture)
Reviews: CEO review (CLEAN), Eng review (CLEAN), Design review (8/10)
PR: #135 (review artifacts)
Problem
The contract schema in contract.ts defines gates, stop conditions, outcome policies, and agent constraints — but createLocalRuntime defaults to parseContract: false, so they're all dormant. enforcing-store.ts only checks rate limits and artifact sizes. contributeOperation validates relation targets and artifact hashes but not scores, gates, or role-kind constraints. Contributions that violate the contract are silently accepted.
Solution
New enforcement-pipeline.ts (decorator pattern wrapping contributeOperation):
grove_contribute → enforcement-pipeline
├─ 1. agentConstraints.allowedKinds check
├─ 2. agentConstraints.requiredArtifacts check
├─ 3. agentConstraints.requiredRelations check
├─ 4. Gate evaluation (metric_improves, has_artifact, has_relation, min_reviews, min_score)
├─ 5. before_contribute hook (existing, blocking)
├─ 6. contributeOperation() (existing store write)
├─ 7. after_contribute hook (existing, flag on failure — not rolled back)
├─ 8. evaluateStopConditions() (existing in lifecycle.ts, just wired in)
├─ 9. Auto outcome derivation → outcomeStore.set()
├─ 10. EventBus publish (best-effort, Phase 3)
└─ 11. Audit log write (best-effort)
~80% is wiring existing code. evaluateStopConditions(), HookRunner, all gate schemas already exist.
Tasks
Key decisions (from reviews)
- Enforcement pipeline lives in new
enforcement-pipeline.ts (decorator pattern, like enforcing-store.ts)
- Hook failures flag metadata, not rolled back (contribution persists)
- First contribution auto-passes gates (establishes baseline)
- Stop evaluation is O(n) — acceptable for v2 scale, incremental deferred to swarm
- GROVE.md in
immutablePaths (agents can't modify their own constraints)
- EventBus publish is best-effort (DAG is truth)
Depends on
Nothing — this is the foundation. All other phases depend on this.
Context
Parent: #132 (Grove v2 architecture)
Reviews: CEO review (CLEAN), Eng review (CLEAN), Design review (8/10)
PR: #135 (review artifacts)
Problem
The contract schema in
contract.tsdefines gates, stop conditions, outcome policies, and agent constraints — butcreateLocalRuntimedefaults toparseContract: false, so they're all dormant.enforcing-store.tsonly checks rate limits and artifact sizes.contributeOperationvalidates relation targets and artifact hashes but not scores, gates, or role-kind constraints. Contributions that violate the contract are silently accepted.Solution
New
enforcement-pipeline.ts(decorator pattern wrappingcontributeOperation):~80% is wiring existing code.
evaluateStopConditions(),HookRunner, all gate schemas already exist.Tasks
parseContract: trueby default inruntime.ts:71enforcement-pipeline.tsas decorator wrappingcontributeOperationcontract.ts:GateSchema)metric_improvesgate (establishes baseline)contract.outcomePolicyevaluateStopConditions()post-contribute (already exists inlifecycle.ts)HookRunnerbefore/after contribute hooksimmutablePaths){ rejected, reason, field, hint }(cherry-pick Define contribution manifest schema #1)grove contract validateCLI command (cherry-pick Define relation schema and semantics #2)grove_contribute --dry-runparameter (cherry-pick Define artifact schema and CAS addressing #3)Key decisions (from reviews)
enforcement-pipeline.ts(decorator pattern, likeenforcing-store.ts)immutablePaths(agents can't modify their own constraints)Depends on
Nothing — this is the foundation. All other phases depend on this.