1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// On-disk state for ritalin contracts.
///
/// Layout (relative to current working directory):
/// .ritalin/scope.yaml — human-edited contract (outcome + metadata)
/// .ritalin/obligations.jsonl — append-only obligation ledger
/// .ritalin/evidence.jsonl — append-only evidence ledger (proof of work)
/// .task-incomplete — marker file; presence = "agent must keep working"
///
/// Why JSONL for ledgers? Append-only writes are atomic line-by-line on POSIX,
/// so we never corrupt the ledger even on crash. No locking needed for the
/// single-builder case; multi-writer scenarios should serialize through `gate`.
///
/// Why YAML for scope? Humans (and agents) read and write it directly;
/// JSON's lack of comments makes it hostile to in-line acceptance criteria.
use ;
/// Find the ritalin state directory by walking up from cwd.
/// Returns `.ritalin/` next to the first ancestor that contains it,
/// or `<cwd>/.ritalin/` if no ancestor has one (used by `init`).
/// Returns true if `.ritalin/` exists somewhere up the cwd ancestry.