Skip to content

Git designed for AI agents.

resolve: mark a model's resolution as a proposal, never record it

Federico Eliab54b5290058c
diff --git a/doc/graft/PLAN10.md b/doc/graft/PLAN10.md
index 4f3164b..9252650 100644
--- a/doc/graft/PLAN10.md
+++ b/doc/graft/PLAN10.md
@@ -898,7 +898,7 @@ not exist yet; (not enabled) marks what is designed and measured but switched of
v
VERDICT PROPOSAL (PROPOSED, the proposal + its report)
[AI landing when every deterministic check passes: designed by Federico's amendment (14),
- NOT ENABLED: the measurement in 15.5 shows no deterministic check that reaches the bar]
+ NOT ENABLED: the measurement in 15.6 shows no deterministic check that reaches the bar]
```
### 15.3 Composition report (planned; a report, not a gate)
diff --git a/tools/graft-agents/protocol/protocol.go b/tools/graft-agents/protocol/protocol.go
index 20148d2..4709fe9 100644
--- a/tools/graft-agents/protocol/protocol.go
+++ b/tools/graft-agents/protocol/protocol.go
@@ -151,6 +151,9 @@ type ResolvedFile struct {
Action string `json:"action"`
Mode string `json:"mode,omitempty"`
Content []byte `json:"content"`
+ // Proposal marks a resolution made by a model (the llm strategy): the server never lands it,
+ // it proposes it to the agent (PLAN10 14).
+ Proposal bool `json:"proposal,omitempty"`
}
// ErrorResponse is the body of an HTTP 422 (unresolvable) or other error.
diff --git a/tools/graft-agents/resolve/llm_strategy.go b/tools/graft-agents/resolve/llm_strategy.go
index 38155e9..711714a 100644
--- a/tools/graft-agents/resolve/llm_strategy.go
+++ b/tools/graft-agents/resolve/llm_strategy.go
@@ -180,6 +180,13 @@ func (s *llmStrategy) Resolve(ctx context.Context, f File, req protocol.Request)
// syntaxChecked marks the llm answers for the syntax check (resolveFile).
func (s *llmStrategy) syntaxChecked() {}
+// proposer marks a strategy whose results are proposals: those of a model, which the server
+// proposes to the agent and never lands (PLAN10 14).
+type proposer interface{ proposes() }
+
+// proposes marks the llm answers as proposals (resolveFile).
+func (s *llmStrategy) proposes() {}
+
// llmBytes keeps an empty side distinct from an absent one: ResolveLLM treats
// nil as absent.
func llmBytes(b []byte) []byte {
diff --git a/tools/graft-agents/resolve/resolve.go b/tools/graft-agents/resolve/resolve.go
index 22d947a..b2d8dbd 100644
--- a/tools/graft-agents/resolve/resolve.go
+++ b/tools/graft-agents/resolve/resolve.go
@@ -450,12 +450,19 @@ func (r *Resolver) resolveFile(ctx context.Context, req protocol.Request, f File
attempts = append(attempts, Attempt{Strategy: b.Name, Kind: AttemptCheckFailed, Err: err})
continue
}
- r.record(ctx, f, res)
+ // A model resolution is a proposal: the server never lands it (PLAN10 14). It is not
+ // recorded either: a strategy that learns accepted answers (Recorder) would otherwise
+ // replay a model's resolution later as a rule's.
+ _, proposal := b.Strategy.(proposer)
+ if !proposal {
+ r.record(ctx, f, res)
+ }
return protocol.ResolvedFile{
- Path: f.Path,
- Action: res.Action,
- Mode: modeOf(res),
- Content: contentOf(res),
+ Path: f.Path,
+ Action: res.Action,
+ Mode: modeOf(res),
+ Content: contentOf(res),
+ Proposal: proposal,
}, b.Name, nil, nil
}
return protocol.ResolvedFile{}, "", attempts, nil
diff --git a/tools/graft-agents/resolve/resolve_test.go b/tools/graft-agents/resolve/resolve_test.go
index b56c70c..b48a916 100644
--- a/tools/graft-agents/resolve/resolve_test.go
+++ b/tools/graft-agents/resolve/resolve_test.go
@@ -587,3 +587,40 @@ func TestConcurrentResolve(t *testing.T) {
t.Error(err)
}
}
+
+// proposingStrategy answers like fakeStrategy, as a model does: its answers are proposals.
+type proposingStrategy struct{ fakeStrategy }
+
+func (*proposingStrategy) proposes() {}
+
+// The llm strategy's answers are proposals (PLAN10 14).
+var _ proposer = (*llmStrategy)(nil)
+
+// TestProposalsAreMarkedAndNotRecorded: a model's answer is marked as a proposal, which the server
+// never lands, and no Recorder learns it, so that it can never come back as a rule's answer; a
+// rule's answer is not marked, and is recorded.
+func TestProposalsAreMarkedAndNotRecorded(t *testing.T) {
+ model := &proposingStrategy{fakeStrategy{fn: answer(protocol.ModeFile, "proposed\n")}}
+ rec := &recordingStrategy{fakeStrategy: fakeStrategy{fn: decline}}
+ r := newTestResolver(t, nil, Binding{Name: "rec", Strategy: rec}, Binding{Name: "llm", Strategy: model})
+ resp, err := r.Resolve(context.Background(), request(conflict("a.go")))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(resp.Files) != 1 || !resp.Files[0].Proposal {
+ t.Fatalf("files %+v, want one proposal", resp.Files)
+ }
+ if len(rec.recorded) != 0 {
+ t.Fatalf("a proposal was recorded: %+v", rec.recorded)
+ }
+
+ rule := &recordingStrategy{fakeStrategy: fakeStrategy{fn: answer(protocol.ModeFile, "ruled\n")}}
+ r = newTestResolver(t, nil, Binding{Name: "rule", Strategy: rule})
+ resp, err = r.Resolve(context.Background(), request(conflict("a.go")))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if resp.Files[0].Proposal || len(rule.recorded) != 1 {
+ t.Fatalf("rule answer: proposal %v, recorded %d", resp.Files[0].Proposal, len(rule.recorded))
+ }
+}