Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 69 additions & 56 deletions .github/scripts/chain_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
an exit code.
"""

CHAIN_FEED_VERSION = "12"
CHAIN_FEED_VERSION = "14"

import argparse
import hashlib
Expand Down Expand Up @@ -151,20 +151,6 @@
# against `.chain/manifest.yml` and exits 2 on any drift, so the copy can never rot silently.

RECIPES = {
"reflectornet": {
"path": "shared/ReflectorNet",
"slug": "IvanMurzak/ReflectorNet",
"ecosystem": "dotnet",
"kind": "repo",
"build": "dotnet build ReflectorNet.sln -c Release -p:Version={ws_version}",
"pack": [
"dotnet pack ReflectorNet/ReflectorNet.csproj --no-build --configuration Release --output {feed} -p:Version={ws_version}",
],
"artifacts": {
"nupkg": {"kind": "nupkg", "id": "com.IvanMurzak.ReflectorNet"},
},
"consumes": [],
},
"rql": {
"path": "shared/RQL",
"slug": "IvanMurzak/RQL",
Expand Down Expand Up @@ -220,21 +206,39 @@
"dotnet pack McpPlugin.Common/McpPlugin.Common.csproj --no-build --configuration Release --output {feed} -p:Version={ws_version}",
"dotnet pack McpPlugin/McpPlugin.csproj --no-build --configuration Release --output {feed} -p:Version={ws_version}",
"dotnet pack McpPlugin.Server/McpPlugin.Server.csproj --no-build --configuration Release --output {feed} -p:Version={ws_version}",
"dotnet pack McpPlugin.Rql/McpPlugin.Rql.csproj --no-build --configuration Release --output {feed} -p:Version={ws_version}",
],
"artifacts": {
"mcpplugin": {"kind": "nupkg", "id": "com.IvanMurzak.McpPlugin"},
"common": {"kind": "nupkg", "id": "com.IvanMurzak.McpPlugin.Common"},
"server": {"kind": "nupkg", "id": "com.IvanMurzak.McpPlugin.Server"},
"rql": {"kind": "nupkg", "id": "com.IvanMurzak.McpPlugin.Rql"},
},
"consumes": [
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"mode": "nuget",
"pins": [
"McpPlugin/McpPlugin.csproj",
"McpPlugin.Common/McpPlugin.Common.csproj",
"McpPlugin.Server/McpPlugin.Server.csproj",
],
"ref": "rql/nupkg", "node": "rql", "artifact": "nupkg",
"mode": "nuget", "pins": ["McpPlugin.Rql/McpPlugin.Rql.csproj"],
},
],
},
# A FACADE of type forwards to McpPlugin (nothing here consumes it): it builds after McpPlugin.
"reflectornet": {
"packs_own": True,
"path": "shared/ReflectorNet",
"slug": "IvanMurzak/ReflectorNet",
"ecosystem": "dotnet",
"kind": "repo",
"build": "dotnet build ReflectorNet.sln -c Release -p:Version={ws_version}",
"pack": [
"dotnet pack ReflectorNet/ReflectorNet.csproj --no-build --configuration Release --output {feed} -p:Version={ws_version}",
],
"artifacts": {
"nupkg": {"kind": "nupkg", "id": "com.IvanMurzak.ReflectorNet"},
},
"consumes": [
{
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"mode": "nuget", "pins": ["ReflectorNet/ReflectorNet.csproj"],
},
],
},
Expand All @@ -256,10 +260,6 @@
},
},
"consumes": [
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"mode": "nuget", "pins": ["com.IvanMurzak.GameDev.MCP.Server.csproj"],
},
{
"ref": "mcp-plugin-dotnet/server", "node": "mcp-plugin-dotnet", "artifact": "server",
"mode": "nuget", "pins": ["com.IvanMurzak.GameDev.MCP.Server.csproj"],
Expand Down Expand Up @@ -319,6 +319,7 @@
"Unity-Tests/6000.5.0b3/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.0a2/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.7f1/Assets/Plugins/NuGet",
"Unity-Tests/7000.0.0a11/Assets/Plugins/NuGet",
],
},
{
Expand All @@ -333,10 +334,11 @@
"Unity-Tests/6000.5.0b3/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.0a2/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.7f1/Assets/Plugins/NuGet",
"Unity-Tests/7000.0.0a11/Assets/Plugins/NuGet",
],
},
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"ref": "mcp-plugin-dotnet/rql", "node": "mcp-plugin-dotnet", "artifact": "rql",
"mode": "unity-dll",
"pins": [
"Unity-MCP-Plugin/Packages/com.ivanmurzak.unity.mcp/Editor/DependencyResolver/NuGetConfig.cs",
Expand All @@ -350,6 +352,7 @@
"Unity-Tests/6000.5.0b3/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.0a2/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.7f1/Assets/Plugins/NuGet",
"Unity-Tests/7000.0.0a11/Assets/Plugins/NuGet",
],
},
{
Expand All @@ -367,6 +370,7 @@
"Unity-Tests/6000.5.0b3/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.0a2/Assets/Plugins/NuGet",
"Unity-Tests/6000.6.7f1/Assets/Plugins/NuGet",
"Unity-Tests/7000.0.0a11/Assets/Plugins/NuGet",
],
},
{
Expand All @@ -390,10 +394,6 @@
"ref": "cli-core/tgz", "node": "cli-core", "artifact": "tgz",
"mode": "npm", "path": "cli", "pins": ["cli/package.json"],
},
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"mode": "nuget", "pins": ["Unity-MCP-Plugin/Tests~/EngineFree/EngineFree.csproj"],
},
{
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"mode": "nuget", "pins": ["Unity-MCP-Plugin/Tests~/EngineFree/EngineFree.csproj"],
Expand All @@ -414,7 +414,7 @@
},
"consumes": [
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"mode": "nuget",
"pins": [
"Godot-MCP.csproj",
Expand All @@ -423,7 +423,7 @@
],
},
{
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"ref": "mcp-plugin-dotnet/rql", "node": "mcp-plugin-dotnet", "artifact": "rql",
"mode": "nuget",
"pins": [
"Godot-MCP.csproj",
Expand Down Expand Up @@ -485,10 +485,6 @@
"cli": {"kind": "tgz", "id": "unreal-mcp-cli"},
},
"consumes": [
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"mode": "nuget", "pins": ["bridge/src/com.IvanMurzak.Unreal.MCP.Bridge.csproj"],
},
{
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"mode": "nuget", "pins": ["bridge/src/com.IvanMurzak.Unreal.MCP.Bridge.csproj"],
Expand Down Expand Up @@ -536,11 +532,11 @@
},
"consumes": [
{
"ref": "reflectornet/nupkg", "node": "reflectornet", "artifact": "nupkg",
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"mode": "nuget", "pins": ["Directory.Packages.props"],
},
{
"ref": "mcp-plugin-dotnet/mcpplugin", "node": "mcp-plugin-dotnet", "artifact": "mcpplugin",
"ref": "mcp-plugin-dotnet/rql", "node": "mcp-plugin-dotnet", "artifact": "rql",
"mode": "nuget", "pins": ["Directory.Packages.props"],
},
{
Expand Down Expand Up @@ -1206,7 +1202,7 @@ def scope_selectors(node_id):
# package for its engine-free project) — offer each selector once
if value not in out:
out.append(value)
if is_root_node(node_id) and own_packable_artifacts(node_id):
if packs_own(node_id) and own_packable_artifacts(node_id):
out.append(SCOPE_SELF)
for twin in node_twins(node_id):
if twin_selector(twin) not in out:
Expand Down Expand Up @@ -1294,7 +1290,7 @@ def own_packable_artifacts(node_id):


def is_root_node(node_id):
"""A ROOT consumes nothing in RECIPES (§C4 "root nodes" — ReflectorNet, cli-core).
"""A ROOT consumes nothing in RECIPES (§C4 "root nodes" — RQL, Code-Exec, cli-core).

Decided by the RECIPE, never by the lock: a consumer whose producers all happen to be
`released` in one lock has no overridden edge either, yet it is not a root — its workflow
Expand All @@ -1304,6 +1300,13 @@ def is_root_node(node_id):
return not any(edge["mode"] != "project" for edge in RECIPES[node_id]["consumes"])


def packs_own(node_id):
"""Does this node's leg pack its own artifact at the lock's ws version and prove it? Every root,
and a consumer whose recipe says `packs_own` (v14: ReflectorNet, a facade over McpPlugin whose
workflow kept its own-pack steps)."""
return is_root_node(node_id) or bool(RECIPES[node_id].get("packs_own"))


def leg_is_active(ctx):
"""A leg is evidence for this lock when it consumes a ws producer, is a root at a ws version,
OR this job selected a twin the lock pins at a sha (`--edges twin:<node>`).
Expand All @@ -1314,18 +1317,18 @@ def leg_is_active(ctx):
"""
return (
bool(overridden_edges(ctx))
or (is_root_node(ctx.node) and bool(ctx.ws_version(ctx.node)))
or (packs_own(ctx.node) and bool(ctx.ws_version(ctx.node)))
or bool(pinned_twins(ctx))
)


def own_pack_in_scope(ctx):
"""`(proven, skipped)` own-pack artifacts — a root at a ws version only.
"""`(proven, skipped)` own-pack artifacts — a `packs_own` node at a ws version only.

With no `--edges`, or `--edges self`, the root proves its own pack; any other scope records
With no `--edges`, or `--edges self`, the node proves its own pack; any other scope records
the own pack as a named skip rather than dropping it silently (A22).
"""
if not (is_root_node(ctx.node) and ctx.ws_version(ctx.node)):
if not (packs_own(ctx.node) and ctx.ws_version(ctx.node)):
return [], []
artifacts = own_packable_artifacts(ctx.node)
if ctx.scope is None or SCOPE_SELF in ctx.scope:
Expand Down Expand Up @@ -1368,17 +1371,15 @@ def own_build_props(ctx):


def own_ws_version_export(ctx):
"""`CHAIN_WS_VERSION` — a ROOT's own ws version, for whatever ecosystem it packs in.
"""`CHAIN_WS_VERSION` — the own ws version of a node whose leg packs its own artifact (`packs_own`).

`CHAIN_BUILD_PROPS` exists only when the recipe's build takes `{ws_version}` (an MSBuild
property), so an npm root such as cli-core exported nothing its pack step could stamp —
yet its workflow packs with `npm pkg set version=$CHAIN_WS_VERSION && npm pack`.
Exported for every root at a ws version; a consumer's ws version lives in the lock.
Any other consumer's ws version lives in the lock.
"""
own_ws = ctx.ws_version(ctx.node)
if is_root_node(ctx.node) and own_ws:
return own_ws
return None
return own_ws if own_ws and packs_own(ctx.node) else None


def feed_artifact_path(ctx, node_id, body):
Expand Down Expand Up @@ -1574,7 +1575,7 @@ def twin_lower_edges(ctx):
"""The `nuget` edges of every pinned twin whose producer moves in this lock.

A twin checkout restores its own packages, so a producer it pins at an UNRELEASED version
(`ReflectorNet >= 5.5.3` while 5.5.3 is only this lock's ws build) fails NU1102 unless the leg
(`Rql >= 0.6.0` while 0.6.0 is only this lock's ws build) fails NU1102 unless the leg
self-builds that producer into the feed and overrides it in the twin, exactly as it does for a
lower node's clone."""
return [edge for twin in pinned_twins(ctx) for edge in moving_nuget_edges(ctx, twin["node"])]
Expand Down Expand Up @@ -1813,6 +1814,20 @@ def render_nuget_config(feed, lock_hash8="nolock"):
)


#: True for a pin that is not already an EXACT range. `[5.7.0]` is a deliberate pin of one release
#: (v14: ReflectorNet.Compat compiles against the last OLD ReflectorNet and McpPlugin), so the
#: override leaves it alone; a declared consumer pin written that way fails its identity proof.
NOT_EXACT_PIN = (
"!$([System.String]::new('%(Version)').StartsWith('[')) "
"or $([System.String]::new('%(Version)').Contains(','))"
)


def render_row(package_id, ws_version):
return ('<PackageReference Update="%s"><Version Condition="%s">[%s]</Version></PackageReference>'
% (package_id, NOT_EXACT_PIN, ws_version))


def render_targets(rows, lock_hash8="nolock"):
"""The `02` §5 fragment: NU1603/NU1605 promoted, plus one EXACT `[range]` row per package.

Expand All @@ -1832,9 +1847,7 @@ def render_targets(rows, lock_hash8="nolock"):
" <ItemGroup Condition=\"'$(%s)' == 'true'\">" % NUGET_PROPERTY,
]
for row in rows:
lines.append(
' <PackageReference Update="%s" Version="[%s]" />' % (row["package_id"], row["ws_version"])
)
lines.append(" " + render_row(row["package_id"], row["ws_version"]))
lines += [" </ItemGroup>", "</Project>", ""]
return "\n".join(lines)

Expand Down Expand Up @@ -3202,7 +3215,7 @@ def cmd_dry_run(args):
return EXIT_OK
edges, outside = scoped_edges(ctx)
own, own_outside = own_pack_in_scope(ctx)
if is_root_node(ctx.node):
if own or own_outside or is_root_node(ctx.node):
log("")
log("chain: --- %s @ %s (%s) — this node's OWN pack, run by the workflow after its tests ---"
% (ctx.node, ctx.ws_version(ctx.node), ctx.sha(ctx.node)))
Expand All @@ -3212,7 +3225,7 @@ def cmd_dry_run(args):
for _, body in own_packable_artifacts(ctx.node):
# checkout-relative: the same `.artifacts/<feed>/<file>` the workflow's pack step writes
relative = feed_artifact_path(ctx, ctx.node, body).relative_to(ctx.checkout).as_posix()
log("chain: root node: no lower layers; pack → %s" % relative)
log("chain: %spack → %s" % ("root node: no lower layers; " if is_root_node(ctx.node) else "", relative))
for _, body in own:
log("chain: prove %s (own pack)" % as_posix_abs(feed_artifact_path(ctx, ctx.node, body)))
for row in scope_skips(ctx, edges, outside, own_outside):
Expand Down