Swadhin Biswas chore: rename cortexa to contexa globally · 3/6/2026
6f0cfba
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"""Tests for Contexa Python package."""
import pytest
from contexa import GCCWorkspace
@pytest.fixture
def ws(tmp_path):
workspace = GCCWorkspace(str(tmp_path))
workspace.init("Test project roadmap")
return workspace
def test_init_creates_gcc_directory(tmp_path):
ws = GCCWorkspace(str(tmp_path))
ws.init("Test project")
assert (tmp_path / ".GCC" / "main.md").exists()
assert (tmp_path / ".GCC" / "branches" / "main" / "log.md").exists()
assert (tmp_path / ".GCC" / "branches" / "main" / "commit.md").exists()
assert (tmp_path / ".GCC" / "branches" / "main" / "metadata.yaml").exists()
def test_log_ota(ws):
rec = ws.log_ota("saw empty dir", "should read files", "list_files()")
assert rec.step == 1
assert rec.observation == "saw empty dir"
def test_commit(ws):
ws.log_ota("obs", "thought", "action")
commit = ws.commit("Initial scaffold done")
assert commit.this_commit_contribution == "Initial scaffold done"
assert commit.branch_name == "main"
assert len(commit.commit_id) == 8
def test_branch_creates_isolated_workspace(ws):
ws.branch("experiment-a", "Try alternative algorithm")
assert ws.current_branch == "experiment-a"
branches = ws.list_branches()
assert "main" in branches
assert "experiment-a" in branches
def test_branch_has_fresh_ota_log(ws):
ws.log_ota("main obs", "main thought", "main action")
ws.branch("clean-branch", "Fresh start")
ota = ws._read_ota("clean-branch")
assert ota == []
def test_merge_integrates_branch(ws):
ws.commit("Main first commit")
ws.branch("feature", "Add feature X")
ws.log_ota("feature obs", "feature thought", "feature action")
ws.commit("Feature X implemented")
merge_commit = ws.merge("feature", target="main")
assert "feature" in merge_commit.this_commit_contribution.lower()
assert ws.current_branch == "main"
def test_context_k1_returns_last_commit(ws):
ws.commit("First commit")
ws.commit("Second commit")
ws.commit("Third commit")
ctx = ws.context(k=1)
assert len(ctx.commits) == 1
assert ctx.commits[0].this_commit_contribution == "Third commit"
def test_context_k3_returns_last_three(ws):
ws.commit("C1")
ws.commit("C2")
ws.commit("C3")
ws.commit("C4")
ctx = ws.context(k=3)
assert len(ctx.commits) == 3
def test_context_includes_roadmap(ws):
ctx = ws.context()
assert "Test project roadmap" in ctx.main_roadmap
def test_branch_metadata_records_purpose(ws):
ws.branch("jwt-branch", "Test JWT auth approach")
from contexa.models import BranchMetadata
meta_text = ws._read(ws._meta_path("jwt-branch"))
meta = BranchMetadata.from_yaml(meta_text)
assert meta.purpose == "Test JWT auth approach"
assert meta.created_from == "main"
assert meta.status == "active"
def test_merge_marks_branch_as_merged(ws):
ws.branch("to-merge", "Will be merged")
ws.commit("Branch work done")
ws.merge("to-merge", target="main")
from contexa.models import BranchMetadata
meta_text = ws._read(ws._meta_path("to-merge"))
meta = BranchMetadata.from_yaml(meta_text)
assert meta.status == "merged"
assert meta.merged_into == "main"
def test_switch_branch(ws):
ws.branch("b1", "Branch one")
ws.switch_branch("main")
assert ws.current_branch == "main"
def test_ota_step_increments(ws):
r1 = ws.log_ota("o1", "t1", "a1")
r2 = ws.log_ota("o2", "t2", "a2")
r3 = ws.log_ota("o3", "t3", "a3")
assert r1.step == 1
assert r2.step == 2
assert r3.step == 3