feat(semantics): version scene edits and refine paint geometry

This commit is contained in:
DCCONSTRUCTIONS
2026-11-04 00:42:55 +03:00
parent 7a3c3c00b3
commit b7b5ac9cf0
34 changed files with 3014 additions and 138 deletions
+52
View File
@@ -160,3 +160,55 @@ def test_save_and_worker_receipt_run_outside_the_event_loop(tmp_path, monkeypatc
response = client.post(path, json={})
assert response.status_code == 200
assert response.json()["thread"] != event_loop
def test_http_representation_selection_and_pinned_manual_branch(tmp_path):
import uuid
world, model, maps, store, old_sha = make_setup(tmp_path)
raw, auto = copy.deepcopy(model), copy.deepcopy(model)
raw['semantic_stage'] = 'raw'
auto['semantic_stage'] = 'algorithmic'
published = maps.publish_pair(world, raw, auto)
def invoke(fn, *args):
try:
return fn(*args)
except FileNotFoundError as exc:
raise HTTPException(404) from exc
except ValueError as exc:
raise HTTPException(400, str(exc)) from exc
except RuntimeError as exc:
raise HTTPException(409, str(exc)) from exc
app = FastAPI()
app.include_router(build_semantic_edits_router(
tmp_path, SimpleNamespace(get=lambda _: world, list=lambda: [world]), maps,
invoke, lambda _: None,
))
path = '/worlds/fixture/semantic-edits'
branch = str(uuid.uuid4())
with TestClient(app) as client:
versions = client.get('/worlds/fixture/semantic-versions').json()
assert versions['manual'] == []
assert versions['raw_sha256'] == published['raw_sha256']
observed = client.get(path, params={'source': 'raw'}).json()
assert observed['read_only'] and 'edited' not in observed
assert observed['model'] == raw
assert client.post(path, json={
**change(published['raw_sha256']), 'branch_id': branch,
}).status_code == 400
assert client.get(path, params={'source': 'manual', 'branch_id': branch}).status_code == 404
pinned = client.get(path, params={
'source': 'algorithmic', 'model_sha256': old_sha,
}).json()
assert pinned['model'] == model
saved = client.post(path, json={**change(old_sha), 'branch_id': branch})
assert saved.status_code == 200, saved.text
assert saved.json()['model_sha256'] == old_sha
assert client.get(path, params={
'source': 'manual', 'branch_id': branch,
}).json()['revision'] == saved.json()['revision']
assert client.get(path, params={'source': 'algorithmic'}).json()['model'] == auto
assert len(client.get('/worlds/fixture/semantic-versions').json()['manual']) == 1
assert not store._path(world).exists()