Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions PROJECTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Mind>/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-<resource ID>` disclosure while retaining source/published links.
Publish the owner-board changes before publishing the new Scientist links.
5 changes: 5 additions & 0 deletions scripts/organism_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down
27 changes: 26 additions & 1 deletion scripts/project_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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())


Expand Down Expand Up @@ -214,3 +224,18 @@ def render_html(snapshot: dict) -> str:
return f'''<section id="projects" aria-labelledby="projects-heading"><h2 id="projects-heading">Projects</h2>
<p>Connected resources. Follow the source links for current records; listed resources do not establish quality or readiness.</p>
{empty}<div class="organ-grid" aria-label="Project resources">{''.join(cards)}</div></section>'''


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())}
32 changes: 32 additions & 0 deletions tests/test_project_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<h2 id="projects-heading">Projects</h2>') < page.index('<h2 id="dashboards-heading">Dashboards</h2>') < 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
Loading