Trace weights fetched before origins were kept, and let an origin be given by hand

The mirror keeps where it fetched a file beside it, and reports that and the
checksum after it restarts. A model whose files the mirror cannot trace is
found on the registry: a repository holding a file of that name that has the
commit the mirror's directory is named after, with every file at the same
size, the most downloaded first. ctl model origin and the console set one by
hand, checked the same way. Commits compare shortened.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 00:24:41 +02:00
1 parent dac7ff0e99
commit f36c46a881
11 files changed
+356 -14

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ func newModelCmd(client func() *ctlClient, asJSON *bool) *cobra.Command {
newResourcesCmd(client), newClassCmd(client), newOwnerCmd(client),
newTargetCmd(client, asJSON), newAdaptersCmd(client),
newModelServeCmd(client), newModelUpdatesCmd(client, asJSON), newModelUpdateCmd(client),
newModelRollbackCmd(client))
newModelRollbackCmd(client), newModelOriginCmd(client))
return c
}
+22
View File
@@ -117,3 +117,25 @@ func newModelRollbackCmd(client func() *ctlClient) *cobra.Command {
},
}
}
func newModelOriginCmd(client func() *ctlClient) *cobra.Command {
return &cobra.Command{
Use: "origin MODEL OWNER/REPO",
Short: "Say which registry repository a model's weights came from",
Long: "For a model fetched before llmgw kept this, and that it could not find on\n" +
"its own. The repository is checked: it must have the commit the mirror's\n" +
"directory is named after, holding the model's files at the sizes the\n" +
"mirror has. From then on its updates are watched.",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
body, _ := json.Marshal(map[string]string{"repo": args[1]})
var o struct{ Repo, Revision string }
if err := client().post(cmd.Context(), "/api/v1/models/"+args[0]+"/origin", body, &o); err != nil {
return err
}
fmt.Fprintf(cmd.OutOrStdout(), "%s came from %s at %s; its updates are watched\n", args[0], o.Repo,
catalog.ShortRevision(o.Revision))
return nil
},
}
}
+27
View File
@@ -680,7 +680,33 @@ func (m *consoleModel) doEntry() tea.Cmd {
// updateItems are what can be done about a model's repository publishing new
// weights: move to them, ask now, or go back.
func (m consoleModel) updateItems(md adminapi.ModelView) []menuItem {
origin := menuItem{"Where its weights came from…", func(m *consoleModel) tea.Cmd {
repo := ""
if md.Origin != nil {
repo = md.Origin.Repo
}
m.openForm(&formDialog{title: "Origin of " + md.Name,
note: "The registry repository its files were fetched from. Checked: it must have the\n" +
"commit the mirror's directory is named after, with the same files at the same sizes.",
fields: []formField{textF("repository", repo, "owner/name, like bartowski/phi-4-GGUF")},
submit: func(m *consoleModel, v []string) (tea.Cmd, error) {
if !strings.Contains(v[0], "/") {
return nil, fmt.Errorf("owner/name")
}
return m.call("Origin of "+md.Name, http.MethodPost, "/api/v1/models/"+url.PathEscape(md.Name)+"/origin",
map[string]string{"repo": v[0]}, func(raw json.RawMessage) string {
var o adminapi.OriginView
_ = json.Unmarshal(raw, &o)
return fmt.Sprintf("%s came from %s at %s; its updates are watched.", md.Name, o.Repo,
catalog.ShortRevision(o.Revision))
}), nil
}})
return nil
}}
if md.Origin == nil {
if strings.Contains(md.Source, "://") {
return []menuItem{origin}
}
return nil
}
server := "--server=" + m.client.base
@@ -712,6 +738,7 @@ func (m consoleModel) updateItems(md adminapi.ModelView) []menuItem {
return fmt.Sprintf("%s at %s: %s", u.Repo, catalog.ShortRevision(u.Latest), updateCell(u))
})
}})
items = append(items, origin)
if prev := md.Origin.Previous; prev != "" {
items = append(items, menuItem{"Go back to " + catalog.ShortRevision(prev) + "…", func(m *consoleModel) tea.Cmd {
m.confirmD = &confirmDialog{title: "Go back on " + md.Name,