Skip to content

adopt execute and family init set the xf-project-<id> topic, as the scaffold does - #24

Merged
brettheap merged 3 commits into
mainfrom
fix/adopt-family-topics
Sep 4, 2026
Merged

brettheap merged 3 commits into
mainfrom
fix/adopt-family-topics

Conversation

@brettheap

@brettheap brettheap commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Lane: repo-shape
Claim: #21 (comment)

README line 99 promises that every repository of a project "carries the GitHub topic xf-project-<id>". One of the three creating tools kept that promise.

What the scaffold does. scaffold-project.py prints a topics line in its plan and, after the pushes, runs gh repo edit <repo> --add-topic xf-project-<id> on the assembly root and both legs, guarded by not local so the offline test path calls nothing.

What the other two did not. adopt-project.py execute recorded TOPIC in the assembly root's project.yaml — so validate-manifest.py was satisfied — and set the topic on nothing: not on the adopted root, not on the two legs it creates. scripts/family.py init created the holder and set no topic at all. Verified on 2026-09-04 with gh repo view --json repositoryTopics: the SCAFFOLDED MedxSoft/MedxGlass carries xf-project-medxglass, while the adopted MedxSoft/MedxEHR, InkRouter/IRRS, InkRouter/IRSS and the family holder InkRouter/InkRouter carry none — exactly the scaffold/other split.

What changed. Both tools mirror the scaffold, and nothing more.

  • adopt-project.py: execute prints the topics plan line before it asks for the human's yes, and after the split branch is pushed and the pull request is opened it sets the topic on assembly + spec + code and prints topic <topic> set on all three. The adopted root pre-existed and gets the topic too — it IS the project's assembly root, and its own manifest already claims the topic. check prints the same line inside WHAT WILL HAPPEN, so the human reads it before saying yes. The id is derived in ONE place (Plan.project_id), which feeds both the manifest's TOPIC and the gh call, so the two cannot disagree. The top-of-file docstring's execute step now says so.
  • scripts/family.py: init prints the plan line and, after the holder is pushed, sets xf-project-<family-id> on the holder via the NamingPolicy it had already loaded. Both new calls are guarded by not local.
  • No template and no manifest change: the family manifest still has no topic field.

What the tests prove. Four new tests, none of which calls gh or touches the network:

  • test_execute_plans_the_topic_and_skips_it_against_local_remotes — the local adoption prints topics skipped for local remotes and never spells gh repo edit.
  • test_init_plans_the_topic_and_skips_it_against_local_remotes — the same for the family holder.
  • test_check_plans_the_topic_on_all_three — adopt check runs against a local source and calls nothing, so the REAL plan line is assertable offline: topics gh repo edit --add-topic xf-project-northwind on all three.
  • test_init_dry_run_plans_the_gh_topic_command_for_a_real_org — family.py init --dry-run with no --local-remote-dir reaches the plan print before anything is created, so it asserts topics gh repo edit --add-topic xf-project-contoso.

python3 -m pytest tests -q: 354 passed (349 before), the way CI runs it, with git-filter-repo installed so the adoption suite actually runs.

Two review follow-ups on this branch. b6cbdd9: a gh repo edit that fails no longer suppresses the blob-sha verification table — the failure is reported loudly with the commands to finish by hand, verification still prints, and the run still exits non-zero (a verification mismatch outranks a missing topic). e3012c0: Plan.project_id re-validates the plan's editable id: against ^[a-z0-9][a-z0-9-]*$ where the topic is derived from it, since the value now reaches a gh command line — plus the test for it, which is the 354th.

One finding left as it stands: family.py init --no-push sets the topic on a real remote. gh repo create has already made the repository by then whether or not the commit is pushed, and scaffold-project.py — the tool both of these mirror — guards its own topic block with not local alone.

Closes #21.

Still needed by hand (the issue's own follow-on, not this PR): the four repositories that exist without a topic today — MedxSoft/MedxEHR, InkRouter/IRRS, InkRouter/IRSS and InkRouter/InkRouter — get theirs set by an operator. This PR changes code only and touched no real repository.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T

…caffold does

README promises that every repository of a project carries the GitHub topic
`xf-project-<id>`, and only one of the three creating tools kept the promise.
`scaffold-project.py` prints a `topics` plan line and runs `gh repo edit
--add-topic` on all three repositories, guarded by `not local`.
`adopt-project.py execute` recorded `TOPIC` in the manifest — so
`validate-manifest.py` was satisfied — and set the topic on nothing;
`scripts/family.py init` created the holder and set no topic at all. Verified
on 2026-09-04: the SCAFFOLDED MedxSoft/MedxGlass carries
`xf-project-medxglass`, while the adopted MedxSoft/MedxEHR, InkRouter/IRRS,
InkRouter/IRSS and the family holder InkRouter/InkRouter carry none — exactly
the scaffold/other split.

Both tools now mirror the scaffold and nothing more:

- adopt `execute` prints the `topics` plan line before it asks for the
  human's yes, and after the split branch is pushed and the pull request is
  opened it sets the topic on the assembly root and both legs. The adopted
  root pre-existed, and it gets the topic too: it IS the project's assembly
  root and its own `project.yaml` already claims the topic. `check` prints
  the same line in WHAT WILL HAPPEN, so the human reads it before saying yes.
- family `init` prints the plan line and sets `xf-project-<family-id>` on the
  holder after the push, via the `NamingPolicy` it already loaded.

The topic is derived in one place — `Plan.project_id` feeds both the
manifest's `TOPIC` and the `gh` call — so the two can never disagree. No
template and no manifest change; the family manifest still has no `topic`
field.

Four tests, none of which calls `gh`: the local adopt execute and the local
family init print `topics ... skipped for local remotes` and invoke nothing,
and the two paths that reach a plan print with no network — `adopt check`
against a local source, and `family init --dry-run` with no
`--local-remote-dir` — assert the real `gh repo edit --add-topic
xf-project-<id>` line. 349 -> 353 tests, all passing.

Closes #21. The four repositories that exist without a topic today
(MedxEHR, IRRS, IRSS, InkRouter) still need theirs set by hand.

Lane: repo-shape

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Copilot AI lite review requested due to automatic review settings September 4, 2026 05:01
@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR brings adopt-project.py and family.py init into alignment with the scaffold by deriving and planning xf-project- topics, applying them to the appropriate repositories only for real remotes, and adding offline tests covering the plans and guards.

Sequence diagram for applying project topics during adoption

sequenceDiagram
    participant Operator
    participant AdoptProject
    participant GitHub
    Operator->>AdoptProject: execute
    AdoptProject->>AdoptProject: Plan.project_id
    AdoptProject->>AdoptProject: NamingPolicy.topic_for(project_id)
    AdoptProject-->>Operator: topics gh repo edit --add-topic topic on all three
    Operator->>AdoptProject: confirm
    AdoptProject->>GitHub: gh repo edit assembly --add-topic topic
    AdoptProject->>GitHub: gh repo edit spec --add-topic topic
    AdoptProject->>GitHub: gh repo edit code --add-topic topic
    AdoptProject-->>Operator: topic set on all three
Loading

Sequence diagram for family holder topic initialization

sequenceDiagram
    participant Operator
    participant FamilyInit
    participant GitHub
    Operator->>FamilyInit: init
    FamilyInit->>FamilyInit: NamingPolicy.topic_for(family_id)
    FamilyInit-->>Operator: topics gh repo edit --add-topic topic
    FamilyInit->>GitHub: gh repo edit holder --add-topic topic
    FamilyInit-->>Operator: topic set on the holder
Loading

Flow diagram for skipping topic updates on local remotes

flowchart TD
    Start[adopt execute or family init] --> Plan[Print topic plan]
    Plan --> Remote{local remotes?}
    Remote -->|Yes| Skip[Skip gh repo edit]
    Remote -->|No| Apply[Apply xf-project-id topic]
    Skip --> Done[Continue without network calls]
    Apply --> Done
Loading

File-Level Changes

Change Details Files
Add consistent GitHub project-topic planning and application to project adoption and family initialization.
  • Centralize project ID derivation and use it for manifest/topic consistency.
  • Show topic actions in adoption check and execute plans.
  • Apply the topic to the adopted assembly root and both legs after remote setup, while skipping local remotes.
  • Plan and apply the family-holder topic through the existing naming policy, with local-remotes guards.
adopt-project.py
scripts/family.py
Add offline regression coverage for topic planning, execution guards, and dry-run behavior.
  • Assert local adoption and family initialization skip GitHub commands.
  • Assert adoption check lists all three repositories and the expected topic.
  • Assert real-organization family dry-run output contains the topic command without creating resources.
tests/test_adopt_e2e.py
tests/test_adopt_plan.py
tests/test_family.py

Assessment against linked issues

Issue Objective Addressed Explanation
#21 Update adopt-project.py execute to plan and set the xf-project-<id> GitHub topic on the adopted assembly root and both newly created legs, while skipping GitHub topic operations for local/offline remotes. ✅
#21 Update scripts/family.py init to plan and set the xf-project-<family-id> GitHub topic on the family holder, while skipping the operation for local/offline remotes. ✅
#21 Expose the topic operation in the relevant execution/check/dry-run plans and add offline tests covering the planned behavior without changing templates or manifests. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="adopt-project.py" line_range="1267-1269" />
<code_context>
                   f"--base {tracking} --head {branch}", file=sys.stderr)
             return 2

+        # ---- the topic, on all three --------------------------------------
+        # The assembly root pre-existed and is still a repository OF THIS
+        # PROJECT: `project.yaml` claims `topic: <topic>` either way, and a
+        # claim the organisation cannot see is the defect being fixed here.
+        for role in ("assembly", "spec", "code"):
+            run(["gh", "repo", "edit", repositories[role], "--add-topic",
+                 topic])
+        print(f"  topic     {topic} set on all three")
+
</code_context>
<issue_to_address>
**issue (bug_risk):** A failure from any new `gh repo edit` call raises `CommandFailed` uncaught, so `execute` terminates with a traceback after the pull request is created, stops before updating the remaining repositories, and never reaches verification.

**Triggers:** When GitHub rejects one topic update, such as because of insufficient permission or a transient API failure.

**Suggested fix:** Catch `CommandFailed` around the topic-update loop, report which repository failed, and return the command's documented failure status without an uncaught traceback.

```suggestion
        try:
            for role in ("assembly", "spec", "code"):
                run(["gh", "repo", "edit", repositories[role], "--add-topic",
                     topic])
        except CommandFailed as exc:
            print(exc.loudly(
                f"updating the topic on {repositories[role]}"),
                file=sys.stderr)
            return 2
```
</issue_to_address>

### Comment 2
<location path="scripts/family.py" line_range="506-508" />
<code_context>
             return 2
     head = git_out(["rev-parse", "HEAD"], cwd=work)[:12]
     print(f"  holder    {head} -> {url}")
+    if not local:
+        run(["gh", "repo", "edit", repository, "--add-topic", topic])
+        print(f"  topic     {topic} set on the holder")
     if not local and args.visibility in ("private", "internal"):
         print(f"NOTE {repository} is {args.visibility} and its members will "
</code_context>
<issue_to_address>
**issue (broader_impact):** `init --no-push` still runs `gh repo edit --add-topic` for a real remote even though it deliberately skipped pushing the holder commit, so the command performs a remote mutation despite its no-push mode and diverges from the scaffold's topic guard.

**Triggers:** When `family.py init` is run with `--no-push` and without a local remote directory.

**Suggested fix:** Guard the topic update with `if not local and not args.no_push:` and report that it was skipped when pushing is disabled.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if the derived topic is wrong or the GitHub commands partially fail, repository metadata can be left inconsistent across the three repositories and will remain after reverting this code. The topic can be removed or corrected with another repository-metadata operation, so the impact is bounded and repairable.

Blocking findings: adopt-project.py:1269, scripts/family.py:508


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread adopt-project.py Resolved
Comment thread scripts/family.py
Comment on lines +506 to +508
if not local:
run(["gh", "repo", "edit", repository, "--add-topic", topic])
print(f" topic {topic} set on the holder")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): init --no-push still runs gh repo edit --add-topic for a real remote even though it deliberately skipped pushing the holder commit, so the command performs a remote mutation despite its no-push mode and diverges from the scaffold's topic guard.

Triggers: When family.py init is run with --no-push and without a local remote directory.

Suggested fix: Guard the topic update with if not local and not args.no_push: and report that it was skipped when pushing is disabled.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Plan.project_id reads an editable plan id without re-validating it, which can produce invalid topics/manifest values despite the tool treating the plan as untrusted input.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR aligns adopt-project.py execute and scripts/family.py init with scaffold-project.py by planning and (when not using local remotes) applying the xf-project-<id> GitHub topic via gh repo edit --add-topic, ensuring repositories can be listed/grouped by project consistently with the README promise.

Changes:

  • Add a “topics …” plan line to adopt check/execute and family init output, mirroring the scaffold behavior and preserving offline/no-network testability via local-remote guards.
  • Set the xf-project-<id> topic on GitHub after adopt execute opens the PR (assembly + spec + code) and after family init pushes the holder (holder repo).
  • Add offline tests asserting the plan-line behavior and local-remote “skipped” behavior without invoking gh.
File summaries
File Description
adopt-project.py Adds topic planning output and applies the topic to all three repos post-PR creation; centralizes topic derivation via Plan.project_id.
scripts/family.py Plans and applies the holder topic (xf-project-<family-id>) when not using local remotes.
tests/test_adopt_plan.py Verifies adopt check prints the topic plan line (“… on all three”) offline.
tests/test_adopt_e2e.py Verifies local-remote adopt execute prints “topics skipped…” and never mentions gh repo edit.
tests/test_family.py Verifies family init topic plan line behavior for local remotes and real-org dry runs without network calls.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread adopt-project.py Outdated
Comment on lines +732 to +737
@property
def project_id(self) -> str:
"""The lowercase machine name. The GitHub topic is derived from it,
both for the manifest's `TOPIC` and for `gh repo edit --add-topic`,
so it is read in ONE place rather than spelled out at each."""
return str(self.get("id", self.names()["assembly"].lower()))
Sourcery, on #24: the new `gh repo edit --add-topic` loop raised
`CommandFailed` out of `cmd_execute`. `main()` catches it and exits 2 with the
loud command report, so it was never a traceback — but by then the split is
pushed and the pull request is open, and what the failure DID cost is the
blob-sha verification table, which is the report AGENTS.md step 7 tells the
human to read back. Losing the accounting for every source path because
GitHub rate-limited a metadata call is the more expensive failure.

So the loop is caught: the failure is reported loudly with the three commands
to finish it by hand, verification still runs and still prints, and the run
still exits non-zero afterwards. A verification mismatch outranks a missing
topic and keeps exit 1.

Left as it stands, from the same review: `family.py init --no-push` sets the
topic on a real remote. `gh repo create` has already made the repository by
then whether or not the commit is pushed, and `scaffold-project.py` — the
tool both of these mirror — sets its topics guarded by `not local` alone.

Lane: repo-shape

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Copilot AI review requested due to automatic review settings September 4, 2026 05:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

adopt-project.py currently allows an unvalidated plan id to flow into gh repo edit argv (topic argument), and family.py init should provide a clearer remediation message on topic-setting failures.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

scripts/family.py:508

  • If gh repo edit --add-topic fails (permissions, rate limit, etc.), cmd_init currently exits via the generic top-level CommandFailed handler and does not tell the user that the holder has already been created/pushed and how to finish setting the topic manually.

adopt-project.py:737

  • Plan.project_id can come from an edited YAML plan (id:) but is not validated before it is used to build the GitHub topic that is passed as an argv element to gh repo edit. A crafted value (e.g. starting with '-') can be interpreted as an extra flag by gh, contradicting the nearby guarantee that plan values are validated before reaching git/gh.
    def project_id(self) -> str:
        """The lowercase machine name. The GitHub topic is derived from it,
        both for the manifest's `TOPIC` and for `gh repo edit --add-topic`,
        so it is read in ONE place rather than spelled out at each."""
        return str(self.get("id", self.names()["assembly"].lower()))
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot, on #24: `Plan.project_id` read the plan's editable `id:` without
re-checking it, and the value now reaches a `gh repo edit --add-topic`
command line as well as the rendered manifest. `plan` refuses a bad `--id`,
but the plan is edited between `plan` and `execute` on purpose — which is the
tool's own stated reason for validating every plan value where it is USED
rather than trusting the file it wrote.

So the property refuses an `id:` that is not `^[a-z0-9][a-z0-9-]*$`, in the
spelling `plan` already uses, and says the topic is derived from it. It is a
refusal rather than a finding, exactly as an unsafe leg name in the same file
already is. A topic that disagrees with contracts/repository-naming.yaml is
one the project's OWN gate refuses later, in
`validate-repository-naming.py`, long after the run that set it.

One test, offline as ever: an `id:` edited to `Northwind` after `plan` wrote
`northwind` is refused by `check` with `plan-bad-id`.

Lane: repo-shape

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@brettheap

Copy link
Copy Markdown
Contributor Author

(lane repo-shape, 2026-09-04T05:11:59Z) The by-hand follow-on this body mentions is already DONE: the manifest-declared topic was set on MedxEHR, IRRS, IRSS and their six legs and on the InkRouter holder before this PR opened — see #21 (comment). This PR is what keeps the gap from reopening.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, guarded for offline/local operation, and includes targeted tests that validate the new planning behavior without introducing network dependencies.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread adopt-project.py
Comment on lines +741 to +743
command line and a written manifest, and a topic that does not match
`contracts/repository-naming.yaml` is one `validate-repository-naming.py`
will refuse in the project's own gate, long after the run that set it.
@brettheap
brettheap merged commit 122d729 into main Sep 4, 2026
4 checks passed
@brettheap
brettheap deleted the fix/adopt-family-topics branch September 4, 2026 05:14
brettheap added a commit that referenced this pull request Sep 4, 2026
…dex-first) into fix/reference-by-election-date

One conflict, in adopt-project.py _template_values: main derives project_id
via plan.project_id (#24); this branch reads elected_on once beside it. Both kept.

Lane: codex-intake-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adopt execute and family init never set the xf-project-<id> GitHub topic; scaffold does

2 participants