Skip to content

agent: preserve upstream groups and canonical Grok capability IDs - #1

Open
turingcat wants to merge 4 commits into
review-base/agent-catalogs-20261104from
fix/agent-model-catalogs
Open

turingcat wants to merge 4 commits into
review-base/agent-catalogs-20261104from
fix/agent-model-catalogs

Conversation

@turingcat

Copy link
Copy Markdown
Owner

Review copy for yetone#5151.

The upstream repository permits PR creation only for collaborators. An actual
creation attempt was rejected with turingcat does not have the correct permissions to execute CreatePullRequest. This fork PR provides the complete
reviewable patch and verification record for maintainer pickup.

The base is the exact upstream commit 247794c613440dcb317ad9a8189c659ec2be8c63;
the head contains only the four reviewed feature commits.

Hermes loses upstream groups and per-model capabilities when Magpie writes only
model-ID strings. Grok config registers an extra magpie/ alias while the
gateway advertises the public ID, splitting model identity and reasoning
metadata.

This exports a generic Hermes metadata mapping under the existing provider,
with unchanged callable IDs, and uses canonical Grok table/model/default IDs.
Hermes user field overrides and deletions remain owned by the user across
catalog changes. Ownership records follow successful configuration writes;
invalid stash data is unknown. Grok migrates only proven managed aliases and
their children/cache/defaults, preserves user models and windows, and refuses
canonical collisions. Its callable native-model picker ignores TOML child
tables.

DSH's three native protocol routes remain intact. Its exported IDs and real
thinking mappings already satisfy the transport contract; Codeg performs the
limited tuple-based display compensation.

Affected design reference: docs/subsystems/agent-wiring.md.
No installed agent config, live gateway, or paid model endpoint was used.

Fixes yetone#5151. Companion changes: spacering-net/codeg#1093 and
NousResearch/hermes-agent#148733.

Verification uses Go 1.26.8, temporary HOME and pinned caches. The final reviewed
source tree is 35ba8eb6adbc968276adc5b3a3c41683ebf4b7d3.

Independent full-branch review and scoped re-reviews are complete. The commit
body records the checks and baseline issues. An earlier test-runner attempt
that overrode the gateway address invalidated fixed-address fixtures; it is
excluded from the valid results above.

Report: turingcat requested the same upstream model grouping and real
thinking controls in Hermes, DSH and Grok as in Codex and OpenCode.

Hermes's existing magpie provider now contains a model metadata mapping
keyed by the original callable IDs. It carries names, upstream prefixes,
known context lengths and explicit effort lists. Empty effort lists claim
no selectable levels. Older Hermes readers still iterate the same IDs.

Keep user edits and field deletions on retained models using the previous
generated values. Untouched metadata follows catalog refreshes; removed
models leave the generated list. Missing or invalid ownership records
claim no user settings. A failed partial decode is discarded in full.

RED: TestHermesCatalogCarriesUpstreamAndEfforts and
TestHermesCatalogGroupsPublicRoutingAndProviderIDs reject the old
string-list output. TestHermesCatalogUnreadableRecordKeepsUserSettings
caught the user's 96000 context being replaced by 128000.
GREEN: all TestHermes and TestDsh tests, 6.415s. Broader scoped run with
-race plus TestMarkedLinesEveryAgent and TestOwnModelsSayTheirPath
passed, 14.418s, under temporary HOME with pinned Go caches.

Mutation verification: wrong upstream groups fail
TestHermesCatalogGroupsPublicRoutingAndProviderIDs; inverting ownership
comparison fails TestHermesCatalogSyncKeepsUserModelOverrides. Restored
sources then passed the race run. gofmt -l and git diff --check are clean.
DSH's existing three-protocol and reasoning tests pass unchanged; no
unsupported grouping fields are added to its config.

Full suite and platform builds will be recorded in the integration commit
and PR before publishing. No installed runtime or live config was edited.
Grok previously registered magpie/<id> while /v1/models returned <id>,
so its ACP picker could show both and attach reasoning levels only to
the alias. Register the public ID, wire ID, default and capabilities
together. Keep the magpie/ wrapper only in Magpie's field values.

Use Grok's native model_provider relationship to identify owned tables.
Migrate proven legacy tables, defaults and cached aliases by exact table
name; refuse canonical user-table collisions. Preserve native entries,
existing explicit/inline/dotted provider definitions, recorded proxy
routes and user context windows, including an unknown catalog window. Refresh owned reasoning child tables
and move other legacy child tables with their model ID, preserving proxy
headers without leaving an implicit alias.
Keep a removed selected identity until Reseat can compare it. Reject
full-document TOML parse errors before either model or effort Clear.
Disconnect removes an empty provider definition only if Magpie made it.

Verified in temporary HOME with GOPATH/GOMODCACHE/GOCACHE pinned:
- go test -tags nogui ./internal/agent -run
  '^TestGrok|^TestOwnModelsSayTheirPath$|^TestMarkedLinesEveryAgent$'
  -count=1 -timeout 15m: pass, 15.135s.
- Same selection with -race -count=1: pass, 18.915s.
- go test -race -tags nogui ./internal/agent -run
  '^TestGrok(Canonical|LegacyCatalog|PrefixAlone|UnreadCache|DisconnectKeeps|CatalogDuplicate|CatalogReplaces)'
  -count=20 -timeout 15m: pass, 27.143s.
- go vet -tags nogui ./internal/agent: pass.
- gofmt -l on the four changed Go files and git diff --check: clean.

Before the fix, TestGrokCanonicalModelCarriesItsCapabilities failed
because the public ID had no registration; migration, collision,
prefix-ownership and default assertions failed too. Additional observed
reds cover duplicate-key Clears, provider spellings, a removed selection
and unknown-window overrides. Omitting cache pruning makes
TestGrokLegacyCatalogMigratesDefaultWindowAndCache fail on the surviving
alias; omitting existing windows makes TestGrokKeepsAWindowSetByHand fail
with 1000000 instead of the user's 300000.

Real Grok 1.0.70 against a recording loopback endpoint confirmed two
canonical ACP IDs, their exact levels, a nondefault high reasoning
request, stale-cache restart after HTTP 503, and a legacy-default session
resuming its underlying canonical ID even with a different new default.
No session files are edited by Magpie. No paid upstream or live agent
configuration was used. Full-repository and platform checks are deferred
to the parent integration run to avoid concurrent full Go suites.

Related discussions yetone#775 and yetone#2811 were read through their last comments.
This keeps slash-containing public IDs, so it does not resolve the
CodexHost opaque-ref restriction in yetone#775. Native Grok 1.0.70 accepts the
inline effort list and the explicit high ACP override was verified;
yetone#2811's requested table formatting/default marker remains separate.
Neither issue is closed by this change.
Address consolidated review R1-R7 without changing callable model IDs,
native protocol routes, or installed agent configuration.

Store generated metadata plus sticky user override/deletion flags in a
versioned record, with readers for the previous Hermes mapping and Grok
numeric-window formats. A future catalog equality or temporarily absent
field no longer reclaims a user's value or deletion. The same rule covers
Grok windows.

Prepare ownership without writes. Hermes freezes its profile roster and
puts root/profile config and env files in edit.Atomically, then commits one
operation-local stash patch after all steps succeed. Grok likewise defers
provider/model/window changes until its complete Set or Sync succeeds.
Stash errors propagate, and committing against the latest shared stash
preserves another agent's concurrent updates. Reject the entire outer
stash on a JSON decode error; recovery still keeps the bad original aside.

Remove all owned Grok child tables when their model leaves the catalog,
retain user children of remaining models, and enumerate only exact
ordinary model headers. Normalize catalog off to Hermes none without
duplicates; nil and empty capability lists remain explicit [].

Verification: Go 1.26.8, temporary HOME, pinned GOPATH/GOMODCACHE/GOCACHE.
- Every review finding and the sibling Grok window cases produced actual
  assertion failures before production edits; the complete new regression
  set then passed in 1.549s.
- go test -tags nogui ./internal/agent ./internal/proc ./internal/edit
  -run '^Test(Hermes|Grok|Stash|UnreadStash|Dsh|FolderVarsAreListed|ModelReadersShareTheList|MarkedLinesEveryAgent|OwnModelsSayTheirPath|HandWiredMagpieProviderSiblings|ListOnlyAgentsReadConnected|NoCommandBypassesProc)'
  -count=1 -timeout 15m: pass (agent 23.535s, proc 0.576s;
  edit had no matching tests).
- go test -race -tags nogui ./internal/agent
  -run '^Test(HermesCatalog|Grok(UserWindow|DeletedWindow|RemovedModel|Failed|ModelChoices)|Stash|UnreadStash)'
  -count=1 -timeout 15m: pass, 3.259s.
- go vet -tags nogui ./internal/agent ./internal/proc ./internal/edit:
  pass; gofmt and git diff --check clean.

Read the complete independent review and its regression sources. Failed
write tests use portable target replacement, cover root/profile retries,
config/cache rollback, all three Grok ownership records, and preservation
of an unrelated concurrent stash update. The existing macOS SDK spawn
deprecation warning remains. Full-repository/platform runs are coordinated
by the parent and were not duplicated here.
Address scoped review R8. A removed legacy reasoning child is deleted
under its original header and is never renamed. Record a canonical child
name only in the branch that actually queues that header rename, so
cleanup cannot match an unrelated user's canonical reasoning subtree.

TestGrokRemovedAliasKeepsUnownedCanonicalReasoning failed on 45c6fede6:
Sync returned nil but removed the unowned canonical reasoning metadata.
The same fixture now preserves the private model, endpoint, key and max
reasoning entry when the catalog lists only flash.

Verified with Go 1.26.8, temporary HOME and pinned caches:
- go test -tags nogui ./internal/agent -run '^TestGrok'
  -count=1 -timeout 10m: pass, 11.533s.
- go test -race -tags nogui ./internal/agent
  -run '^TestGrok(RemovedAliasKeepsUnownedCanonicalReasoning|RemovedModelChildrenCannotOutliveClear|CatalogReplacesOwnedReasoningSubtables|LegacyCatalogMovesUserSubtablesWithoutAliases)$'
  -count=1 -timeout 10m: pass, 2.079s.
- go vet -tags nogui ./internal/agent: pass.
- gofmt -l and git diff --check: clean.

Only this fix-local delta was checked; the parent's final full Go and
platform batch was left untouched. No installed config or runtime changed.

Publication verification for yetone#5151 (same reviewed source tree):
GOTOOLCHAIN=go1.26.8; temporary HOME with pinned GOPATH/GOMODCACHE/GOCACHE.
Full go test -tags nogui -timeout 45m ./... completed: only the three
preexisting failures reproduced on unchanged upstream 247794c remain:
TestKiroCrewFindsAdapters (yetone#5149), TestCoreScriptBudget (yetone#4526), and
TestLaneLimitRoutes (yetone#5150). The latter was reproduced using a controlled
fixture owner; no live provider data is in its issue. All feature-scoped
Hermes/Grok/DSH/stash/ownership regressions and required races pass.
Node color variables were cleared and a temporary failing scutil stand-in
isolated the machine proxy per yetone#2562; no MAGPIE_ADDR override was used.
An earlier runner attempt with that override invalidated fixed-address
fixtures and is explicitly excluded from valid verification.

macOS go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., macOS go build, Linux nogui build and Windows
build all pass on this final source tree. Actual Grok 1.0.70 ACP checks
cover canonical IDs, exact efforts, nondefault high on the wire, old-session
resume and cache fallback; actual DSH checks cover all three protocols.

Local integration retained Sub2API and passed the Agent/Kiro/Hermes/Grok/
DSH plus Sub2API/NewAPI provider/gateway tests. No installed runtime or
live agent configuration was modified. Independent branch review and
all scoped re-reviews are clean. Related downstream work:
spacering-net/codeg#1093 and NousResearch/hermes-agent#148733.
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.

1 participant