Thesis
Glyph should assume many humans and agents can work on the same project at the same time. Concurrency should not be modeled as branches fighting for control of a filesystem. It should be modeled as isolated work contexts over a shared source graph, coordinated through leases, snapshots, dependency edges, conflict detection, review, and explicit publication.Problem
Agent-native development makes parallel work normal:- Several agents may edit different parts of the project at once.
- A human may review one workspace while another agent continues work elsewhere.
- Two agents may accidentally attempt the same task.
- Long-running work may become stale after the destination realm changes.
- A crashed agent may leave a workspace claimed but inactive.
- Publication order can matter when changes depend on each other.
Goals
- Allow many active work contexts over the same base realm.
- Avoid global editing locks for ordinary source changes.
- Prevent accidental concurrent mutation of the same work context.
- Detect stale, dependent, superseded, and conflicting work.
- Make agent activity observable without requiring trust in the agent.
- Keep publication explicit and policy-checked.
- Preserve enough history to explain concurrent decisions later.
Non-Goals
- Building real-time collaborative editing in the first prototype.
- Silently resolving all conflicts.
- Requiring a central hosted coordinator for local concurrency.
- Making every active workspace visible to every user or agent.
- Treating Git branches as the concurrency primitive.
Core Concepts
Work Context Isolation
Each human or agent task should normally use its own work context. A work context has:- A stable ID and name
- Owner identity
- Optional agent identity
- Base realm and base snapshot
- Writable overlay
- Materialized workspace path, if any
- Claim or lease state
- Snapshot history
- Publication requests
Claim
A claim records which actor is actively driving a work context. Fields:- Work context ID
- Actor identity
- Provider
- Session ID
- Claimed at
- Last heartbeat
- Expiration time
- Claim mode
exclusive: one actor is expected to write the context.shared-read: other actors may inspect but not write.handoff: a new actor is taking over an inactive or explicitly transferred context.
Heartbeat
A heartbeat updates liveness for a claimed work context. Agents should heartbeat during long tasks. Missing heartbeats mark the claim as stale after a policy-defined timeout. Stale claims may be taken over through explicit handoff.Base Snapshot
Every work context records the realm state it started from. Publication compares the work context against:- Its base snapshot
- The current destination realm
- Other active or pending publication requests when policy requires it
Dependency Edge
A dependency edge says one work context should be evaluated after another. Dependencies can model:- Stacked work
- Agent subtasks
- A refactor that must land before a feature
- A security fix that must precede public cleanup
Conflict
A conflict is an incompatible concurrent change. Conflict types include:- Same source object changed differently
- Path rename/delete/edit collision
- Generated artifact divergence
- Policy object conflict
- Realm visibility conflict
- External mount conflict
- Remote publication conflict
Workspace States
Concurrent work should use clear states:active: work is being edited or observed.idle: no recent heartbeat, but not stale.stale: base realm or claim liveness is outdated.ready: work has a publication request or review-ready checkpoint.blocked: policy, dependency, check, or conflict prevents publication.conflicted: incompatible concurrent change detected.superseded: another work context made this one obsolete.published: work was integrated into a destination realm.discarded: work was intentionally abandoned but retained by policy.pruned: active projection was removed; retained history remains.
Concurrency Model
Glyph should use optimistic concurrency for ordinary source edits. Rules:- Active work contexts do not block each other by default.
- SQLite serializes local store writes.
- Materialized workspaces are isolated per work context.
- Writes to the same work context require a valid claim unless policy allows shared editing.
- Publication checks whether the destination realm changed since the base snapshot.
- If the destination changed, Glyph computes whether the work is clean, stale, dependent, superseded, or conflicted.
- Conflicted publication is blocked until explicitly resolved.
- Stale but non-conflicting work may be rebased by projection, published with a dependency, or reviewed as-is according to policy.
Agent Coordination
Agents should identify themselves with provider-scoped identities such as:agent:codex:session-01agent:claude-code:session-02agent:cursor:session-03
- Work context claimed
- Files read
- Files written
- Commands requested
- Snapshots created
- Heartbeats
- Policy denials
- Publication requests
Conflict Detection
The first prototype should use conservative detection:- Compare changed path and source object sets against the destination realm delta since base.
- If both sides changed the same source object to different content hashes, mark a content conflict.
- If one side deleted or renamed a path and the other edited it, mark a path conflict.
- If policy or visibility labels changed in incompatible ways, mark a policy or visibility conflict.
- If changes are identical, mark duplicate/no-op rather than conflicted.
- If changes touch disjoint paths and no policy relationship is affected, mark clean.
CLI Surface
Prototype commands:Store Requirements
The local store should record:- Work context base snapshot
- Claim records
- Heartbeat timestamps
- Dependency edges
- Conflict records
- Publication ordering decisions
- Supersession links
- Prune events
Policy Requirements
Policy decides:- Who can claim a work context
- Whether claims are exclusive or shared
- Claim timeout duration
- Who can take over stale work
- Whether stale work may publish
- Whether conflicts can be resolved by agents
- Which work contexts are visible to which actors
- Retention and pruning rules for stale, discarded, superseded, and published work
Prototype Defaults
- One writer claim per work context.
- Claims default to exclusive.
- Claim timeout defaults to 15 minutes without heartbeat for agent sessions.
- Humans can override stale agent claims in local bootstrap mode.
- Publication uses optimistic concurrency checks.
- Conflicts block publication.
- Disjoint path changes can publish independently.
- Dependency edges affect publication ordering but do not merge work.
- Pruning stale projections is explicit in v1.
Success Criteria
This spec is successful if a prototype can:- Create two active work contexts from the same realm.
- Claim each work context for a different agent identity.
- Record heartbeats and mark inactive claims stale.
- Detect disjoint changes as clean parallel work.
- Detect same-file divergent changes as conflicts.
- Block publication on unresolved conflicts.
- Represent dependency ordering between two work contexts.
- Publish clean work without blocking unrelated active work.
- Prune stale or completed workspace projections without deleting retained history.