From 9547e970762280ab0af205e2f99c69d9ed5d92c3 Mon Sep 17 00:00:00 2001 From: Adambomb210 Date: Wed, 25 Nov 2026 11:17:52 -0500 Subject: [PATCH 1/2] Don't name OSPool to members or reviewers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What members and reviewers see now says "partner grant" instead of OSPool: the status badge ("Approved · Partner grant"), the project's grant card, its Slack channel post, the residency line and the review queue. On Help, the two OSPool guides are listed and served to admins only, and the public guides no longer mention it. Admin pages, the audit log's action names and the funder packet keep the name. Co-Authored-By: Claude Opus 5.5 --- docs/SPEC.md | 7 +++- docs/guides/ospool-grants.md | 7 +++- docs/guides/reviewing-and-admin.md | 28 +++++++------- docs/guides/share-with-ospool.md | 2 +- docs/guides/using-krater.md | 6 +-- krater/services/funding_holds.py | 4 +- krater/services/ospool_grants.py | 6 +++ krater/web/help_docs.py | 11 +++++- krater/web/routers/help_pages.py | 23 ++++++++--- krater/web/routers/projects.py | 6 +-- krater/web/templates/_macros.html | 6 +-- krater/web/templates/admin/index.html | 2 +- krater/web/templates/projects/_ospool.html | 14 ++++--- krater/web/templates/projects/detail.html | 8 ++-- krater/web/templates/reviews/queue.html | 6 +-- tests/web/test_help.py | 45 +++++++++++++++++++--- tests/web/test_ospool_grants_web.py | 43 ++++++++++++++++++--- tests/web/test_residency_filter.py | 3 +- 18 files changed, 164 insertions(+), 63 deletions(-) diff --git a/docs/SPEC.md b/docs/SPEC.md index 25668f3e..1de5b45b 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -550,8 +550,11 @@ values the usage at what renting the GPU would have cost. else the catalog). A day keeps the price it was first valued at; a day without a price gets one when Krater has one. An admin changes the GPU or price from the project page (`admin_change_ospool_valuation`), for later days only. OSG doesn't record which GPU a job used, so the value is an estimate, shown as one. -- **Display.** The project shows *Approved · OSPool*. Its page has an OSPool card (totals, worth, the last 30 days - with usage, when it was last read), seen by anyone who can see the project. `/admin` lists every grant. The funder +- **Display.** The project shows *Approved · Partner grant*. Its page has a *Partner grant* card (totals, worth, the + last 30 days with usage, when it was last read), seen by anyone who can see the project. +- **Not named outside admin pages.** What members and reviewers see (the badge, the card, the project's Slack + channel, the residency line, the review queue and the public Help guides) says "partner" and never OSPool or OSG. Admin pages, the audit log, the funder packet and the two OSPool guides on Help + (listed and served to admins only) keep the name. `/admin` lists every grant. The funder packet's *OSPool usage* field (ticked at first) adds the totals and worth for a project with a grant. ## Admin overrides diff --git a/docs/guides/ospool-grants.md b/docs/guides/ospool-grants.md index d08892f7..72965cda 100644 --- a/docs/guides/ospool-grants.md +++ b/docs/guides/ospool-grants.md @@ -10,7 +10,7 @@ accounting shows it. The rules are in [SPEC.md](../SPEC.md) "OSPool grants". `PatchworkLabs_Ganymede01`, with an adult Patchwork staff member as its PI. - The project is approved in Krater. Approving it *awaiting 3rd party review* keeps its budget from being added while you wait for OSPool. -- Every team member is a verified US resident in Weave. The project page's "Not OSPool-ready" line says who isn't. +- Every team member is a verified US resident in Weave. The project page's "Not all US residents" line says who isn't. - The project holds no Krater budget. If it has some, reclaim it first from the Admin card. ## Record the grant @@ -26,7 +26,10 @@ accounting shows it. The rules are in [SPEC.md](../SPEC.md) "OSPool grants". 6. Give a reason and choose **Record OSPool grant**. Krater cancels the project's held budget and clears its funding hold, since the OSPool funds it instead. Nothing goes -to the ledger or Quilt. The project now shows *Approved · OSPool*, and a post in its channel says what you did. +to the ledger or Quilt. The project now shows *Approved · Partner grant*, and a post in its channel says what you did. + +Members and reviewers never see OSPool or OSG named: the badge, the project's card and the channel post all say +"partner grant". Your **reason** goes in the channel as you typed it, so leave the name out of it. ## Read the usage diff --git a/docs/guides/reviewing-and-admin.md b/docs/guides/reviewing-and-admin.md index dad3e863..5a1ab16c 100644 --- a/docs/guides/reviewing-and-admin.md +++ b/docs/guides/reviewing-and-admin.md @@ -15,7 +15,7 @@ Members' side of all this: [Using Krater](using-krater.md) and [Running jobs and - [Admin overrides](#admin-overrides) - [Compute settings](#compute-settings) - [Watching compute](#watching-compute) -- [Funders and OSPool](#funders-and-ospool) +- [Funders](#funders) - [Alerts](#alerts) ## Reviewing @@ -104,7 +104,7 @@ Approve a project before Patchwork can pay for it with **Fund it now?** on the w - **Yes:** the budget is added once the team is verified (the usual case); - **No: approve as awaiting funding**: the money isn't there yet; -- **No: approve as awaiting 3rd party review**: a funder (OSPool, say) has to review it first. +- **No: approve as awaiting 3rd party review**: a funder has to review it first. While a hold is set, the project is approved and reads *Approved · awaiting funding* (or *· awaiting 3rd party review*). Every grant is held, nothing reaches the ledger or Quilt, and no compute starts. Machines already running @@ -137,7 +137,7 @@ nothing else may change the project's budget: no amendment, adjustment or reclai | --- | --- | | Status counts | How many projects are in each status | | **Budget held** | Every held grant: the amount, and who or what it's waiting on | -| **OSPool grants** | Every project with an OSPool grant | +| **Partner grants** | Every project a partner funds outside Krater's budget | | **All projects** | Search by title or the lead's Patchwork ID, filter by status; ceiling, spend and remaining for each | | **Recent activity** | The latest audit events. **All activity** (`/admin/activity`) has the full log, and per project the budget ledger | | **Approval policy** | The policy in force | @@ -145,8 +145,8 @@ nothing else may change the project's budget: no amendment, adjustment or reclai | **Delivery to Quilt** | Whether budget and submission events have reached Quilt, Patchwork's finance system, with retry and dismiss for any it refused | Its other pages: **Live compute** (`/admin/live`, every queued and running job and box), **Images** -(`/admin/images`, every image members used, and inspecting one), **Share with OSPool** (`/admin/funders/ospool`) -and **Compute settings** (`/admin/compute`). +(`/admin/images`, every image members used, and inspecting one), the funder page (a +button at the top of `/admin`) and **Compute settings** (`/admin/compute`). ## Admin overrides @@ -161,7 +161,7 @@ project's Slack channel so reviewers see it. | **Funding hold** | Set, change or clear the project's hold | | **Hourly cap** | The most any one machine of the project may cost per hour, or back to the default ($5) | | **Withdraw project (admin)** | Close it: unspent budget reclaimed, machines destroyed, channels archived a week later | -| **Record an OSPool grant** | See [OSPool grants](ospool-grants.md) | +| **Record a partner grant** | For a project a partner funds instead of Krater's budget. Admins: see the grant guide on Help | **Your own project** (you lead it, are on its team or are invited): you can't decide it, add to its budget, raise its hourly cap or clear its funding hold. Another admin, or the normal review, has to. You can still cut, reclaim or @@ -227,14 +227,14 @@ The page also shows Vast's daily search quota and any hourly spend check that di - **Budgets:** the project's channel is warned at 80% and 95% of the ceiling, and Krater stops the project's machines just before 100%. -## Funders and OSPool +## Funders -- **Share with OSPool** (`/admin/funders/ospool`) lists every project and proposal, newest first, each saying whether - its whole team are verified US residents (OSPool takes only those). Tick the projects and the fields to include, - and download a PDF to send. It never includes emails, Patchwork IDs, demographics or secrets, names members under 18 - as the gallery setting says, asks Weave again on each download, and is audited. -- **OSPool grants** let a project run on the OSPool instead of Krater's budget: [OSPool grants](ospool-grants.md) and - [Share with OSPool](share-with-ospool.md). +- The **funder page** (admins) lists every project and proposal, newest first, each saying whether its whole team + are verified US residents. Tick the projects and the fields to include, and download a PDF to send. It never + includes emails, Patchwork IDs, demographics or secrets, names members under 18 as the gallery setting says, asks + Weave again on each download, and is audited. +- **Partner grants** let a partner fund a project's compute instead of Krater's budget. Signed in as an admin, Help + lists the guides for both. ## Alerts @@ -244,7 +244,7 @@ root cause (a DNS lookup, a connection refused or timed out ...). The Problems c failure of the last 24 hours, kept for 14 days. It covers: - a background task that keeps failing: the compute scheduler, spend reconciliation, cleaning up unfinished uploads, - recording Vast's prices, releasing held grants, syncing admins' SSH keys to boxes, importing OSPool usage, delivery + recording Vast's prices, releasing held grants, syncing admins' SSH keys to boxes, importing partner-grant usage, delivery to Quilt, archiving in Stash, and Slack tasks; - Quilt's outbox backing up; - Stash archive requests backing up; diff --git a/docs/guides/share-with-ospool.md b/docs/guides/share-with-ospool.md index 0ae819c3..4047dc77 100644 --- a/docs/guides/share-with-ospool.md +++ b/docs/guides/share-with-ospool.md @@ -37,6 +37,6 @@ only whether every member is a verified US resident. ## A team isn't OSPool-ready -The project page tells reviewers and admins who on the team isn't a verified US resident (the "Not OSPool-ready" +The project page tells reviewers and admins who on the team isn't a verified US resident (the "Not all US residents" line). Each member does the residency check on Weave's verification page. You can still send the project; the PDF says its team isn't all verified US residents. diff --git a/docs/guides/using-krater.md b/docs/guides/using-krater.md index 3ab65ea1..0cc47215 100644 --- a/docs/guides/using-krater.md +++ b/docs/guides/using-krater.md @@ -40,7 +40,7 @@ You can withdraw a project at any point before it's completed. | **Approved** | You have a budget and can run compute (once your team is verified) | | **Approved · awaiting verification** | Approved, but the budget waits until every team member is verified in Weave | | **Approved · awaiting funding** or **· awaiting 3rd party review** | Approved, but Patchwork can't fund it yet. An admin releases it | -| **Approved · OSPool** | Your compute runs on the OSPool instead of Krater's budget (see [OSPool grants](ospool-grants.md)) | +| **Approved · Partner grant** | A partner funds your compute outside Krater's budget. Krater only shows what you used | | **Pending completion review** | You've submitted your final write-up | | **Completion changes requested** | Reviewers asked for changes to the write-up | | **Completed** | Done. Published in the gallery | @@ -281,8 +281,8 @@ your amount with it. **Can someone outside Patchwork join my team?** They need a Patchwork account first, then you invite them by Patchwork ID. -**Can I use my own computer's GPU or another cloud?** Krater only tracks compute it rents. For OSPool, see -[OSPool grants](ospool-grants.md). +**Can I use my own computer's GPU or another cloud?** Krater only tracks compute it rents, and compute a partner +grant funds. **Who sees my project?** Your team, reviewers and admins while it's in progress. The public sees it only once it's completed, in the gallery. diff --git a/krater/services/funding_holds.py b/krater/services/funding_holds.py index 0794c8ee..40b09553 100644 --- a/krater/services/funding_holds.py +++ b/krater/services/funding_holds.py @@ -69,7 +69,9 @@ def parse(value: str | None) -> FundingHold | None: #: An approved project the OSPool funds outside Krater (`krater.services.ospool_grants`): shown, never a hold. -OSPOOL = "OSPool" +#: Shown on the status badge, which never names the partner (docs/SPEC.md "OSPool grants"). Admins see the name on +#: their own pages (the admin index's grant list, Share with OSPool). +OSPOOL = "Partner grant" def approval_label(project: Project, *, verification_held: bool, ospool: bool = False) -> str | None: diff --git a/krater/services/ospool_grants.py b/krater/services/ospool_grants.py index 7a469cd4..4c7c9111 100644 --- a/krater/services/ospool_grants.py +++ b/krater/services/ospool_grants.py @@ -43,6 +43,10 @@ AUDIT_RECORD = "admin_record_ospool_grant" AUDIT_VALUATION = "admin_change_ospool_valuation" +#: What the project's Slack channel is told for each. Its team reads it, so it never names OSPool (docs/SPEC.md +#: "OSPool grants"). The audit log keeps the actions above. +SLACK_RECORD = "admin_record_partner_grant" +SLACK_VALUATION = "admin_change_partner_grant_valuation" #: `OspoolUsageDay.rate_source` for the grant's own price. SOURCE_ADMIN = "admin" #: How many recent days each import reads again, since OSG corrects them. @@ -411,6 +415,8 @@ def rate_text(grant: OspoolGrant) -> str: __all__ = [ "AUDIT_RECORD", "AUDIT_VALUATION", + "SLACK_RECORD", + "SLACK_VALUATION", "REIMPORT_DAYS", "SOURCE_ADMIN", "Summary", diff --git a/krater/web/help_docs.py b/krater/web/help_docs.py index 6a5d2ded..d8d1c18f 100644 --- a/krater/web/help_docs.py +++ b/krater/web/help_docs.py @@ -29,6 +29,8 @@ class Guide: slug: str summary: str audience: str # "members" or "admins" + #: Listed and served only to admins: the guides that name OSPool (docs/SPEC.md "OSPool grants"). + admins_only: bool = False #: The Help index, in the order shown. @@ -56,8 +58,13 @@ class Guide: "alerts.", "admins", ), - Guide("ospool-grants", "Record a grant that runs on the OSPool, and report what the team used.", "admins"), - Guide("share-with-ospool", "Send OSPool the projects you choose, as a PDF.", "admins"), + Guide( + "ospool-grants", + "Record a grant that runs on the OSPool, and report what the team used.", + "admins", + admins_only=True, + ), + Guide("share-with-ospool", "Send OSPool the projects you choose, as a PDF.", "admins", admins_only=True), Guide( "compute-runbook", "The stop switch, and what to do about each compute alert: spend, unknown charges, credit, storage.", diff --git a/krater/web/routers/help_pages.py b/krater/web/routers/help_pages.py index 9722276c..39327720 100644 --- a/krater/web/routers/help_pages.py +++ b/krater/web/routers/help_pages.py @@ -1,20 +1,31 @@ """Krater's Help pages (`/help`): the guides in docs/guides, rendered. Public, so a member can read them before -signing in or applying.""" +signing in or applying. A guide marked `admins_only` is listed and served only to an admin (others get 404).""" from __future__ import annotations -from fastapi import APIRouter, HTTPException, Request, status +from typing import Annotated + +from fastapi import APIRouter, Depends, HTTPException, Request, status from fastapi.responses import HTMLResponse +from krater.models import User +from krater.services import users as user_service from krater.web import help_docs +from krater.web.deps import current_user from krater.web.templates import templates router = APIRouter() +def _is_admin(user: User | None) -> bool: + # Display only (cached roles), like the top bar: these pages change nothing. + return user is not None and user_service.cached_actor(user).is_admin + + @router.get("/help", response_class=HTMLResponse) -def help_index(request: Request) -> HTMLResponse: - guides = help_docs.index() +def help_index(request: Request, user: Annotated[User | None, Depends(current_user)]) -> HTMLResponse: + is_admin = _is_admin(user) + guides = [g for g in help_docs.index() if is_admin or not g.guide.admins_only] return templates.TemplateResponse( request, "help/index.html", @@ -26,8 +37,8 @@ def help_index(request: Request) -> HTMLResponse: @router.get("/help/{slug}", response_class=HTMLResponse) -def help_guide(request: Request, slug: str) -> HTMLResponse: +def help_guide(request: Request, slug: str, user: Annotated[User | None, Depends(current_user)]) -> HTMLResponse: rendered = help_docs.render(slug) - if rendered is None: + if rendered is None or (rendered.guide.admins_only and not _is_admin(user)): raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not found") return templates.TemplateResponse(request, "help/guide.html", {"rendered": rendered}) diff --git a/krater/web/routers/projects.py b/krater/web/routers/projects.py index 83b77cb4..c416724a 100644 --- a/krater/web/routers/projects.py +++ b/krater/web/routers/projects.py @@ -1330,10 +1330,10 @@ def admin_record_ospool_grant( def _notify() -> None: slack_post_admin_override.defer( project_id=str(project.id), - action=ospool_grants.AUDIT_RECORD, + action=ospool_grants.SLACK_RECORD, actor_sub=actor.user.weave_sub, reason=reason, - extra=f"OSPool project {name}, usage from {since}, valued at {rate_line}.", + extra=f"Partner grant under the project name {name}, usage from {since}, valued at {rate_line}.", ) message = f"OSPool grant recorded. Usage under {name} shows here after the next daily import." @@ -1389,7 +1389,7 @@ def admin_ospool_valuation( def _notify() -> None: slack_post_admin_override.defer( project_id=str(project.id), - action=ospool_grants.AUDIT_VALUATION, + action=ospool_grants.SLACK_VALUATION, actor_sub=actor.user.weave_sub, reason=reason, extra=f"Usage from now on valued at {rate_line}.", diff --git a/krater/web/templates/_macros.html b/krater/web/templates/_macros.html index 61e6c844..782f3b18 100644 --- a/krater/web/templates/_macros.html +++ b/krater/web/templates/_macros.html @@ -1,8 +1,8 @@ {# `hold`: what an approved project waits on (`funding_holds.approval_label`), shown after its status. #} {% macro status_badge(status, hold=none) %} -{%- if hold == "OSPool" -%} -{#- Funded by an OSPool grant (`funding_holds.OSPOOL`): not a hold, so the status's own colour. -#} -{{ status.value.replace('_', ' ') | capitalize }} · OSPool +{%- if hold == "Partner grant" -%} +{#- Funded by a partner (an OSPool grant, `funding_holds.OSPOOL`; not named outside admin pages): not a hold, so the status's own colour. -#} +{{ status.value.replace('_', ' ') | capitalize }} · Partner grant {%- elif hold -%} {{ status.value.replace('_', ' ') | capitalize }} · {{ hold | lower }} {%- else -%} diff --git a/krater/web/templates/admin/index.html b/krater/web/templates/admin/index.html index 27e17af6..a67c6477 100644 --- a/krater/web/templates/admin/index.html +++ b/krater/web/templates/admin/index.html @@ -99,7 +99,7 @@

OSPool grants

{% for grant, totals in ospool %} - {{ grant.project.title or "Untitled proposal" }} + {{ grant.project.title or "Untitled proposal" }} {{ grant.ospool_project_name }} {{ "{:,.1f}".format(totals.gpu_hours) }} {{ "{:,.1f}".format(totals.core_hours) }} diff --git a/krater/web/templates/projects/_ospool.html b/krater/web/templates/projects/_ospool.html index 609f7e97..cf48060f 100644 --- a/krater/web/templates/projects/_ospool.html +++ b/krater/web/templates/projects/_ospool.html @@ -1,10 +1,12 @@ -{# The project's OSPool grant (`krater.services.ospool_grants`): usage from OSG's accounting, valued at rent prices. #} +{# The project's OSPool grant (`krater.services.ospool_grants`): usage from OSG's accounting, valued at rent prices. + The team sees this card, so it says "partner" and never names OSPool or OSG (docs/SPEC.md "OSPool grants"). #} {% set totals = ospool_summary %} -
-

OSPool grant

+
+

Partner grant

- The OSPool funds this project outside Krater. The team runs on the OSPool with its own OSG accounts, under the - OSPool project {{ ospool_grant.ospool_project_name }}. Krater only reports the usage. + A partner funds this project's compute outside Krater's budget. The team runs on the partner's machines with + its own accounts there, under the project name {{ ospool_grant.ospool_project_name }}. Krater only + reports the usage.

GPU-hours
{{ "{:,.1f}".format(totals.gpu_hours) }}
@@ -19,7 +21,7 @@

OSPool grant

{{ "have" if totals.unvalued_days != 1 else "has" }} no price yet, so {{ "they're" if totals.unvalued_days != 1 else "it's" }} left out.{% endif %}

- From OSG's public accounting, which runs about a day behind and corrects recent days. + From the partner's accounting, which runs about a day behind and corrects recent days. {% if ospool_grant.last_imported_at %}Last read {{ ospool_grant.last_imported_at.strftime("%Y-%m-%d %H:%M") }} UTC.{% else %}Not read yet: the first daily import fills this in.{% endif %}

{% if ospool_grant.last_import_error and is_admin %} diff --git a/krater/web/templates/projects/detail.html b/krater/web/templates/projects/detail.html index fa167599..c1dcd79c 100644 --- a/krater/web/templates/projects/detail.html +++ b/krater/web/templates/projects/detail.html @@ -115,14 +115,14 @@

{{ project.title or "Untitled proposal" }} {{ macros.status_badge(project.st {% if show_residency %} {% if team_residency is none %} -

OSPool: Krater couldn't reach Weave to check the team's US residency.

+

Krater couldn't reach Weave to check the team's US residency.

{% elif team_residency.all_residents %}

US residents Every team member is a verified - US resident in Weave, so this project can be sent to OSPool.

+ US resident in Weave.

{% else %}
-

Not OSPool-ready OSPool is open only to US residents. These team - members are not verified US residents in Weave:

+

Not all US residents These team members are not verified US + residents in Weave:

    {% for member in team_residency.others %}
  • {{ member.label }}: {{ member.reason }}
  • diff --git a/krater/web/templates/reviews/queue.html b/krater/web/templates/reviews/queue.html index 15b2b703..57de4762 100644 --- a/krater/web/templates/reviews/queue.html +++ b/krater/web/templates/reviews/queue.html @@ -15,9 +15,9 @@

    Review queue

    Krater couldn't reach Weave to check US residency, so the filter shows nothing. Try again in a minute. Show all {% elif us_residents %} - Showing projects whose whole team is verified US residents (OSPool-ready). Show all + Showing projects whose whole team is verified US residents. Show all {% else %} - Show only projects whose whole team is verified US residents (OSPool) + Show only projects whose whole team is verified US residents {% endif %}

    @@ -48,7 +48,7 @@

    Review queue

    {% if us_residents and approved_residents %}

    Approved projects with a whole team of verified US residents

    -
    +
      {% for project in approved_residents %}
    • diff --git a/tests/web/test_help.py b/tests/web/test_help.py index 43d18260..689b7001 100644 --- a/tests/web/test_help.py +++ b/tests/web/test_help.py @@ -7,7 +7,7 @@ from fastapi.testclient import TestClient from krater.web import help_docs -from tests.conftest import MEMBER_SUB, REVIEWER_SUB +from tests.conftest import ADMIN_SUB, MEMBER_SUB, REVIEWER_SUB _HREF = re.compile(r'href="([^"]+)"') _ID = re.compile(r'id="([^"]+)"') @@ -19,16 +19,47 @@ def _guide_html(client: TestClient, slug: str) -> str: return response.text -def test_the_index_lists_every_guide_without_signing_in(client: TestClient): +_PUBLIC = [guide for guide in help_docs.GUIDES if not guide.admins_only] +_ADMINS_ONLY = [guide for guide in help_docs.GUIDES if guide.admins_only] + + +def test_the_index_lists_every_public_guide_without_signing_in(client: TestClient): response = client.get("/help") assert response.status_code == 200 - for guide in help_docs.GUIDES: + for guide in _PUBLIC: assert f'href="/help/{guide.slug}"' in response.text assert "For reviewers and admins" in response.text -def test_every_guide_renders_with_its_own_title(client: TestClient): +def test_the_ospool_guides_are_for_admins_only(client: TestClient, login_as): + assert {guide.slug for guide in _ADMINS_ONLY} == {"ospool-grants", "share-with-ospool"} + for who in (None, MEMBER_SUB, REVIEWER_SUB): + if who is not None: + login_as(who) + index = client.get("/help").text + assert "OSPool" not in index, who + for guide in _ADMINS_ONLY: + assert f'href="/help/{guide.slug}"' not in index, who + assert client.get(f"/help/{guide.slug}").status_code == 404, who + + login_as(ADMIN_SUB) + index = client.get("/help").text + for guide in _ADMINS_ONLY: + assert f'href="/help/{guide.slug}"' in index + assert client.get(f"/help/{guide.slug}").status_code == 200 + + +def test_no_public_guide_names_ospool(client: TestClient): + for guide in _PUBLIC: + page = _guide_html(client, guide.slug) + assert "OSPool" not in page and "OSG" not in page, guide.slug + for hidden in _ADMINS_ONLY: # a link everyone else would follow to a 404 + assert f'href="/help/{hidden.slug}' not in page, (guide.slug, hidden.slug) + + +def test_every_guide_renders_with_its_own_title(client: TestClient, login_as): + login_as(ADMIN_SUB) # sees the admins-only guides too for guide in help_docs.GUIDES: page = _guide_html(client, guide.slug) rendered = help_docs.render(guide.slug) @@ -42,7 +73,8 @@ def test_an_unknown_guide_is_404(client: TestClient): assert client.get("/help/..%2FSPEC").status_code == 404 -def test_every_link_in_the_guides_goes_somewhere_real(client: TestClient): +def test_every_link_in_the_guides_goes_somewhere_real(client: TestClient, login_as): + login_as(ADMIN_SUB) pages = {guide.slug: _guide_html(client, guide.slug) for guide in help_docs.GUIDES} ids = {slug: set(_ID.findall(page)) for slug, page in pages.items()} for slug, page in pages.items(): @@ -60,7 +92,8 @@ def test_every_link_in_the_guides_goes_somewhere_real(client: TestClient): assert href.startswith(("https://", "http://", "mailto:")), (slug, href) # never a bare .md -def test_a_link_to_another_doc_goes_to_github(client: TestClient): +def test_a_link_to_another_doc_goes_to_github(client: TestClient, login_as): + login_as(ADMIN_SUB) page = _guide_html(client, "ospool-grants") assert 'href="https://github.com/patchworklabsorg/krater/blob/main/docs/SPEC.md' in page diff --git a/tests/web/test_ospool_grants_web.py b/tests/web/test_ospool_grants_web.py index 38a49aa7..7e6b1802 100644 --- a/tests/web/test_ospool_grants_web.py +++ b/tests/web/test_ospool_grants_web.py @@ -73,7 +73,7 @@ def test_an_admin_records_a_grant_and_the_page_reports_it( page = client.get(f"/projects/{project.id}").text assert "OSPool grant recorded." in page - assert "Approved · OSPool" in page + assert "Approved · Partner grant" in page assert NAME in page assert "$9.96" in page # 4 GPU-hours at $2.49 assert "OSPool valuation" in page @@ -81,14 +81,17 @@ def test_an_admin_records_a_grant_and_the_page_reports_it( admin_page = client.get("/admin").text assert "OSPool grants" in admin_page assert NAME in admin_page - assert "Approved · OSPool" in admin_page + assert "Approved · Partner grant" in admin_page login_as(MEMBER_SUB) team_page = client.get(f"/projects/{project.id}").text - assert "OSPool grant" in team_page + assert "Partner grant" in team_page assert "$9.96" in team_page - assert "OSPool valuation" not in team_page - assert "Approved · OSPool" in client.get("/").text + # The team never sees OSPool or OSG named. + assert "OSPool" not in team_page and "OSG" not in team_page + home = client.get("/").text + assert "Approved · Partner grant" in home + assert "OSPool" not in home def test_a_reviewer_cant_record_one(client, login_as, submitted_project, db_session, weave_stub): @@ -207,3 +210,33 @@ def row(usage: str) -> PacketRow: ("Summary", "A rover."), ("OSPool usage", "X1: 1.0 GPU-hours."), ] + + +def test_the_projects_slack_channel_never_names_ospool( + client: TestClient, login_as, submitted_project, db_session: Session, weave_stub, monkeypatch +): + # The team reads the channel. + posts: list[dict] = [] + monkeypatch.setattr( + "krater.web.routers.projects.slack_post_admin_override.defer", lambda **kwargs: posts.append(kwargs) + ) + project = _held(client, login_as, submitted_project, db_session, weave_stub) + login_as(ADMIN_SUB) + assert _record(client, project, rate="2.49").status_code == 303 + grant = db_session.scalar(sa.select(OspoolGrant).where(OspoolGrant.project_id == project.id)) + response = _post( + client, + f"/projects/{project.id}/admin-ospool-valuation", + f"/projects/{project.id}", + gpu_name=grant.gpu_name, + rate="3.00", + rate_note="", + reason="New price.", + ) + assert response.status_code == 303 + + assert [post["action"] for post in posts] == [ospool_grants.SLACK_RECORD, ospool_grants.SLACK_VALUATION] + for post in posts: + assert "ospool" not in f"{post['action']} {post['extra']}".lower() + # The audit log keeps the real action names. + assert db_session.scalar(sa.select(AuditEvent).where(AuditEvent.action == ospool_grants.AUDIT_RECORD)) is not None diff --git a/tests/web/test_residency_filter.py b/tests/web/test_residency_filter.py index a1eff77f..61e92b0e 100644 --- a/tests/web/test_residency_filter.py +++ b/tests/web/test_residency_filter.py @@ -34,8 +34,9 @@ def test_the_project_page_names_who_is_not_a_verified_us_resident( login_as(REVIEWER_SUB) page = client.get(f"/projects/{project.id}").text - assert "Not OSPool-ready" in page + assert "Not all US residents" in page assert MEMBER_SUB in page + assert "OSPool" not in page # reviewers don't see the partner named either def test_a_member_does_not_see_the_residency_line(client: TestClient, login_as, submitted_project) -> None: From 397cd96a99cedefc6347f5f5900d73a7123f6e9d Mon Sep 17 00:00:00 2001 From: Adambomb210 Date: Wed, 25 Nov 2026 11:24:24 -0500 Subject: [PATCH 2/2] test: record the grant with the catalog price in the Slack test Co-Authored-By: Claude Opus 5.5 --- tests/web/test_ospool_grants_web.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/web/test_ospool_grants_web.py b/tests/web/test_ospool_grants_web.py index 7e6b1802..bad773c3 100644 --- a/tests/web/test_ospool_grants_web.py +++ b/tests/web/test_ospool_grants_web.py @@ -222,16 +222,15 @@ def test_the_projects_slack_channel_never_names_ospool( ) project = _held(client, login_as, submitted_project, db_session, weave_stub) login_as(ADMIN_SUB) - assert _record(client, project, rate="2.49").status_code == 303 - grant = db_session.scalar(sa.select(OspoolGrant).where(OspoolGrant.project_id == project.id)) + assert _record(client, project).status_code == 303 response = _post( client, f"/projects/{project.id}/admin-ospool-valuation", f"/projects/{project.id}", - gpu_name=grant.gpu_name, - rate="3.00", - rate_note="", - reason="New price.", + gpu_name="A100", + rate="1.99", + rate_note="Another neocloud", + reason="Cheaper price found.", ) assert response.status_code == 303