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:
1 parent
59735c3b24
commit
ae316860e5
17 files changed
+296
-17
No files matched your search
+13
-1
@@ -26,6 +26,18 @@ func loadLockfileOrFail(cmd *cobra.Command) *lockfile.Lockfile {
|
||||
return lf
|
||||
}
|
||||
|
||||
// loadLockfileForValidate is loadLockfileOrFail, except that a repository
|
||||
// without a lockfile but with a labels file still gets its labels checked
|
||||
// (own items only) instead of failing on the missing lockfile.
|
||||
func loadLockfileForValidate(cmd *cobra.Command) *lockfile.Lockfile {
|
||||
if _, err := os.Stat(filepath.Join(".", lockfile.FileName)); os.IsNotExist(err) {
|
||||
if _, err := os.Stat(labels.FileName); err == nil {
|
||||
return lockfile.New()
|
||||
}
|
||||
}
|
||||
return loadLockfileOrFail(cmd)
|
||||
}
|
||||
|
||||
func emitJSON(cmd *cobra.Command, v any) error {
|
||||
enc := json.NewEncoder(cmd.OutOrStdout())
|
||||
enc.SetIndent("", " ")
|
||||
@@ -39,7 +51,7 @@ func newValidateCmd() *cobra.Command {
|
||||
Short: "Check lockfile rules and external-area consistency offline",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
lf := loadLockfileOrFail(cmd)
|
||||
lf := loadLockfileForValidate(cmd)
|
||||
result := vendor.Validate(".", lf)
|
||||
if asJSON {
|
||||
return emitJSON(cmd, result)
|
||||
|
||||
Reference in new issue
Block a user