Selected original test assertions from the extracted agent-work implementation. Synthetic fixtures; source excerpts require the original implementation/test harness to run. # test_store.py :: test_restart_and_replay def test_restart_and_replay(self): self.s.apply(self.batch);self.s.close();self.s=Store(self.path) self.assertTrue(self.s.apply(self.batch)['replayed']);self.assertEqual(len(self.s.snapshot()['items']),2) # test_store.py :: test_stale_correction_preserves_history def test_stale_correction_preserves_history(self): self.s.apply(self.batch);self.s.correct('i1',1,{'title':'Prove capture'},'Better title','r1') with self.assertRaises(Conflict):self.s.correct('i1',1,{'title':'Overwritten'},'Stale edit','r2') state=self.s.snapshot();self.assertEqual(state['items'][0]['title'],'Prove capture');self.assertEqual(len(state['events']),3) self.assertTrue(self.s.correct('i1',1,{'title':'Prove capture'},'Better title','r1')['replayed']) # test_store.py :: test_failed_quote_rolls_back_whole_batch def test_failed_quote_rolls_back_whole_batch(self): self.batch['items'][1]['evidence'][0]['quote']='Invented deadline tomorrow' with self.assertRaises(ValueError):self.s.apply(self.batch) self.assertEqual(self.s.snapshot()['sources'],[]);self.assertEqual(self.s.snapshot()['items'],[]) # test_private_mcp.py :: test_cloud_excludes_host_access_but_shares_store def test_cloud_excludes_host_access_but_shares_store(self): with tempfile.TemporaryDirectory() as d: db=Path(d)/'data.sqlite';s=Store(db);s.close() local=Server(ROOT,db);remote=Server(ROOT,db,cloud=True) names={t['name'] for t in remote.handle({'method':'tools/list'})['tools']} self.assertFalse(names & LOCAL_ONLY_TOOLS) for name in LOCAL_ONLY_TOOLS: with self.assertRaises(ValueError):remote.call(name,{}) remote.call('capture_note',{'id':'shared-proof','text':'Fictional shared-store connection test'}) state=local.call('read_workspace',{})['structuredContent']['state'] self.assertTrue(any(s['id']=='shared-proof' for s in state['sources'])) self.assertIn('save_record',names);self.assertIn('patch_table',names) # test_hosted_mcp.py :: test_no_access_without_auth_and_no_cross_origin def test_no_access_without_auth_and_no_cross_origin(self): self.assertEqual(self.request('post','/mcp',json={}).status_code,401) r = self.request('post','/mcp',headers={'Origin':'https://evil.example'},json={}) self.assertEqual(r.status_code,403) self.assertNotIn('owner_key',self.request('get','/.well-known/oauth-authorization-server').text) # test_hosted_mcp.py :: test_task_status_http_contract_readback_replay_and_noop def test_task_status_http_contract_readback_replay_and_noop(self): access = self.exchange(self.authorize()).json['access_token'] tools = self.rpc(access, 'tools/list').json['result']['tools'] update_schema = next(t for t in tools if t['name'] == 'update_task')['outputSchema'] wording = 'I will confirm the room, print the checklist and email the invitation.' create = dict(request_id='http-status-create', source_id='http-status-source', user_statement=wording, project_id=None, tasks=[ dict(id='http-room', title='Confirm room', detail='Fictional transport test.', quote='confirm the room'), dict(id='http-checklist', title='Print checklist', detail='Fictional transport test.', quote='print the checklist'), dict(id='http-invitation', title='Email invitation', detail='Fictional transport test.', quote='email the invitation')]) result = self.rpc(access, 'tools/call', dict(name='create_tasks', arguments=create)) self.assertEqual(result.status_code, 200) self.assertNotIn('isError', result.json['result']) for item_id, status, statement in [ ('http-room', 'waiting', 'The room is waiting on the venue manager.'), ('http-checklist', 'canceled', 'I am not printing the checklist anymore.'), ('http-invitation', 'done', 'I emailed the invitation.')]: args = dict(item_id=item_id, version=1, changes={'status': status}, request_id=item_id+'-update', source_id=item_id+'-report', user_statement=statement) response = self.rpc(access, 'tools/call', dict(name='update_task', arguments=args)) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, 'application/json') self.assertNotIn('error', response.json) output = response.json['result'] self.assertNotIn('isError', output) value = output['structuredContent'] self.assertEqual(json.loads(output['content'][0]['text']), value) self.assertLessEqual(set(update_schema['required']), set(value)) self.assertLessEqual(set(value), set(update_schema['properties'])) self.assertEqual((value['id'], value['version']), (item_id, 2)) read = self.rpc(access, 'tools/call', dict(name='read_chat', arguments={'item_ids':[item_id]})).json['result']['structuredContent'] self.assertEqual(len(read['items']), 1) self.assertEqual((read['items'][0]['status'], read['items'][0]['version']), (status, 2)) replay = self.rpc(access, 'tools/call', dict(name='update_task', arguments=args)).json['result']['structuredContent'] self.assertTrue(replay['replayed']) unchanged = dict(args, version=2, request_id=item_id+'-repeat', source_id=item_id+'-repeat-report') noop = self.rpc(access, 'tools/call', dict(name='update_task', arguments=unchanged)).json['result']['structuredContent'] self.assertEqual((noop['unchanged'], noop['version']), (True, 2)) reread = self.rpc(access, 'tools/call', dict(name='read_chat', arguments={'item_ids':[item_id]})).json['result']['structuredContent'] self.assertEqual(reread['items'], read['items'])