Repository navigation
feat(nemoclaw-tofu): pass resource identities between types as typed refs - #13138
Merged
Merged
Conversation
…refs Provider types identify each other through separately passed strings, such as a sandbox's workspace name, so OpenTofu cannot check that the pieces belong to one object or say which resource type they came from. The provider redesign in #13131 replaces these with a computed `ref` object on the producing type and an object input on the consumer. Definitions gain `exports` and `references`. The structured adapter derives `ref` from the row, so backends never see it, and parts the row does not know yet stay unknown. A reference input is one object attribute whose declared attributes travel to the backend as row fields; its `type` must match the exporting type, because OpenTofu drops object attributes a consumer does not declare and would otherwise accept a ref of another type with matching fields. A changed ref replaces its consumer when the carried fields are immutable, and plans report the reference attribute as the replacement path. The fixture provider gains a ref-exporting workspace and a ref-taking sandbox. Unit tests cover the schema, planning with known and unknown refs, type checks, and refresh. A contract test through OpenTofu 1.12.6 covers create, an unchanged plan, replacement propagating to the consumer, and rejecting a ref of another type.
Contributor
cv
added a commit
that referenced
this pull request
Oct 14, 2026
Closes #13141. Part of #13131. Stacked on #13138. ## Failure OpenShell provider profiles, registrations, and sandboxes named their workspace, scoped profile, and provider registrations with separate strings. OpenTofu could not check that each name meant an object of the right type, and graphs had to pass names in a fixed order through `depends_on`. ## Decision - Each OpenShell resource exports a computed `ref`: `type`, `name`, `owner`, `generation`, `id`, plus `workspace` for objects inside a workspace. - Profiles, registrations, and sandboxes take `workspace = openshell_workspace.<label>.ref`. Registrations take an optional `profile` ref in place of `profile_name`. Sandboxes take `providers`, a list of registration refs, in place of `provider_names`. - `nemoclaw-tofu` gains list references (`references_list`) and a schema version. The four OpenShell schemas move to version 1, so OpenTofu rejects state from the earlier schema instead of upgrading it. The SDK record version moves from 7 to 8 with a message pointing to the original release for recovery or teardown. - The SDK compiler emits ref expressions. `nemoclaw_openshell::flatten` rewrites refs in state, plans, and planned values back into the row fields the SDK compares, so plan gates, export, and binding checks are unchanged. Sandbox readiness reads the workspace from the sandbox's ref. ## Validation - New `nemoclaw-tofu` unit tests for list references: schema shape and version, backend rows, unknown elements deferring planning, rejecting an element of another type, and refresh. - Regenerated the OpenShell contract fixtures (`NEMOCLAW_REGENERATE_FIXTURES=1`) and schema snapshot; updated the hand-written OpenShell and Fabric contract HCL; the SDK compile test now checks workspace and provider refs. - `cargo ci` passed locally on linux_arm64, including all 138 contract and system tests.
Closed
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13140. Part of #13131.
Failure
Provider types identify each other through separately passed strings, such as a sandbox's workspace name. OpenTofu cannot check that those strings belong to one object, or which resource type they came from, and every consumer repeats the fields it needs.
Decision
Resource definitions gain two declarations in
nemoclaw-tofu:exports(kind, fields)adds a computed object attributeref:{ type = kind, <fields> }. The structured adapter derives it from the resource's row, so backends never see it. Parts the row doesn't know yet, such as an ID assigned on create, stay unknown in the plan.references(attribute, kind, fields)adds one object input that takes another type'sref. Each declared attribute travels to the backend as an ordinary row field, and refresh rebuilds the object from what the backend observes. A changed carried field that is immutable replaces the consumer, and plans report the reference attribute as the replacement path.OpenTofu drops object attributes that a consumer doesn't declare. Consumers therefore declare only what they carry, and every
refcarriestype, which consumers check: arefof another type is rejected with "Expected a ref of X, not Y".No production type uses this yet; the OpenShell types adopt it in the next slice.
nemoclaw-providernow picks the structured adapter throughDefinition::is_structured().Validation
structured.rs: schema shape, planning with known and partly unknown refs, backend rows, type rejection, and refresh rebuilding a reference from observed fields.workspaceand a ref-takingsandbox. New contract tests incrates/nemoclaw-provider/tests/contract/references.rsrun them through pinned OpenTofu 1.12.6: create, an unchanged plan, workspace replacement propagating to the sandbox withreplace_paths == [["workspace"]], and rejection of a ref of another type during validation.cargo cipassed locally on linux_arm64.