Show which exercises differ from their last published release.
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Failing after 30s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 17s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s

The release tab names the changed areas, and an admin list collects those exercises so a new release stays a deliberate publication.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-23 14:56:15 +01:00
1 parent 4b33b17b2d
commit 4ad62b6e38
14 files changed
+305 -6

No files matched your search

+65
View File
@@ -410,6 +410,71 @@ def _duration_note(exercise: dict) -> Optional[str]:
return None
def _manifest_part_text(manifest: dict, role: str) -> str:
parts = ((manifest.get("exercise") or {}).get("parts") or [])
return "\n".join((part.get("text") or "").strip() for part in parts if part.get("role") == role).strip()
def _instruction_texts(exercise: dict, variants: list[dict]) -> list[str]:
texts = []
base = plaintext(exercise.get("execution"))
if variants:
for variant in variants:
extra = plaintext(variant.get("execution_changes"))
combined = "\n".join(piece for piece in (base, extra) if piece)
if combined:
texts.append(combined)
elif base:
texts.append(base)
return texts
def changed_areas(exercise: dict, variants: list[dict], media: list[dict], manifest: dict) -> list[str]:
"""Benannte Abweichungen der Arbeitsfassung vom gespeicherten Release-Manifest."""
body = manifest.get("exercise") or {}
areas: list[str] = []
if (exercise.get("title") or "") != (body.get("title") or ""):
areas.append("Titel")
if (plaintext(exercise.get("summary")) or "") != (body.get("summary") or ""):
areas.append("Kurztext")
for role, label, current in (
("goal", "Ziel", plaintext(exercise.get("goal"))),
("preparation", "Vorbereitung", plaintext(exercise.get("preparation"))),
("trainer_notes", "Trainerhinweise", plaintext(exercise.get("trainer_notes"))),
("equipment", "Material", plaintext(_equipment_text(exercise))),
("duration_note", "Dauer", plaintext(_duration_note(exercise))),
):
if (current or "") != _manifest_part_text(manifest, role):
areas.append(label)
released_instructions = sorted(
(part.get("text") or "").strip()
for part in (body.get("parts") or [])
if part.get("role") == "instructions" and (part.get("text") or "").strip()
)
if sorted(_instruction_texts(exercise, variants)) != released_instructions:
areas.append("Durchführung")
released_variants = list(body.get("variants") or [])
if variants:
current_variants = sorted((str(item.get("public_id")), item.get("variant_name") or "") for item in variants)
released_pairs = sorted((str(item.get("id")), item.get("label") or "") for item in released_variants)
if current_variants != released_pairs:
areas.append("Varianten")
elif len(released_variants) != 1:
areas.append("Varianten")
current_by_id = {str(item.get("public_id")): item.get("sha256") or "" for item in media}
released_by_id = {str(item.get("id")): item.get("sha256") or "" for item in (body.get("assets") or [])}
media_changed = set(current_by_id) != set(released_by_id)
if not media_changed:
for key, digest in current_by_id.items():
released_digest = released_by_id.get(key) or ""
if digest and released_digest and digest != released_digest:
media_changed = True
break
if media_changed:
areas.append("Medien")
return areas
def _equipment_text(exercise: dict) -> Optional[str]:
raw = exercise.get("equipment")
if isinstance(raw, str):
+95
View File
@@ -17,6 +17,7 @@ from distribution_contract import (
REASON_CODES,
can_withdraw,
canonical_json,
changed_areas,
collect_blockers,
cut_hash,
decide_confirm,
@@ -415,6 +416,7 @@ def overview(cur, exercise_id: int, profile_id: int, role: str) -> dict:
"release_block": release_block,
"releases": releases,
"keys": keys,
"drift": exercise_release_drift(cur, exercise),
"profile_id": profile_id,
"role": role,
}
@@ -1572,6 +1574,99 @@ def release_keys_for_exercise(cur, exercise: dict, profile_id: int, role: str) -
return keys, None
def _latest_release_row(cur, source_id: str) -> Optional[dict]:
cur.execute(
"""
SELECT r.release_id, r.revision, r.published_at, r.manifest_text, sr.snapshot_hash
FROM distribution_releases r
JOIN distribution_source_revisions sr
ON sr.source_id = r.source_id AND sr.revision = r.revision
WHERE r.source_id = %s
ORDER BY r.revision DESC, r.published_at DESC
LIMIT 1
""",
(str(source_id),),
)
return _one(cur)
def _drift_from_row(exercise: dict, variants: list[dict], media: list[dict], row: dict) -> dict:
published = row.get("published_at")
base = {
"differs": False,
"revision": row.get("revision"),
"release_id": str(row["release_id"]),
"published_at": format_utc(published) if published and not isinstance(published, str) else published,
}
if snapshot_hash(exercise, variants, media) == row.get("snapshot_hash"):
return base
manifest = row.get("manifest_text")
if isinstance(manifest, str):
import json
manifest = json.loads(manifest)
areas = changed_areas(exercise, variants, media, manifest or {})
return {**base, "differs": True, "areas": areas or ["Weitere Angaben"]}
def exercise_release_drift(cur, exercise: dict) -> dict:
row = _latest_release_row(cur, str(exercise["public_id"]))
if not row:
return {"differs": False}
variants = _load_variants(cur, int(exercise["id"]))
media = _load_media(cur, int(exercise["id"]))
return _drift_from_row(exercise, variants, media, row)
def _may_rerelease(cur, exercise: dict, profile_id: int, role: str) -> bool:
vis = (exercise.get("visibility") or "private").strip().lower()
kind = {"official": "platform", "club": "club"}.get(vis, "own")
return _denial_for(cur, exercise, {"kind": kind, "club_id": exercise.get("club_id")}, profile_id, role) is None
def list_release_drift(cur, profile_id: int, role: str) -> list[dict]:
cur.execute(
"""
SELECT DISTINCT ON (e.id)
e.id, e.public_id, e.title, e.summary, e.goal, e.execution, e.preparation,
e.trainer_notes, e.equipment, e.duration_min, e.duration_max, e.status,
e.visibility, e.club_id, e.exercise_kind, e.created_by,
c.name AS club_name,
r.release_id, r.revision, r.published_at, r.manifest_text, sr.snapshot_hash
FROM exercises e
JOIN distribution_releases r ON r.source_id = e.public_id
JOIN distribution_source_revisions sr
ON sr.source_id = r.source_id AND sr.revision = r.revision
LEFT JOIN clubs c ON c.id = e.club_id
ORDER BY e.id, r.revision DESC, r.published_at DESC
"""
)
rows = [r2d(row) for row in _rows(cur)]
items = []
for exercise in rows:
if not _may_rerelease(cur, exercise, profile_id, role):
continue
variants = _load_variants(cur, int(exercise["id"]))
media = _load_media(cur, int(exercise["id"]))
drift = _drift_from_row(exercise, variants, media, exercise)
if not drift["differs"]:
continue
vis = (exercise.get("visibility") or "private").strip().lower()
items.append(
{
"exercise_id": int(exercise["id"]),
"title": exercise.get("title") or "Übung",
"visibility": vis,
"club_name": exercise.get("club_name"),
"revision": drift["revision"],
"published_at": drift["published_at"],
"areas": drift["areas"],
}
)
items.sort(key=lambda item: (item["title"] or "").lower())
return items
def target_for_key(cur, exercise_id: int, key_id: str, profile_id: int, role: str) -> tuple[str, str]:
exercise = _load_exercise(cur, exercise_id)
keys, block = release_keys_for_exercise(cur, exercise, profile_id, role)
+8
View File
@@ -29,6 +29,7 @@ from distribution_service import (
create_named_key,
issue_key,
list_changes,
list_release_drift,
load_asset,
load_availability,
load_manifest,
@@ -500,6 +501,13 @@ def get_backlog(tenant: TenantContext = Depends(get_tenant_context)):
return {"count": backlog_count(cur)}
@editorial.get("/api/distribution/release-updates")
def get_release_updates(tenant: TenantContext = Depends(get_tenant_context)):
with get_db() as conn:
cur = get_cursor(conn)
return {"items": list_release_drift(cur, tenant.profile_id, tenant.global_role or "")}
@editorial.get("/api/distribution/access")
def get_access(tenant: TenantContext = Depends(get_tenant_context)):
with get_db() as conn:
@@ -29,6 +29,7 @@ from distribution_contract import (
official_write_allowed,
plan_available,
rate_decision,
changed_areas,
release_denial,
retrievable_release_ids,
sha256_bytes,
@@ -281,6 +282,35 @@ def test_release_screen_keeps_the_application_key() -> None:
assert [item["label"] for item in keys] == ["Lara"]
def test_changed_areas_names_the_edited_instruction() -> None:
exercise = {
"title": "Stand",
"summary": "",
"goal": "Sehen",
"execution": "Neuer Weg",
"preparation": "",
"trainer_notes": "",
"equipment": None,
"duration_min": None,
"duration_max": None,
}
manifest = {
"exercise": {
"title": "Stand",
"summary": None,
"parts": [
{"role": "goal", "text": "Sehen"},
{"role": "instructions", "text": "Alter Weg"},
],
"variants": [{"id": "v", "label": "Standard"}],
"assets": [],
}
}
assert changed_areas(exercise, [], [], manifest) == ["Durchführung"]
exercise["execution"] = "Alter Weg"
assert changed_areas(exercise, [], [], manifest) == []
def test_channel_sequence_is_locked() -> None:
assert "FOR UPDATE" in inspect.getsource(_lock_recipient)
+9 -2
View File
@@ -1,6 +1,6 @@
# Shinkan Jinkendo Version Information
APP_VERSION = "0.8.255"
APP_VERSION = "0.8.256"
BUILD_DATE = "2026-11-23"
DB_SCHEMA_VERSION = "20261123101"
@@ -39,7 +39,7 @@ MODULE_VERSIONS = {
"skill_profiles": "1.0.0", # Phase 3: gewichtetes Fähigkeiten-Profil + skill-discovery/suggestions
"methods": "0.1.0",
"exercises": "2.38.0", # Globale Übungen schreibt und gibt nur superadmin frei
"distribution": "1.3.1", # Freigabe liest den Schlüssel, bevor weitere Abfragen denselben Cursor benutzen
"distribution": "1.4.0", # Arbeitsfassung gegen letztes Release: Übung und zentrale Abgleichliste
"planning_exercise_suggest": "0.23.8", # Progressionsgraph: Katalog-Kontext (Fokus/Stil/TT/ZG) im Match-Profil
"training_units": "0.4.0", # POST .../publish-to-framework: Ablauf aus geplanter Einheit → Rahmen-Slot-Blueprint
"training_programs": "0.1.0",
@@ -55,6 +55,13 @@ MODULE_VERSIONS = {
}
CHANGELOG = [
{
"version": "0.8.256",
"date": "2026-11-23",
"changes": [
"Die Übungsfreigabe zeigt, wo die Arbeitsfassung vom letzten Release abweicht. Eine Adminseite listet diese Übungen zum gezielten neuen Release.",
],
},
{
"version": "0.8.255",
"date": "2026-11-23",