add says what it replaced, and the planted change proved less than it looked like
The upstream cart.md change was planted to test whether the tool would notice, and the honest sequence is that check did not catch it. Every document was unlocked, and unlocked means I cannot tell you. add revealed the change by overwriting the file, and the only reason the diff was visible is that git happened to be watching the working tree. So the mechanism is proven and the workflow is not: a document nobody has locked is a document nobody is checking, silently. Fixes the defect that exposed. add reported only "adopted" while overwriting local content that differed from what the publisher serves — and a differing copy is the only evidence that something moved while the document was unlocked. It now says so. Recorded with its own limit: add still overwrites rather than stashing, so outside a git working tree the note says something was lost without letting you see it. Also records the unowned half. Nothing decides when check runs, and every answer — a hook, CI, an agent's session start, a schedule — is outside the tool. Filed as a need with no owner rather than built, because choosing one would put a scheduler inside a fetcher and a comparator, with the falsifier that if nobody ever runs check unaided then a tool that reports only when asked reports nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018UTxuSizozEA8yDitPuris
This commit is contained in:
Vendored
+15
@@ -6,6 +6,7 @@
|
||||
package external
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -127,6 +128,17 @@ func Add(root, raw, override string, out io.Writer) error {
|
||||
if err := os.MkdirAll(filepath.Dir(dest), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Say what is being replaced before replacing it. add overwrites the local
|
||||
// copy, and a copy that differs from what the publisher is serving is the
|
||||
// only evidence that anything changed while the document was unlocked —
|
||||
// destroying it silently is how a change nobody saw becomes a change nobody
|
||||
// can find.
|
||||
replaced := ""
|
||||
if old, err := os.ReadFile(dest); err == nil && !bytes.Equal(old, body) {
|
||||
replaced = fmt.Sprintf("replaced %d bytes that differed — diff the working tree before committing", len(old))
|
||||
}
|
||||
|
||||
if err := os.WriteFile(dest, body, 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -142,6 +154,9 @@ func Add(root, raw, override string, out io.Writer) error {
|
||||
|
||||
fmt.Fprintf(out, "adopted %s\n", rel)
|
||||
fmt.Fprintf(out, " from %s\n", resp.Request.URL)
|
||||
if replaced != "" {
|
||||
fmt.Fprintf(out, " NOTE %s\n", replaced)
|
||||
}
|
||||
if etag == "" {
|
||||
fmt.Fprintf(out, " etag (none served — check cannot ask conditionally)\n")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user