MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / main

Function main

tests/harness/native_review_insert_test.py:90–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89
90def main():
91 call('identity', 'new', 'native-author', '--set-default')
92 call('identity', 'new', 'native-reviewer')
93 call('init')
94 check('native review fixture has no Git repository', not (ROOT / '.git').exists())
95 work_id, work_uid = new_intent('Native originals fixture')
96 call('intent', 'update', work_id, '--body', work_body(work_uid, False), '--force')
97 call('intent', 'attest', work_id, '--identity', 'native-author')
98 call('add', '.vault')
99 record('record work explanation on shared baseline')
100 call('view', 'create', 'agent', '--draft', '--parent', 'dev', '--switch')
101 (ROOT / 'src').mkdir()
102 (ROOT / 'src/one.rs').write_bytes(b'fn one() {}\n')
103 call('add', 'src/one.rs')
104 record('original one')
105 first = history('agent')[0]['hash']
106 (ROOT / 'src/one.rs').write_bytes(b'fn one() { two(); }\n')
107 (ROOT / 'src/two.rs').write_bytes(b'fn two() {}\n')
108 call('add', 'src/two.rs')
109 record('original two depends on one')
110 second = history('agent')[0]['hash']
111 check('two distinct original code identities recorded', first != second)
112 original = data('change', second, '--format', 'json')
113 check('second original retains dependency on first', first in original['dependencies'])
114 before_review = report()
115 check('unmet and unreviewed work is blocked in triage', before_review['verdict'] == 'blocked')
116 check('triage names both original records', {first, second} <= set(before_review['inputs']['candidate_changes']))
117
118 check('work bytes satisfy the fixture before completion',
119 (ROOT / 'src/one.rs').read_bytes() == b'fn one() { two(); }\n' and
120 (ROOT / 'src/two.rs').read_bytes() == b'fn two() {}\n')
121 complete_intent(work_id, work_body(work_uid, True), 'native-author')
122 self_id, self_uid = new_intent('Self-review negative fixture', work_uid)
123 complete_intent(self_id, review_body(self_uid, work_uid, 'native-author'), 'native-author')
124 self_report = report()
125 check('self-authored review does not satisfy independent-review readiness', any(
126 finding['code'] == 'UNREVIEWED_CHANGE' and finding['severity'] == 'block'
127 for finding in self_report['findings']))
128 call('identity', 'default', 'native-reviewer')
129 independent_id, independent_uid = new_intent('Independent fixture review', work_uid)
130 complete_intent(independent_id, review_body(independent_uid, work_uid, 'native-reviewer'), 'native-reviewer')
131 call('add', '.vault')
132 record('retain signed work and review evidence')
133 ready = report()
134 check('independently reviewed work is ready for native insertion', ready['verdict'] == 'ready')
135 check('independent review clears the review finding', not any(f['code'] == 'UNREVIEWED_CHANGE' for f in ready['findings']))
136 check('review report retains both original code identities', {first, second} <= set(ready['inputs']['candidate_changes']))
137 source_history = history('agent')
138 target_before_preview = history('dev')
139 source_hashes = {row['hash'] for row in source_history}
140 # Pin both histories immediately before preview; code originals must
141 # still be absent from the target until explicit insertion.
142 baseline_hashes = {row['hash'] for row in target_before_preview}
143 check('code originals remain Draft-only before insertion', not ({first, second} & baseline_hashes))
144 candidate_hashes = source_hashes - baseline_hashes
145 object_bytes = {str(path): path.read_bytes() for path in (ROOT / '.atomic/changes').rglob('*.change')}
146 before_files = files_under(ROOT)
147 before_ops = data('op', 'log', '--json')

Callers 1

Calls 15

callFunction · 0.90
checkFunction · 0.90
recordFunction · 0.90
dataFunction · 0.90
files_underFunction · 0.90
viewFunction · 0.90
new_intentFunction · 0.85
work_bodyFunction · 0.85
setFunction · 0.85
complete_intentFunction · 0.85
review_bodyFunction · 0.85
historyFunction · 0.70

Tested by

no test coverage detected