Skip to content

docs: use typed primitives in the guard example and pin plugin installs - #171

Merged
sourcehawk merged 1 commit into
mainfrom
docs/typed-primitives-and-plugin-pin
Aug 2, 2026
Merged

docs: use typed primitives in the guard example and pin plugin installs#171
sourcehawk merged 1 commit into
mainfrom
docs/typed-primitives-and-plugin-pin

Conversation

@sourcehawk

Copy link
Copy Markdown
Owner

Description

The declared-data guard example in docs/component.md was still written against static.NewBuilder and unstructured
field access, which made the generic primitive look like the way to do declared data. It isn't: the shape predates typed
data cells, and the rewrite to cells and WithDataGuard kept the old scaffolding instead of reshaping the example. This
swaps it for typed primitives and, separately, adds a README snippet so consumers can pin the ocf Claude Code plugin
to the framework version they compile against.

Changes

  • The Blocking on declared data example in docs/component.md now uses a ConfigMap producer and a Deployment
    consumer. It reads cm.Data["endpoint"] instead of uns.NestedString, and injects the value with
    EnsureContainerEnvVar instead of EditContent plus SetNestedString. This matches the configmap.ExtractInto
    snippet directly above it and the deployment.NewBuilder custom-guard example directly below it.
  • README.md gains a team-install snippet for the plugin: extraKnownMarketplaces plus enabledPlugins committed to a
    consumer's own .claude/settings.json, with ref pinned to a framework release tag so the skills Claude reads
    describe the same API the project builds against.
  • plugin/skills/building-components/references/component.md is regenerated via make sync-plugin.

No pkg/ code changed, so this is documentation only.

Challenges

The unstructured shape wasn't arbitrary, which is why it survived a rewrite. It came in with the guard docs when the
extraction API was still WithDataExtractor(func(obj uns.Unstructured) error), where reaching into arbitrary JSON was
the whole point. Once extraction became typed cells, the justification went away but the code didn't. All 25 primitive
packages export ExtractInto, WithDataGuard, and WithOptionalData, so the typed rewrite needed no API changes.

For the plugin pin, Claude Code distinguishes a marketplace source from a plugin source: the marketplace source that
extraKnownMarketplaces configures accepts ref (branch or tag) but not sha. A release tag is therefore the pin that
is actually available, and the README says so rather than suggesting a commit pin that would be silently ignored.

Testing

The rewritten example was compiled against the real API in a throwaway package under the module before being committed,
so the builder, mutator, and ExtractInto signatures are verified rather than assumed; the package was deleted
afterwards. The README's JSON snippet validates under jq. make fmt-md reports both files unchanged, and
make sync-plugin was re-run so the plugin reference mirror matches docs/.

Reviewers may want to check one judgment call I left alone: plugin/skills/structuring-operators/SKILL.md also uses
static.NewBuilder, but there the resource is a third-party cloud-provider CR with no typed primitive, so the
unstructured builder looks correct rather than accidental. docs/primitives/unstructured.md,
docs/custom-resource.md, and examples/custom-resource/ keep their unstructured usage for the same reason: the
generic path is their subject.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PnvBNAXNx7LZyyHR8ZamMU

The declared-data guard example in docs/component.md was still built on
static.NewBuilder and unstructured field access. That shape predates
typed data cells: it was written for the old WithDataExtractor callback,
where an unstructured object was the point, and the rewrite to cells and
WithDataGuard kept the surrounding scaffolding rather than reshaping it.

Every primitive package exports ExtractInto, WithDataGuard, and
WithOptionalData, so nothing about declared data needs the unstructured
variant. The example now uses a ConfigMap producer and a Deployment
consumer, matching the configmap.ExtractInto snippet above it and the
deployment.NewBuilder guard example below it, and it drops
uns.NestedString and EditContent/SetNestedString in favour of cm.Data
and EnsureContainerEnvVar. The unstructured version of the pattern
remains in docs/primitives/unstructured.md, where the generic path is
the subject.

The README gains a team-install snippet for the ocf plugin. Consumers
can commit extraKnownMarketplaces and enabledPlugins to their own
.claude/settings.json and pin ref to the framework tag their go.mod
requires, so the skills Claude reads describe the same API they compile
against. A marketplace source accepts ref but not sha, so a release tag
is the available pin; without it the marketplace tracks the default
branch and the guidance drifts ahead of the pinned release.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PnvBNAXNx7LZyyHR8ZamMU
Copilot AI review requested due to automatic review settings August 2, 2026 19:29
@sourcehawk
sourcehawk merged commit 89d798a into main Aug 2, 2026
7 checks passed
@sourcehawk
sourcehawk deleted the docs/typed-primitives-and-plugin-pin branch August 2, 2026 19:31

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.

Pull request overview

Updates framework documentation to reflect the preferred “typed primitives + typed data cells” approach for declared-data guards, and documents how consumers can pin the Claude Code plugin marketplace reference to the same framework release they build against.

Changes:

  • Rewrites the “Blocking on declared data” guard example to use configmap.NewBuilder/deployment.NewBuilder, typed extraction (cm.Data["endpoint"]), and typed workload mutation (EnsureContainerEnvVar).
  • Adds a README snippet showing how to commit .claude/settings.json with extraKnownMarketplaces + enabledPlugins, pinning ref to a release tag.
  • Regenerates the plugin reference mirror for component.md so it matches docs/component.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
README.md Adds a team-shareable Claude Code plugin install snippet with ref pinned to a framework release tag.
docs/component.md Updates the declared-data guard example to use typed primitives and typed field access/mutation.
plugin/skills/building-components/references/component.md Regenerated reference copy of docs/component.md reflecting the updated guard example.

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