Skip to content

Name a component's stash as billing-*-app - #308

Open
coryodaniel wants to merge 2 commits into
mainfrom
component-star-scope
Open

coryodaniel wants to merge 2 commits into
mainfrom
component-star-scope

Conversation

@coryodaniel

Copy link
Copy Markdown
Member

A two-part stash scope such as billing-dev fits both an environment and a component. Components now take * in the environment slot, so the kind is readable from the shape:

Scope Kind
billing project
billing-dev environment
billing-*-app component
billing-dev-app instance
a UUID deployment

billing--app is accepted too, for shells that glob *. billing-app and the component:/env: prefixes keep working, so existing scripts don't change. The API still receives billing-app, so this needs no server change.

🤖 Generated with Claude Code

A two-part scope like billing-dev could be an environment or a component.
Writing a component with * in the environment slot makes every scope's kind
readable from its shape. billing-app still works for older scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coryodaniel

Copy link
Copy Markdown
Member Author

@claude please review.

@claude

claude Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 18s —— View job


Review of #308

  • Read the diff and CLAUDE.md
  • Review internal/commands/stash/stash.go and its tests

Verdict: Looks good. I found one convention nit and a few optional points. I only read the diff. I did not run make check or make docs.

What I checked

  • Parsing: componentPattern (^([a-z0-9]+)-\*?-([a-z0-9]+)$) accepts billing-*-app and billing--app. It rejects api-**-db, and the added test covers that. A non-component ref such as billing-dev-app doesn't match, so it still falls through to the instance path.
  • Order of checks: The UUID check runs first and the component check runs before scopeIDPattern. That is needed, because * and -- would fail scopeIDPattern. The legacy two-segment path through resolveEnvironmentOrComponent is unchanged.
  • component: prefix: Both star forms are accepted. env:api-*-db still errors, and there's a test for that.
  • API contract: The API still receives billing-app, so there is no server change. The new tests assert this.
  • Ambiguity error: The message now suggests 'api-*-db' in single quotes. That is a good call, because an unquoted * can glob against local files.

Nits

  1. CLAUDE.md "Comments" rule: componentScopeID has a doc comment, and the rule says no doc comments on unexported helpers (internal/commands/stash/stash.go, just above func componentScopeID). The function name and the billing-*-app examples in the ResolveScope doc already say what it does, so I'd drop it. The comment on componentPattern explains why, so keep that one.
  2. starForm: It splits on the first -, which is only correct because project and component IDs contain no hyphens. This assumption already exists in the "three segments = instance" rule. If the input can't match, it silently produces x-*-. That can't happen on the current call path, which only receives refs that matched both an environment and a component. A short note, or reusing the project/component split in one place, would keep the two helpers from drifting.
  3. Test gap (optional): api--db and api-*-db don't have a case that checks ResolveScope makes no API calls. The api-*-gone case implies it. If the fake records calls, an explicit assertion would lock that behaviour in.

Docs

The helpdocs and the generated docs are both updated in the diff, so the CI docs check should pass. I didn't regenerate them to confirm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coryodaniel

Copy link
Copy Markdown
Member Author

Thanks.

Fixed:

  1. Dropped the doc comment on componentScopeID.

Not changed:
2. starForm only gets IDs that matched an existing component, and component IDs are always <project>-<component> with no other hyphens, the same assumption the instance rule makes.
3. api-*-gone already shows it: the fake has no api-gone component, and the scope still resolves, so no lookup ran.

@claude please review.

@claude

claude Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 9s —— View job


Review of #308 (re-review)

Verdict: Looks good to merge. I read the diff only. I did not run make check or make docs.

  • Doc comment: The doc comment on componentScopeID is gone, so the CLAUDE.md comments nit is resolved.
  • starForm: Your reasoning holds. It only receives refs that already matched both an environment and a component, and component IDs are <project>-<component> with no other hyphens. I have no objection.
  • api-*-gone test: I agree this shows no API lookup ran. The fake has no api-gone component, and the scope still resolves to component:api-gone. An explicit call-recording assertion is not needed.
  • Parsing: componentPattern accepts billing-*-app and billing--app, and rejects api-**-db. The check runs after the UUID check and before scopeIDPattern, which is the right order because * and -- would fail scopeIDPattern.
  • Prefixes: The component: prefix accepts both star forms. env:api-*-db still errors.
  • API contract: The API still receives billing-app, so there is no server change.
  • Ambiguity error: The message now suggests the single-quoted 'api-*-db'. That avoids shell globbing.

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.

2 participants