From f38542bf3862d8c3097afbe2d04dc9c9ad42cdc9 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 11 Oct 2026 18:41:42 +0100 Subject: [PATCH] Export public resources and link to owner-board dropdowns --- PROJECTS.md | 13 +++++++++++++ scripts/organism_board.py | 5 +++++ scripts/project_resources.py | 27 ++++++++++++++++++++++++++- tests/test_project_resources.py | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/PROJECTS.md b/PROJECTS.md index 083905f..d8eae03 100644 --- a/PROJECTS.md +++ b/PROJECTS.md @@ -129,3 +129,16 @@ their ordinary category row. No private dashboard name or URL enters the snapsho Old schema-version-1 configurations continue to work without `routes`; generic `records` remains supported for existing instances, but this instance no longer uses the generic Organ records row or the shared assistant evidence inventory. + +## Public owner-board catalogue + +`organism_board.py --catalogue --repos /repos.yaml` exports only public +resources referenced by public projects, deduplicated by stable resource ID. +It collects no organ feeds. Heart and Broca keep reviewed copies as resources.json +for offline rendering. Regenerate these projections when relationships change; +never hand-maintain a second identity or relationship map. The catalogue carries +no evidence timestamp: inventory refresh is not evidence collection. + +Tests and communication resources link to their owning board's +`#resource-` disclosure while retaining source/published links. +Publish the owner-board changes before publishing the new Scientist links. diff --git a/scripts/organism_board.py b/scripts/organism_board.py index d3faf4a..6774a8c 100644 --- a/scripts/organism_board.py +++ b/scripts/organism_board.py @@ -365,6 +365,7 @@ def main(argv: list[str] | None = None) -> int: g.add_argument("--html", action="store_true") g.add_argument("--badge", action="store_true") g.add_argument("--json", action="store_true") + g.add_argument("--catalogue", action="store_true", help="export public resource relationships offline; no feed collection") ap.add_argument("--instance", type=Path, help="opt-in instance profile; selects only explicitly connected organs") ap.add_argument("--projects", type=Path, help="instance-owned project/resource configuration") @@ -397,6 +398,10 @@ def main(argv: list[str] | None = None) -> int: if ns.check_projects or ns.check_instance: print(f"Project configuration valid: {len(projects['projects'])} public projects") return 0 + if ns.catalogue: + from project_resources import catalogue + print(json.dumps(catalogue(projects), indent=2)) + return 0 snap = collect(instance=instance) snap["project_resources"] = projects fmt = "md" diff --git a/scripts/project_resources.py b/scripts/project_resources.py index ea7fa60..dac2676 100644 --- a/scripts/project_resources.py +++ b/scripts/project_resources.py @@ -105,6 +105,8 @@ def resolve(config: dict, body_map: dict) -> dict: if not links: raise ValueError(f"resource {key}: repo or published_url required") resolved[key] = {"id": key, "name": item["name"], "links": links} + if "repo" in item: + resolved[key].update(repo=item["repo"], github=repos[item["repo"]]["github"]) routes = config.get("routes", {}) if not isinstance(routes, dict) or set(routes) - RELATIONS.keys(): @@ -165,7 +167,15 @@ def display_groups(project: dict) -> list[dict]: "url": dashboard["url"] if dashboard else None, "resources": []} row = groups[key] seen = {r["id"] for r in row["resources"]} - row["resources"].extend(r for r in group["resources"] if r["id"] not in seen) + for resource in group["resources"]: + if resource["id"] in seen: + continue + resource = dict(resource, links=list(resource["links"])) + if dashboard and group["relation"] in {"tests", "workspaces", "tutorials", "documentation", "assistants"}: + base = dashboard["url"].split("#", 1)[0] + resource["links"].append({"label": dashboard["name"] + " details", + "url": base + "#resource-" + resource["id"]}) + row["resources"].append(resource) return list(groups.values()) @@ -214,3 +224,18 @@ def render_html(snapshot: dict) -> str: return f'''

Projects

Connected resources. Follow the source links for current records; listed resources do not establish quality or readiness.

{empty}
{''.join(cards)}
''' + + +def catalogue(snapshot: dict) -> dict: + """Public, deduplicated inventory only; no evidence or source-content copy.""" + resources = {} + for project in snapshot.get("projects", []): + for group in project["groups"]: + for resource in group["resources"]: + row = resources.setdefault(resource["id"], dict(resource, projects=[], relations=[])) + context = {"id": project["id"], "name": project["name"]} + if context not in row["projects"]: + row["projects"].append(context) + if group["relation"] not in row["relations"]: + row["relations"].append(group["relation"]) + return {"schema_version": 1, "resources": list(resources.values())} diff --git a/tests/test_project_resources.py b/tests/test_project_resources.py index e669b9d..5b5dbae 100644 --- a/tests/test_project_resources.py +++ b/tests/test_project_resources.py @@ -166,3 +166,35 @@ def test_dashboard_headings_remain_visible_and_separate(inputs): snapshot = {"owner": "Example", "boards": [], "project_resources": pr.resolve(*inputs)} page = ob.render(snapshot, "html") assert page.index('

Projects

') < page.index('

Dashboards

') < page.index('id="dashboards"') + + +def test_catalogue_deduplicates_public_relationships(): + from project_resources import catalogue, resolve + config = {'schema_version': 1, 'resources': { + 'shared': {'name': 'Guide', 'repo': 'guide', 'public': True}, + 'secret': {'name': 'Secret', 'repo': 'guide', 'public': False}}, + 'projects': {key: {'name': key, 'kind': 'scientific_project', 'public': public, + 'resources': {'tutorials': ['shared', 'secret']}} + for key, public in [('one', True), ('two', True), ('private', False)]}} + result = catalogue(resolve(config, {'repos': {'guide': {'github': 'Example/Guide'}}})) + assert len(result['resources']) == 1 + resource = result['resources'][0] + assert resource['repo'] == 'guide' + assert resource['github'] == 'Example/Guide' + assert [p['id'] for p in resource['projects']] == ['one', 'two'] + assert 'Secret' not in str(result) and 'private' not in str(result) + + +def test_owner_deep_links_preserve_sources_and_snapshot(inputs): + config, body_map = inputs + config["resources"]["communication"] = { + "name": "Broca", "public": True, "published_url": "https://example.org/broca/"} + config["routes"] = {"documentation": "communication"} + snapshot = pr.resolve(config, body_map) + before = copy.deepcopy(snapshot) + rows = pr.display_groups(snapshot["projects"][0]) + docs = next(row for row in rows if row["label"] == "Broca")["resources"][0] + assert {link["url"] for link in docs["links"]} == { + "https://docs.example.org/", "https://example.org/broca/#resource-docs", + "https://github.com/OtherLab/renamed-code/tree/release%2F1/guide/start%20here.md"} + assert snapshot == before