ProgramGen / tasks /data /reverse /abdelstark__guts.8876fcf /environment /docs /004-collaboration-data-model.md
Conghao97's picture tcftrees's picture
ProgramGen release
d086025
|
Raw History Blame Contribute Delete
2.55 kB

ADR-004: Collaboration Data Model

Status

Accepted

Date

2025-12-20

Context

Guts needs to support GitHub-style collaboration features:

  • Pull Requests with merge workflows
  • Issues with labels and state management
  • Comments on PRs, issues, and code
  • Code reviews with approvals

These features must work in a decentralized environment where:

  • Multiple nodes may receive updates concurrently
  • State must eventually converge across nodes
  • Operations must be cryptographically attributable

Decision

We implement collaboration features in guts-collaboration crate with the following data model:

Core Types

State Machines

Storage Layer

Consequences

Positive

  • Familiar model: Matches GitHub/GitLab mental model
  • Rich workflows: Supports review cycles and merge requirements
  • Auditable: All actions have author attribution
  • Extensible: Labels, assignments can be added later

Negative

  • Eventual consistency: Concurrent updates may need conflict resolution
  • State management: Complex state machines to maintain
  • Storage growth: Comments and reviews can be voluminous

Neutral

  • Sequential numbering requires coordination
  • Cross-repository references need consideration

Design Decisions

UUIDs + Sequential Numbers

We use both:

  • UUID: Globally unique identifier for referencing
  • Number: Human-friendly sequential ID (like GitHub's #123)

The sequential number is assigned during creation and provides a user-friendly reference within a repository.

Soft State vs Hard State

  • Soft state (can be recomputed): PR mergability, review summary
  • Hard state (must be stored): Comments, reviews, core PR data

Replication Strategy

Collaboration data replicates via the P2P layer using:

  • Create/update messages broadcast to all nodes
  • Eventual consistency with last-write-wins for conflicts
  • Logical clocks for ordering (future enhancement)

Alternatives Considered

CRDT-based Model

Use Conflict-free Replicated Data Types for all collaboration.

Deferred because:

  • Increased complexity
  • Standard model sufficient for MVP
  • Can migrate later if needed

Append-only Log

Store only operations, compute state on read.

Rejected because:

  • Read performance concerns
  • Snapshot management complexity
  • Harder to query

References