fix(client): harden label pinning and close review findings

- Resolve the Windows admin config via the ProgramData known folder
  instead of the user-controlled ProgramData variable, so a user cannot
  redirect the admin lookup and drop pinned labels
- vendor rename rewrites matching agent-lib.labels.json entries, so a
  renamed item keeps its labels instead of going to every client
- validate checks the labels file in repositories without a lockfile
- A kept modified copy of a deselected item is no longer drift in status,
  and the toast explains it as "no longer assigned to you"
- Labels parser rejects trailing data such as an extra closing brace
- Tests: admin pin wiring (config chain, --repo, admin as chosen config),
  reselect redeploy with byte-level no-op, status labels JSON, validate
  without lockfile, rename keeps labels
- README: document unreadable admin config, drift semantics, rename

Refs: agent_lib-fh4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
m3ta-chironandClaude Opus 5.5 committed 2026-11-14 11:00:41 +01:00
1 parent 59735c3b24
commit ae316860e5
17 files changed
+296 -17

No files matched your search

+35
View File
@@ -263,3 +263,38 @@ func TestAdminConfigBrokenIsFatal(t *testing.T) {
t.Fatal("an unreadable admin config must abort: its label intent is unknown")
}
}
func TestResolveRunConfigAppliesAdminPin(t *testing.T) {
dir := t.TempDir()
admin := filepath.Join(dir, "admin.json")
writeRaw(t, admin, `{"repo_url":"r","labels":["finance"]}`)
orig := adminConfigPath
t.Cleanup(func() { adminConfigPath = orig })
adminConfigPath = func() string { return admin }
user := filepath.Join(dir, "user.json")
writeRaw(t, user, `{"repo_url":"r","labels":["sales","it"]}`)
cfg, err := resolveRunConfig(SyncOptions{ConfigPath: user})
if err != nil {
t.Fatal(err)
}
if cfg.LabelSource != "admin" || strings.Join(*cfg.Labels, ",") != "finance" {
t.Errorf("config-chain run: admin pin not applied, got %v (%s)", *cfg.Labels, cfg.LabelSource)
}
cfg, err = resolveRunConfig(SyncOptions{ConfigPath: user, RepoURL: "other"})
if err != nil {
t.Fatal(err)
}
if cfg.LabelSource != "admin" || strings.Join(*cfg.Labels, ",") != "finance" {
t.Errorf("--repo run: admin pin not applied, got %v (%s)", *cfg.Labels, cfg.LabelSource)
}
cfg, err = resolveRunConfig(SyncOptions{ConfigPath: admin})
if err != nil {
t.Fatal(err)
}
if cfg.LabelSource != "admin" {
t.Errorf("admin config as chosen config: source = %q", cfg.LabelSource)
}
}