Skip to content

Git designed for AI agents.

land: a model's resolution is a proposal, kept under refs/graft/proposals

Federico Eliae33a7231f036
diff --git a/cmd/graft/conflicts.go b/cmd/graft/conflicts.go
index 34e7a68..c44c8e0 100644
--- a/cmd/graft/conflicts.go
+++ b/cmd/graft/conflicts.go
@@ -29,6 +29,10 @@ import (
// DIR/sides/base/<path> the three sides; a side that is absent or cannot be read has no file
// DIR/sides/ours/<path>
// DIR/sides/theirs/<path>
+// DIR/proposals/<path> the resolver's proposal for the path, when it made one (a model's
+// resolution, which the server never lands, or the rules' of a land
+// that failed for another file); copy it over DIR/files/<path> to
+// land it as yours
// DIR/conflict.json the conflict package
//
// Each directory mirrors the tree of the merge, so that no repository path, whatever its name, can
@@ -36,9 +40,10 @@ import (
// lands the files of DIR/files as the resolution: a path whose file is present is written, one
// whose file is absent is deleted.
const (
- conflictsFilesDir = "files"
- conflictsSidesDir = "sides"
- conflictsPackage = "conflict.json"
+ conflictsFilesDir = "files"
+ conflictsSidesDir = "sides"
+ conflictsProposalsDir = "proposals"
+ conflictsPackage = "conflict.json"
)
// conflictSides are the sides of a conflicting file, in the order of the package.
@@ -95,7 +100,7 @@ func conflictPath(dir, sub, p string) (string, error) {
// Two paths that this file system takes for the same file (such as names that differ in case on a
// case-insensitive one) are an error, since one would overwrite the other.
func writeConflicts(ctx context.Context, ws *workspace.Workspace, c *gitalypb.LandConflict, dir string, out io.Writer) error {
- for _, sub := range []string{conflictsFilesDir, conflictsSidesDir, conflictsPackage} {
+ for _, sub := range []string{conflictsFilesDir, conflictsSidesDir, conflictsProposalsDir, conflictsPackage} {
if _, err := os.Lstat(filepath.Join(dir, sub)); err == nil {
return fmt.Errorf("%s already holds a conflicts directory (%s): land it with --resolved, or remove it", dir, sub)
} else if !errors.Is(err, fs.ErrNotExist) {
@@ -142,6 +147,9 @@ func writeConflicts(ctx context.Context, ws *workspace.Workspace, c *gitalypb.La
if err := create(target, p, content); err != nil {
return err
}
+ if err := writeProposal(out, dir, f, blobs, missing, create); err != nil {
+ return err
+ }
}
raw, err := protojson.MarshalOptions{Multiline: true}.Marshal(c)
@@ -151,6 +159,39 @@ func writeConflicts(ctx context.Context, ws *workspace.Workspace, c *gitalypb.La
return create(filepath.Join(dir, conflictsPackage), conflictsPackage, append(raw, '\n'))
}
+// writeProposal writes the resolver's proposal of f, if it has one, to DIR/proposals/<path>, and
+// says so. A proposal to delete the path has no file; a proposal that cannot be read is reported
+// and fails nothing else.
+func writeProposal(out io.Writer, dir string, f *gitalypb.LandConflictFile, blobs map[string][]byte, missing map[string]string, create func(target, p string, data []byte) error) error {
+ prop := f.GetProposal()
+ if prop == nil {
+ return nil
+ }
+ p := string(f.GetPath())
+ by := displayText(prop.GetResolver())
+ if prop.GetAction() == "delete" {
+ fmt.Fprintf(out, " %s: %s proposes to delete it\n", displayText(p), by)
+ return nil
+ }
+ b, ok := blobs[prop.GetOid()]
+ if !ok {
+ fmt.Fprintf(out, " %s: the proposal %s of %s cannot be read: %s\n", displayText(p), shortOID(prop.GetOid()), by, displayText(missing[prop.GetOid()]))
+ return nil
+ }
+ if b == nil {
+ b = []byte{}
+ }
+ target, err := conflictPath(dir, conflictsProposalsDir, p)
+ if err != nil {
+ return err
+ }
+ if err := create(target, p, b); err != nil {
+ return err
+ }
+ fmt.Fprintf(out, " %s: %s proposes %s\n", displayText(p), by, filepath.ToSlash(filepath.Join(conflictsProposalsDir, p)))
+ return nil
+}
+
// conflictsWriter creates the files of a conflicts directory, each once.
type conflictsWriter struct {
// written maps each file created to its conflicting path, by the target folded to lower case,
@@ -185,9 +226,9 @@ func (w conflictsWriter) create(target, p string, data []byte) error {
return f.Close()
}
-// fetchSides reads the sides of the package that have an object ID, all at once. When the server
-// cannot return them all, it reads them one by one, so that a side it cannot return costs only that
-// side: missing gives the error of each side that could not be read.
+// fetchSides reads the sides and the proposals of the package that have an object ID, all at once.
+// When the server cannot return them all, it reads them one by one, so that a blob it cannot return
+// costs only that blob: missing gives the error of each one that could not be read.
func fetchSides(ctx context.Context, ws *workspace.Workspace, c *gitalypb.LandConflict) (map[string][]byte, map[string]string) {
var oids []string
seen := map[string]bool{}
@@ -198,6 +239,10 @@ func fetchSides(ctx context.Context, ws *workspace.Workspace, c *gitalypb.LandCo
oids = append(oids, oid)
}
}
+ if oid := f.GetProposal().GetOid(); oid != "" && !seen[oid] {
+ seen[oid] = true
+ oids = append(oids, oid)
+ }
}
missing := map[string]string{}
blobs, err := ws.GetObjects(ctx, oids)
diff --git a/cmd/graft/conflicts_test.go b/cmd/graft/conflicts_test.go
index f42333e..e44daa6 100644
--- a/cmd/graft/conflicts_test.go
+++ b/cmd/graft/conflicts_test.go
@@ -204,6 +204,36 @@ func TestReadResolutionAcceptsAPointerLineOfTheSides(t *testing.T) {
require.Len(t, res.Files, 1)
}
+// TestWriteProposal: a proposal is written to DIR/proposals/<path> and named on the output; a
+// proposal to delete has no file; one that cannot be read is reported and fails nothing.
+func TestWriteProposal(t *testing.T) {
+ t.Parallel()
+
+ dir := t.TempDir()
+ w := conflictsWriter{written: map[string]string{}}
+ blobs := map[string][]byte{"p1": []byte("proposed\n")}
+ missing := map[string]string{"p2": "the server did not return it"}
+ var out strings.Builder
+ for _, f := range []*gitalypb.LandConflictFile{
+ {Path: []byte("a/x.go"), Proposal: &gitalypb.LandConflictProposal{Action: "write", Oid: "p1", Mode: "100644", Resolver: "graft-resolve/llm"}},
+ {Path: []byte("gone.go"), Proposal: &gitalypb.LandConflictProposal{Action: "delete", Resolver: "graft-resolve/trivial"}},
+ {Path: []byte("lost.go"), Proposal: &gitalypb.LandConflictProposal{Action: "write", Oid: "p2", Mode: "100644", Resolver: "graft-resolve/llm"}},
+ {Path: []byte("none.go")},
+ } {
+ require.NoError(t, writeProposal(&out, dir, f, blobs, missing, w.create))
+ }
+ content, err := os.ReadFile(filepath.Join(dir, "proposals", "a", "x.go"))
+ require.NoError(t, err)
+ require.Equal(t, "proposed\n", string(content))
+ require.NoFileExists(t, filepath.Join(dir, "proposals", "gone.go"))
+ require.NoFileExists(t, filepath.Join(dir, "proposals", "lost.go"))
+ require.NoFileExists(t, filepath.Join(dir, "proposals", "none.go"))
+ require.Contains(t, out.String(), "a/x.go: graft-resolve/llm proposes proposals/a/x.go")
+ require.Contains(t, out.String(), "gone.go: graft-resolve/trivial proposes to delete it")
+ require.Contains(t, out.String(), "lost.go: the proposal p2 of graft-resolve/llm cannot be read: the server did not return it")
+ require.NotContains(t, out.String(), "none.go")
+}
+
// TestReadResolutionModes: the mode is the first file mode of ours, theirs and the base; a path
// that is a file on none of its sides (a submodule) can only be deleted.
func TestReadResolutionModes(t *testing.T) {
diff --git a/doc/graft/AGENT-SECURITY.md b/doc/graft/AGENT-SECURITY.md
index 48ecdab..4650bb3 100644
--- a/doc/graft/AGENT-SECURITY.md
+++ b/doc/graft/AGENT-SECURITY.md
@@ -59,6 +59,14 @@ These can never be enabled, not even through `graft.agent_rpcs`:
- `CleanupService`, `ObjectPoolService`, `HookService`, `InternalGitaly`,
`PartitionService`.
+Whatever the RPC and whatever the policy says, an agent never creates,
+updates or deletes a reference under `refs/graft/`: the reference-transaction
+hook refuses it, so a push, `UpdateReferences`, `DeleteRefs`, `WriteRef` or an
+operation RPC that would do so fails. The namespace is the server's: the
+proposals of a land (`refs/graft/proposals/`, hidden from advertisement and
+push, written by the server) and graft-verify's green references (written with
+the shared token).
+
Every other RPC that is not on the allowlist (for example the other
`OperationService` RPCs such as `UserMergeBranch`, or `SSHService`) is denied
by default and can be enabled with `graft.agent_rpcs`.
diff --git a/doc/graft/CONFIGURATION.md b/doc/graft/CONFIGURATION.md
index 8b75ec0..8225137 100644
--- a/doc/graft/CONFIGURATION.md
+++ b/doc/graft/CONFIGURATION.md
@@ -196,6 +196,7 @@ cause.
| `timeout` | string | `"120s"` | Bound on one resolver call (Go duration). |
| `max_files` | int | `20` | Conflicted files per land. A land with more is not sent to the resolver. |
| `max_file_bytes` | int | `1048576` (1 MiB) | Bound on every side of every file sent and on every resolved file accepted. At most 12566528 (about 12 MiB): one file, its three sides and its resolution, must fit one check request. |
+| `proposal_ttl` | string | `"168h"` | How long the proposals of a failed land are kept under `refs/graft/proposals/` (Go duration); at most 20 are kept per branch. |
| `check_concurrency` | int | `2` | Checks of agents' resolutions that run at once in the Gitaly process, across all its listeners (one resolver client is shared by them); each holds a request of up to 64 MiB. A check waits for a free slot within its deadline (`timeout`), and fails closed when it expires. The wait is in `graft_resolver_check_slot_wait_seconds`. |
| `paths_allow` | array of strings | empty (every path) | Globs of paths that may be sent to the resolver, with the syntax of policy refs. |
| `paths_deny` | array of strings | empty | Globs of paths that are never sent. Deny wins over allow. |
diff --git a/doc/graft/PLAN10.md b/doc/graft/PLAN10.md
index 99d10d6..8856708 100644
--- a/doc/graft/PLAN10.md
+++ b/doc/graft/PLAN10.md
@@ -727,3 +727,92 @@ whole series under $5 real, and a run over $1.00 real stops the series until the
whitespace counted as correct, the cases where the human changed lines outside the conflict
regions as their own category and a rate without them, acceptance and rejections by reason, the
flips against the previous step and R0 with an exact McNemar p-value, and the spend.
+
+## 14. The agent always resolves; the server's AI only proposes (Federico, PM-approved design)
+
+This supersedes "AI lands with trace only". The server never lands a resolution of the llm strategy
+by itself: it is a proposal, which the agent reviews, edits or replaces, and lands with its own
+resolution (UserLandRequest.resolution, Graft-Resolved-By: agent/<actor>). The deterministic
+strategies that the operator configures (trivial, union, rerere, command) are rules, not AI: a
+resolution made by rules alone still lands. The llm auto-land path is removed, not kept behind a
+flag.
+
+* **Protocol (additive).** A ResponseFile gains `"proposal": true`; graft-resolve sets it on every
+ file whose result came from the llm strategy, and only there. The server treats an answer with any
+ proposal file as not landable; it also refuses to land any answer whose resolver names the llm
+ strategy, should the flag be missing.
+* **Server.** With resolve_conflicts, a resolution by rules alone lands as today. When a file is a
+ proposal, the land fails with the LandConflict package: proposal files get OUTCOME_PROPOSED,
+ files that rules resolved keep OUTCOME_RESOLVED, and nothing lands partially. Every file with
+ content carries `LandConflictFile.proposal` (OID, mode, action, strategy, and the explanation cut
+ to 512 bytes), so that the agent can re-land rule results unchanged. No llm trailer exists any
+ more; the agent's re-land records the agent.
+* **Delivery: a hidden reference.** On a failed land with proposals the server writes the proposed
+ blobs and one commit (its tree the proposals by path, its message the tip, the commit and the
+ strategies), written into the repository itself (the land's quarantine is discarded), and updates
+ `refs/graft/proposals/<first 16 hex of sha256(branch)>/<commit>` through the same reference
+ transaction a land uses. One reference per (branch, landed commit), replaced by every failed land
+ of that commit. On every land of a branch that asks for or brings a resolution (a plain land pays
+ nothing; only those lands write proposals) the server deletes the branch's proposal references
+ older than `proposal_ttl` (default 7 days) and keeps at most 20 per branch; the agent's land of
+ the change drops its proposal. A proposal reference
+ that cannot be written fails the land with Internal, not with a package without proposals.
+* **(a) Authoritative storage mode (checked).** UserLand updates references through the
+ reference-transaction hook (STORAGE.md, the voter): the proposal reference and its expiry
+ deletions go through it like the branch, so in authoritative mode each is a changeset committed
+ with the database compare-and-swap, with the pack of its objects uploaded before. They are not
+ changelog entries: `changelog.ParseUpdates` and `corestore.IsChangelogRef` admit only refs/heads/
+ and refs/tags/. The objects reach other nodes with the changeset pack, so the agent can read them
+ on any node.
+* **(b) Visibility and access (checked).** refs/graft/ is not hidden today:
+ `git.InternalRefPrefixes` lists refs/environments, refs/keep-around, refs/merge-requests,
+ refs/pipelines, refs/remotes and refs/tmp only. `refs/graft/proposals/` is added as an
+ InternalReferenceTypeHidden prefix, so receive-pack hides it (no client can create, update or
+ delete it by a push) and upload-pack does not advertise it. Agents cannot write references
+ directly (WriteRef, UpdateReferences and DeleteRefs are never allowed for agents,
+ AGENT-SECURITY.md). The agent reads the proposal with ObjectService.GetObjects, which agents may
+ call and which reads objects by OID with git cat-file, without a reachability check. Observation,
+ left as it is: graft-verify's refs/graft/green/ is not hidden either (advertised and pushable).
+* **CLI and SDK.** `graft land --conflicts-dir DIR` writes each proposal to DIR/proposals/<path> (a
+ proposal that cannot be read is reported and fails nothing else) and prints which files have one;
+ `--resolved` is unchanged, so a proposal copied into DIR/files lands as the agent's. The SDK's
+ ConflictSides gains the proposal (content, strategy, explanation), and ResolutionFromProposals
+ starts a resolution from them (ResolutionFor is unchanged).
+* **The PM's four conditions (implemented).**
+ 1. One writer, one prefix: landUpdateProposalRefs is the only function that writes these
+ references. It refuses any name but refs/graft/proposals/<16 hex>/<object ID> before git
+ runs, and updates as the server (no request identity), so the agent's policy does not judge
+ the server's write. It is called only by landWriteProposals and the pruning.
+ 2. refs/graft/** is reserved: the reference-transaction hook refuses any update under it by an
+ agent identity, whatever the policy says and even with no policy, so a push, UpdateReferences,
+ DeleteRefs, WriteRef or an operation RPC fails. CheckAgentPolicy refuses it early too.
+ graft-verify writes refs/graft/green/ with the shared token, which is not an agent.
+ 3. Hidden: refs/graft/proposals/ is hidden from advertisement and push. Two points are not
+ covered, stated here: graft-verify's refs/graft/green/ is still advertised (hiding it changes
+ graft-verify's users and needs its own decision), and an agent's read accessors (ListRefs,
+ FindRefsByOID and the like) still list the names and OIDs of refs/graft/ references (no
+ content; the blobs are read by OID as before). Filtering those is a change of the ref service
+ for agents, proposed as its own step.
+ 4. Trace: the proposals' commit carries `Requested-By: <actor>` (the agent, or the user ID of the
+ request) and the resolver; the server logs the reference, the actor and the resolver. The
+ update itself is the server's.
+ An end-to-end test runs the real graft-resolve with a model behind the command provider, under the
+ example policy that gives the agent no refs/graft/ rule: the server proposes, the SDK reads the
+ proposal, the agent lands it as its own (Graft-Resolved-By: agent/<actor>), and the proposal
+ reference is dropped.
+* **Amendment: Federico's product decision (2026-10-19, relayed by the PM).** "When the server AI
+ is configured, the server always tries to resolve, and it LANDS its resolution by itself ONLY if
+ the proposal passes every deterministic check: syntax, anchors, no markers, and the composition
+ check from §15 (keeps both changes, no duplicated both-added lines). There is still no
+ self-declared confidence. If any check fails, the resolution goes to the agent as a proposal,
+ with its report. If no AI is configured, the agent always resolves."
+ * Gated on §15: until the composition check exists and is measured, a model's resolution stays a
+ proposal, as implemented above. The composition check is what turns a proposal into a landable
+ resolution; the rule "the server never lands llm output" becomes "the server lands llm output
+ only when the composition check passed in this process", in one function, with tests.
+ * Before it is enabled: the coverage (how many land by themselves) and the precision (how many of
+ those are wrong), per language with a confidence interval, on the 300 cases; the default goes on
+ only with Federico's OK after he sees them.
+ * An AI-landed merge is signed Graft-Resolved-By: llm/<model> and Graft-Checked-By:
+ syntax,composition, and the trace records the proposal and the report.
+ * Everything above still applies: a resolution that fails a check is a proposal.
diff --git a/doc/graft/RESOLVE.md b/doc/graft/RESOLVE.md
index 5747787..070b66d 100644
--- a/doc/graft/RESOLVE.md
+++ b/doc/graft/RESOLVE.md
@@ -74,8 +74,9 @@ A client asks for resolution per call:
resolved paths and the resolver name. On a conflict the server did not
resolve, `sdk.LandConflict(err)` returns the conflict package,
`Repo.ConflictSides` reads the sides (a side that cannot be read is nil,
- with its reason in `Unreadable`), and `LandOptions.Resolution`
- (start from `sdk.ResolutionFor`) lands the agent's resolution. `Land`
+ with its reason in `Unreadable`) and the proposal of a file that has one,
+ and `LandOptions.Resolution` (start from `sdk.ResolutionFor`, or from the
+ proposals with `sdk.ResolutionFromProposals`) lands the agent's resolution. `Land`
refuses a resolution whose request exceeds `sdk.MaxLandRequestBytes`
(4 MiB) before sending it.
- CLI: `graft land --resolve`, `graft commit --land BRANCH --resolve`.
@@ -83,7 +84,8 @@ A client asks for resolution per call:
`--conflicts-dir DIR` writes it: `DIR/files/<path>` is the merge with git's
diff3 markers (the clean changes of both sides applied), the sides are in
`DIR/sides/base/<path>`, `DIR/sides/ours/<path>` and
- `DIR/sides/theirs/<path>`, the package in `DIR/conflict.json`. Each
+ `DIR/sides/theirs/<path>`, a proposal in `DIR/proposals/<path>` (copy it
+ over the file to land it as yours), the package in `DIR/conflict.json`. Each
directory mirrors the tree of the merge, so no repository path can collide
with a side, another path's side or the package. A side the package gives no
object ID (see `unavailable` below), or that the server cannot return, is
@@ -131,7 +133,7 @@ A client asks for resolution per call:
[What is never sent](#what-is-never-sent)), sends the others to the
resolver in one request (protocol below), and validates the answer (see
[Validation](#validation)).
-4. Only when every file is resolved, it builds the merged tree from the
+4. Only when every file is resolved by rules alone, it builds the merged tree from the
merge-tree result, writes the resolved
files as new blobs or deletes them, and creates a merge commit with parents
`[tip, commit]`. The message is `merge_message` or
@@ -149,12 +151,41 @@ A client asks for resolution per call:
against the new tip.
Otherwise (resolution disabled or refused, a file that is never sent, an
-invalid answer, a timeout, an unresolvable file) the land fails with the
-normal `merge_conflict` error, the reason is logged, and the error carries the
-conflict package as a second detail (see
+invalid answer, a timeout, an unresolvable file, or a file a model resolved)
+the land fails with the normal `merge_conflict` error, the reason is logged,
+and the error carries the conflict package as a second detail (see
[The conflict package and the re-land](#the-conflict-package-and-the-re-land)).
Nothing lands partially: the branch is never left in a partial state.
+### Proposals: a model's resolution never lands
+
+The server never lands what a model resolved: the agent always resolves
+(PLAN10 14). graft-resolve marks every file its `llm` strategy resolved as a
+proposal (`"proposal": true`), and the server treats an answer as proposing
+when a file is marked, or when the resolver names the `llm` strategy without
+marking any. Such a land fails with the package: the model's files are
+`PROPOSED`, the files the rules resolved keep `RESOLVED`, and every file the
+answer resolved carries its `proposal` (action, blob OID, mode, resolver, and
+the explanation cut to 512 bytes). An answer that does not land for another
+reason (a file left to the agent, a mode no side has) is kept the same way, so
+that the agent can land the rules' files as they are.
+
+The proposals are kept under a hidden reference,
+`refs/graft/proposals/<first 16 hex of sha256(branch)>/<commit>`, named in the
+package's `proposal_ref`: a commit whose tree holds the proposed files by
+path, with parents `[tip, commit]`, whose message names the resolver and
+`Requested-By:` the actor of the land. One reference per branch and landed
+commit, replaced by every failed land of that commit. The server writes it
+itself, through the reference transaction like any update (and so the storage
+core in authoritative mode), and refuses to write any other reference this
+way. The agent reads the proposals by OID with `GetBlobs`; it cannot see the
+reference in an advertisement nor push to it, and no agent may update
+anything under `refs/graft/`, whatever the policy says. Every land that asks
+for resolution or brings one prunes the branch's proposals older than
+`proposal_ttl` (default 7 days) and keeps at most 20; the agent's land of the
+change drops that change's proposal. A proposal that cannot be written fails
+the land with `Internal`, never with a package that lacks it.
+
Every resolution is logged at info level as `graft: conflicts of land
resolved`, with the branch, the tip, the landed commit, the merge commit, the
actor, the resolver name, the resolved paths and the `explanation` of the
@@ -375,7 +406,9 @@ the error unchanged. The package holds:
- both commit messages, cut to 4 KiB each, with `messages_truncated`;
- `reason`, when the server did not attempt the request at all;
- every conflicting file: the path, the kind, each side's mode and blob OID,
- the conflicting hunks, the outcome and its reason (cut to 512 bytes);
+ the conflicting hunks, the outcome and its reason (cut to 512 bytes), and
+ the resolver's `proposal`, when it made one;
+- `proposal_ref`, the hidden reference that keeps the proposals;
- `messages`: git's messages about the merge (the paths, the type such as
`CONFLICT (rename/delete)`, the text), which also describe a conflict that
has no conflicting file.
@@ -405,7 +438,8 @@ sides read and 64 Mi cells of diff work for its hunks, and 4 MiB encoded
| `NOT_SENT` | never sent (see above); the reason says why |
| `REJECTED` | the result failed a rule or a check, e.g. a syntax error at line:column |
| `FAILED` | the resolver failed on it: a model error, `AI budget exhausted`, no strategy applied |
-| `RESOLVED` | resolved, but the land failed because another file was not |
+| `RESOLVED` | resolved by rules, but the land failed because another file was not; see `proposal` |
+| `PROPOSED` | a model resolved it: proposed, never landed; see `proposal` |
| `NOT_ATTEMPTED` | the request was not attempted; see `reason` |
The agent reads the sides by OID with `GetBlobs`, resolves every file, and
diff --git a/internal/git/reference.go b/internal/git/reference.go
index 9ddbba7..ba57b25 100644
--- a/internal/git/reference.go
+++ b/internal/git/reference.go
@@ -76,6 +76,10 @@ var InternalRefPrefixes = map[string]InternalReferenceType{
// Temporary references are used internally by Rails for various operations and should not
// be exposed to the user.
"refs/tmp/": InternalReferenceTypeHidden,
+
+ // The proposals of a land that the server did not resolve (PLAN10 14): written by the server
+ // only, read by object ID, never advertised nor writable by a push.
+ "refs/graft/proposals/": InternalReferenceTypeHidden,
}
// ObjectPoolRefNamespace is the namespace used for the references of the primary pool member part
diff --git a/internal/gitaly/config/config_graft.go b/internal/gitaly/config/config_graft.go
index 455fbc8..15ef829 100644
--- a/internal/gitaly/config/config_graft.go
+++ b/internal/gitaly/config/config_graft.go
@@ -323,6 +323,10 @@ type GraftResolver struct {
// each holds a check request of up to GraftResolverMaxCheckRequestBytes. Zero means
// DefaultGraftResolverCheckConcurrency.
CheckConcurrency int `json:"check_concurrency" toml:"check_concurrency,omitempty"`
+ // ProposalTTL is how long the server keeps the proposals of a failed land
+ // (refs/graft/proposals/), as a Go duration ("168h"). Empty means
+ // DefaultGraftResolverProposalTTL.
+ ProposalTTL string `json:"proposal_ttl" toml:"proposal_ttl,omitempty"`
}
// GraftResolverVerify is the optional verification of a resolution: Command
@@ -502,6 +506,9 @@ func (r GraftResolver) validate() error {
if _, err := r.TimeoutOrDefault(); err != nil {
return err
}
+ if _, err := r.ProposalTTLOrDefault(); err != nil {
+ return err
+ }
if r.MaxFiles < 0 || r.MaxFileBytes < 0 || r.CheckConcurrency < 0 {
return fmt.Errorf("graft land resolver: max_files, max_file_bytes and check_concurrency must not be negative")
}
@@ -571,6 +578,22 @@ func (r GraftResolver) CheckConcurrencyOrDefault() int {
return DefaultGraftResolverCheckConcurrency
}
+// DefaultGraftResolverProposalTTL is the default of GraftResolver.ProposalTTL: a week.
+const DefaultGraftResolverProposalTTL = "168h"
+
+// ProposalTTLOrDefault parses ProposalTTL, or returns its default.
+func (r GraftResolver) ProposalTTLOrDefault() (time.Duration, error) {
+ s := r.ProposalTTL
+ if s == "" {
+ s = DefaultGraftResolverProposalTTL
+ }
+ d, err := time.ParseDuration(s)
+ if err != nil || d <= 0 {
+ return 0, fmt.Errorf("graft land resolver: invalid proposal_ttl %q", r.ProposalTTL)
+ }
+ return d, nil
+}
+
// MaxFilesOrDefault returns MaxFiles or its default.
func (r GraftResolver) MaxFilesOrDefault() int {
if r.MaxFiles > 0 {
diff --git a/internal/gitaly/config/config_graft_resolver_test.go b/internal/gitaly/config/config_graft_resolver_test.go
index 9e6c337..0b8950c 100644
--- a/internal/gitaly/config/config_graft_resolver_test.go
+++ b/internal/gitaly/config/config_graft_resolver_test.go
@@ -99,12 +99,14 @@ func TestGraftResolverValidateBuildable(t *testing.T) {
r GraftResolver
want string
}{
- "empty command": {GraftResolver{Command: []string{""}}, "empty command"},
- "url without scheme": {GraftResolver{URL: "resolver.example/resolve"}, "http or https URL with a host"},
- "url of another kind": {GraftResolver{URL: "ftp://resolver.example/"}, "http or https URL with a host"},
- "url without host": {GraftResolver{URL: "http:///resolve"}, "http or https URL with a host"},
- "missing token file": {GraftResolver{URL: "https://resolver.example/", TokenFile: filepath.Join(dir, "absent")}, "read token file"},
- "empty token file": {GraftResolver{URL: "https://resolver.example/", TokenFile: empty}, "is empty"},
+ "empty command": {GraftResolver{Command: []string{""}}, "empty command"},
+ "url without scheme": {GraftResolver{URL: "resolver.example/resolve"}, "http or https URL with a host"},
+ "url of another kind": {GraftResolver{URL: "ftp://resolver.example/"}, "http or https URL with a host"},
+ "url without host": {GraftResolver{URL: "http:///resolve"}, "http or https URL with a host"},
+ "missing token file": {GraftResolver{URL: "https://resolver.example/", TokenFile: filepath.Join(dir, "absent")}, "read token file"},
+ "empty token file": {GraftResolver{URL: "https://resolver.example/", TokenFile: empty}, "is empty"},
+ "proposal_ttl not a duration": {GraftResolver{Command: []string{"graft-resolve"}, ProposalTTL: "a week"}, "proposal_ttl"},
+ "proposal_ttl zero": {GraftResolver{Command: []string{"graft-resolve"}, ProposalTTL: "0s"}, "proposal_ttl"},
"negative check_concurrency": {
GraftResolver{Command: []string{"graft-resolve"}, CheckConcurrency: -1}, "must not be negative",
},
@@ -120,6 +122,9 @@ func TestGraftResolverValidateBuildable(t *testing.T) {
})
}
+ ttl, err := GraftResolver{}.ProposalTTLOrDefault()
+ require.NoError(t, err)
+ require.Equal(t, "168h0m0s", ttl.String())
require.Equal(t, DefaultGraftResolverCheckConcurrency, GraftResolver{}.CheckConcurrencyOrDefault())
require.Equal(t, 5, GraftResolver{CheckConcurrency: 5}.CheckConcurrencyOrDefault())
}
diff --git a/internal/gitaly/hook/referencetransaction.go b/internal/gitaly/hook/referencetransaction.go
index 7c40d74..d7f335d 100644
--- a/internal/gitaly/hook/referencetransaction.go
+++ b/internal/gitaly/hook/referencetransaction.go
@@ -377,12 +377,17 @@ func (m *GitLabHookManager) enforceGraftPolicy(ctx context.Context, env []string
// denial of the transaction, or an empty message when the policy allows it or
// does not apply to it.
func (m *GitLabHookManager) graftPolicyDecision(env []string, changes []byte) (string, error) {
- if !m.cfg.Graft.Standalone || len(m.cfg.Graft.Policy) == 0 {
+ if !m.cfg.Graft.Standalone {
return "", nil
}
meta, err := gitcmd.ChangelogMetaFromEnv(env)
if err != nil {
+ if len(m.cfg.Graft.Policy) == 0 {
+ // Without a policy the metadata decides nothing but the reservation of refs/graft/,
+ // which needs an agent the metadata names.
+ return "", nil
+ }
return "", fmt.Errorf("reading graft metadata: %w", err)
}
@@ -406,6 +411,14 @@ func (m *GitLabHookManager) graftPolicyDecision(env []string, changes []byte) (s
return "", nil
}
+ // refs/graft/ is the server's, whatever the policy says.
+ if message := graftReservedDenial(changes); message != "" {
+ return message, nil
+ }
+ if len(m.cfg.Graft.Policy) == 0 {
+ return "", nil
+ }
+
message, err := graftPolicyDenial(m.cfg.Graft.Policy, meta.Actor, changes)
if err != nil {
return "", fmt.Errorf("evaluating graft policy: %w", err)
@@ -425,7 +438,7 @@ func (m *GitLabHookManager) graftPolicyDecision(env []string, changes []byte) (s
// a per-agent token, outside standalone mode or with an empty policy it does
// nothing, and the decision is final: the hook still runs afterwards.
func CheckAgentPolicy(ctx context.Context, graft config.Graft, changes string) error {
- if !graft.Standalone || len(graft.Policy) == 0 {
+ if !graft.Standalone {
return nil
}
@@ -433,6 +446,12 @@ func CheckAgentPolicy(ctx context.Context, graft config.Graft, changes string) e
if !ok || id.Source != identity.SourceAgent {
return nil
}
+ if message := graftReservedDenial([]byte(changes)); message != "" {
+ return structerr.NewPermissionDenied("%s", message)
+ }
+ if len(graft.Policy) == 0 {
+ return nil
+ }
message, err := graftPolicyDenial(graft.Policy, id.Name, []byte(changes))
if err != nil {
@@ -474,6 +493,23 @@ func graftPolicyDenial(policy []config.GraftPolicyRule, actor string, changes []
return message, nil
}
+// GraftReservedRefPrefix is the namespace of the references that only the server writes: the
+// proposals of a land (refs/graft/proposals/) and graft-verify's green references, which it
+// writes with the shared token. An agent never creates, updates or deletes a reference under it,
+// whatever the policy says, by any RPC or a push: the reference-transaction hook refuses it.
+const GraftReservedRefPrefix = "refs/graft/"
+
+// graftReservedDenial returns the denial of changes that update a reference under
+// GraftReservedRefPrefix, or "".
+func graftReservedDenial(changes []byte) string {
+ for _, line := range strings.Split(string(changes), "\n") {
+ if _, _, reference, ok := changelog.ParseHookLine(line); ok && strings.HasPrefix(reference, GraftReservedRefPrefix) {
+ return fmt.Sprintf("%q is under %s, which is reserved for the server: agents may not update it", reference, GraftReservedRefPrefix)
+ }
+ }
+ return ""
+}
+
// isGovernedReference reports whether the standalone access policy governs an
// update of reference: every reference under refs/, and HEAD.
func isGovernedReference(reference string) bool {
diff --git a/internal/gitaly/hook/referencetransaction_policy_test.go b/internal/gitaly/hook/referencetransaction_policy_test.go
index b78afe5..e746535 100644
--- a/internal/gitaly/hook/referencetransaction_policy_test.go
+++ b/internal/gitaly/hook/referencetransaction_policy_test.go
@@ -209,3 +209,29 @@ func TestEnforceGraftPolicy_Concurrent(t *testing.T) {
require.NoError(t, err)
}
}
+
+// TestEnforceGraftPolicy_refsGraftIsReserved: an agent may never update a reference under
+// refs/graft/, whatever the policy says, even with no policy at all; the server and callers that
+// are not agents may.
+func TestEnforceGraftPolicy_refsGraftIsReserved(t *testing.T) {
+ t.Parallel()
+
+ ctx := testhelper.Context(t)
+ allowAll := []config.GraftPolicyRule{{Actor: "agent-a", Refs: []string{"**"}, Allow: true}}
+ for name, policy := range map[string][]config.GraftPolicyRule{"a policy that allows all": allowAll, "no policy": nil} {
+ m := graftPolicyManager(t, config.Graft{Standalone: true, Policy: policy})
+ for _, ref := range []string{"refs/graft/proposals/0123456789abcdef/1", "refs/graft/green/main"} {
+ err := m.enforceGraftPolicy(ctx, policyEnv(t, "agent-a", true), policyChanges("refs/heads/main", ref))
+ require.Equal(t, codes.PermissionDenied, status.Code(err), "%s: %s", name, ref)
+ require.ErrorContains(t, err, "reserved for the server", "%s: %s", name, ref)
+ }
+ // Not an agent (the server, the shared token): allowed.
+ require.NoError(t, m.enforceGraftPolicy(ctx, policyEnv(t, "", false), policyChanges("refs/graft/proposals/0123456789abcdef/1")), name)
+ // Other references of an agent follow the policy as before.
+ require.NoError(t, m.enforceGraftPolicy(ctx, policyEnv(t, "agent-a", true), policyChanges("refs/heads/main")), name)
+ }
+
+ // Outside standalone mode nothing is decided here.
+ m := graftPolicyManager(t, config.Graft{})
+ require.NoError(t, m.enforceGraftPolicy(ctx, policyEnv(t, "agent-a", true), policyChanges("refs/graft/green/main")))
+}
diff --git a/internal/gitaly/service/operations/land.go b/internal/gitaly/service/operations/land.go
index c884158..d106627 100644
--- a/internal/gitaly/service/operations/land.go
+++ b/internal/gitaly/service/operations/land.go
@@ -82,13 +82,19 @@ func (s *Server) UserLand(ctx context.Context, in *gitalypb.UserLandRequest) (*g
}
if s.landBatchable(ctx, in) {
- return s.userLandBatched(ctx, in, committer, precheck)
+ resp, err := s.userLandBatched(ctx, in, committer, precheck)
+ if err != nil {
+ return nil, err
+ }
+ s.landPruneAfterLand(ctx, in)
+ return resp, nil
}
resp, err := s.landWithRetries(ctx, in, committer, precheck)
if err != nil {
return nil, err
}
+ s.landPruneAfterLand(ctx, in)
// A request that lands alone is a batch of one.
resp.BatchSize = 1
diff --git a/internal/gitaly/service/operations/land_package.go b/internal/gitaly/service/operations/land_package.go
index f285234..052d0fb 100644
--- a/internal/gitaly/service/operations/land_package.go
+++ b/internal/gitaly/service/operations/land_package.go
@@ -88,6 +88,9 @@ type landFileState struct {
hunksOmitted string
// unavailable is set when a present side's blob is not kept in the repository.
unavailable bool
+ // proposal is the resolver's resolution of the file in a land that did not happen, kept under
+ // the proposal reference of the package (landWriteProposals).
+ proposal *gitalypb.LandConflictProposal
}
// sent reports whether the file is sent to the resolver.
@@ -139,8 +142,13 @@ func (e *landUnresolvedError) Unwrap() error {
// landWithPackage adds the conflict package of resolveErr, when it carries one, to the merge
// conflict error of the land as a second detail, after UserLandError. Clients that know only
// UserLandError see the error unchanged. A package that cannot be built (a side that cannot be
-// read) is an internal error: the merge conflict alone would hide it.
+// read), or a resolver's answer that cannot be kept as proposals, is an internal error: the merge
+// conflict alone would hide it.
func landWithPackage(ctx context.Context, mergeConflict, resolveErr error) error {
+ var proposalsErr *landProposalsError
+ if errors.As(resolveErr, &proposalsErr) {
+ return structerr.NewInternal("%w", proposalsErr)
+ }
var unresolved *landUnresolvedError
var se structerr.Error
if !errors.As(resolveErr, &unresolved) || !errors.As(mergeConflict, &se) {
@@ -197,6 +205,7 @@ func (l landListing) conflictPackage(ctx context.Context, reason string) (*gital
CommitMessage: cm,
MessagesTruncated: tipCut || commitCut,
Reason: landCutString(reason, landPackageReasonBytes),
+ ProposalRef: l.proposalRef.String(),
}
for i, m := range l.messages {
if i == landMaxPackageMessages {
@@ -223,6 +232,7 @@ func (l landListing) conflictPackage(ctx context.Context, reason string) (*gital
Outcome: f.outcome,
Reason: landCutString(f.reason, landPackageReasonBytes),
SyntaxUnchecked: f.syntaxUnchecked,
+ Proposal: f.proposal,
}
f.unavailable = false
for _, s := range []struct {
diff --git a/internal/gitaly/service/operations/land_proposals.go b/internal/gitaly/service/operations/land_proposals.go
new file mode 100644
index 0000000..0485648
--- /dev/null
+++ b/internal/gitaly/service/operations/land_proposals.go
@@ -0,0 +1,313 @@
+package operations
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "errors"
+ "fmt"
+ "path"
+ "sort"
+ "strings"
+ "time"
+
+ "github.com/prometheus/client_golang/prometheus"
+ "github.com/prometheus/client_golang/prometheus/promauto"
+
+ "github.com/feder-cr/git-ai/internal/git"
+ "github.com/feder-cr/git-ai/internal/git/localrepo"
+ "github.com/feder-cr/git-ai/internal/git/updateref"
+ "github.com/feder-cr/git-ai/internal/graft/identity"
+ "github.com/feder-cr/git-ai/internal/graft/resolver"
+ "github.com/feder-cr/git-ai/internal/log"
+ "github.com/feder-cr/git-ai/proto/go/gitalypb"
+)
+
+// A resolution that a model made is never landed by the server: it is a proposal, which the agent
+// reviews, edits or replaces, and lands as its own (PLAN10 14). The server keeps the proposals of a
+// failed land under a hidden reference, which the agent reads by object ID (GetObjects).
+
+const (
+ // landProposalRefPrefix is the hidden namespace of the proposals (git.InternalRefPrefixes).
+ landProposalRefPrefix = "refs/graft/proposals/"
+ // landMaxProposalsPerBranch bounds the proposal references kept for one branch.
+ landMaxProposalsPerBranch = 20
+)
+
+// landProposalPruneErrors counts the proposal references that could not be pruned after a land.
+var landProposalPruneErrors = promauto.NewCounter(prometheus.CounterOpts{
+ Name: "graft_land_proposal_prune_errors_total",
+ Help: "Prunings of the proposal references of a branch that failed after a land.",
+})
+
+// landProposalBranchDir is the directory of the proposal references of a branch: a hash of the
+// branch name, so that any branch name gives a valid and fixed-length component.
+func landProposalBranchDir(branch string) string {
+ sum := sha256.Sum256([]byte(branch))
+ return landProposalRefPrefix + hex.EncodeToString(sum[:])[:16] + "/"
+}
+
+// landProposalRef is the reference that keeps the proposals of the land of commit onto branch.
+func landProposalRef(branch string, commit git.ObjectID) git.ReferenceName {
+ return git.ReferenceName(landProposalBranchDir(branch) + commit.String())
+}
+
+// landProposalsError is the failure to keep a resolver's answer as proposals. The land fails with
+// Internal (landWithPackage): a package without the proposals would hide the answer.
+type landProposalsError struct{ err error }
+
+func (e *landProposalsError) Error() string {
+ return "keeping the resolver's answer as proposals: " + e.err.Error()
+}
+
+func (e *landProposalsError) Unwrap() error { return e.err }
+
+// landProposedReason is the reason of a file that a model resolved.
+const landProposedReason = "a model resolved the file: the server never lands a model's resolution, it proposes it (see proposal); land it, edited or not, as your own resolution"
+
+// landAnswerFlagsProposals reports whether a file of the answer is marked as a proposal.
+func landAnswerFlagsProposals(answer *resolver.Response) bool {
+ for _, f := range answer.Files {
+ if f.Proposal {
+ return true
+ }
+ }
+ return false
+}
+
+// landAnswerProposes reports whether a resolver's answer holds a model's resolution: a file marked
+// as a proposal, or, should a resolver omit the mark, a resolver that names the llm strategy.
+func landAnswerProposes(answer *resolver.Response) bool {
+ if landAnswerFlagsProposals(answer) {
+ return true
+ }
+ name := answer.Resolver
+ if i := strings.IndexByte(name, '/'); i >= 0 {
+ name = name[i+1:]
+ }
+ for _, strategy := range strings.Split(name, ",") {
+ if strings.TrimSpace(strategy) == "llm" {
+ return true
+ }
+ }
+ return false
+}
+
+// landWriteProposals keeps the resolver's answer for the agent: the written contents as blobs, a
+// commit whose tree holds them by path (its parents the tip and the landed commit), and the
+// proposal reference of (branch, commit) pointing at it, replacing an older one. The objects are
+// written into the repository itself, not the quarantine of the land, which a failed land discards,
+// and the reference is updated through the reference transaction (and so the voter in
+// authoritative storage mode). It sets the proposal of every file of the listing and returns the
+// reference. The branch's older proposals are pruned after; a failed pruning is logged and
+// counted, and fails nothing.
+func (s *Server) landWriteProposals(ctx context.Context, in *gitalypb.UserLandRequest, l landListing, answer *resolver.Response, committer git.Signature) (git.ReferenceName, error) {
+ // Who caused the proposals is in their commit, the trace of the reference: the update itself
+ // is the server's (landUpdateProposalRefs).
+ actor := landBatchActor(ctx, in)
+ repo := s.localRepoFactory.Build(in.GetRepository())
+ tree := &localrepo.TreeEntry{Type: localrepo.Tree, Mode: "040000"}
+ byPath := make(map[string]*gitalypb.LandConflictProposal, len(answer.Files))
+ explanation := landCutString(answer.Explanation, landPackageReasonBytes)
+ for _, f := range answer.Files {
+ p := &gitalypb.LandConflictProposal{Action: f.Action, Resolver: answer.Resolver, Explanation: explanation}
+ if f.Action == resolver.ActionWrite {
+ blob, err := repo.WriteBlob(ctx, bytes.NewReader(f.Content), localrepo.WriteBlobConfig{Path: f.Path})
+ if err != nil {
+ return "", fmt.Errorf("writing the proposal of %q: %w", f.Path, err)
+ }
+ entry := localrepo.TreeEntry{OID: blob, Mode: f.Mode, Path: path.Base(f.Path), Type: localrepo.Blob}
+ if err := tree.Add(f.Path, entry, localrepo.WithOverwriteFile()); err != nil {
+ return "", fmt.Errorf("adding the proposal of %q: %w", f.Path, err)
+ }
+ p.Oid, p.Mode = blob.String(), f.Mode
+ }
+ byPath[f.Path] = p
+ }
+ if err := tree.Write(ctx, repo); err != nil {
+ return "", fmt.Errorf("writing the tree of the proposals: %w", err)
+ }
+ commit, err := repo.WriteCommit(ctx, localrepo.WriteCommitConfig{
+ TreeID: tree.OID,
+ Message: fmt.Sprintf("graft: proposals for landing %s onto %s\n\nResolver: %s\nRequested-By: %s\n", l.commitID, l.tip, answer.Resolver, actor),
+ Parents: []git.ObjectID{l.tip, l.commitID},
+ AuthorName: committer.Name,
+ AuthorEmail: committer.Email,
+ AuthorDate: committer.When,
+ CommitterName: committer.Name,
+ CommitterEmail: committer.Email,
+ CommitterDate: committer.When,
+ GitConfig: s.gitConfig,
+ })
+ if err != nil {
+ return "", fmt.Errorf("writing the commit of the proposals: %w", err)
+ }
+
+ ref := landProposalRef(string(in.GetBranch()), l.commitID)
+ old, err := repo.GetReference(ctx, ref)
+ oldOID := git.ObjectID("")
+ switch {
+ case err == nil:
+ oldOID = git.ObjectID(old.Target)
+ case !errors.Is(err, git.ErrReferenceNotFound):
+ return "", fmt.Errorf("reading %s: %w", ref, err)
+ }
+ objectHash, err := repo.ObjectHash(ctx)
+ if err != nil {
+ return "", fmt.Errorf("detecting object hash: %w", err)
+ }
+ if oldOID == "" {
+ oldOID = objectHash.ZeroOID
+ }
+ if err := s.landUpdateProposalRefs(ctx, repo, []landProposalRefOp{{name: ref, newOID: commit, oldOID: oldOID}}); err != nil {
+ return "", err
+ }
+ s.logger.WithFields(log.Fields{"ref": ref.String(), "actor": actor, "resolver": answer.Resolver}).InfoContext(ctx, "graft: kept the resolver's answer as proposals")
+
+ for _, f := range l.files {
+ f.proposal = byPath[f.conflict.path]
+ }
+ if err := s.landPruneProposals(ctx, repo, string(in.GetBranch()), ""); err != nil {
+ landProposalPruneErrors.Inc()
+ s.logger.WithError(err).WithField("branch", string(in.GetBranch())).ErrorContext(ctx, "graft: pruning the proposals of the branch failed")
+ }
+ return ref, nil
+}
+
+// landPruneProposals deletes the proposal references of a branch that are older than proposal_ttl
+// (by the committer date of their commit) or beyond the newest landMaxProposalsPerBranch, and drop,
+// when set: the proposal of a commit that landed. The deletions go through the reference
+// transaction, as the writes do.
+func (s *Server) landPruneProposals(ctx context.Context, repo *localrepo.Repo, branch string, drop git.ReferenceName) error {
+ ttl, err := s.resolveCfg.ProposalTTLOrDefault()
+ if err != nil {
+ return err
+ }
+ refs, err := repo.GetReferences(ctx, landProposalBranchDir(branch))
+ if err != nil {
+ return fmt.Errorf("listing the proposals of %q: %w", branch, err)
+ }
+ type dated struct {
+ name git.ReferenceName
+ when time.Time
+ }
+ var kept []dated
+ var remove []git.ReferenceName
+ now := time.Now()
+ for _, r := range refs {
+ if r.Name == drop {
+ remove = append(remove, r.Name)
+ continue
+ }
+ c, err := repo.ReadCommit(ctx, git.Revision(r.Target))
+ if err != nil {
+ return fmt.Errorf("reading %s: %w", r.Name, err)
+ }
+ when := c.GetCommitter().GetDate().AsTime()
+ if now.Sub(when) > ttl {
+ remove = append(remove, r.Name)
+ continue
+ }
+ kept = append(kept, dated{r.Name, when})
+ }
+ sort.Slice(kept, func(i, j int) bool { return kept[i].when.After(kept[j].when) })
+ for i := landMaxProposalsPerBranch; i < len(kept); i++ {
+ remove = append(remove, kept[i].name)
+ }
+ if len(remove) == 0 {
+ return nil
+ }
+ deletions := make([]landProposalRefOp, 0, len(remove))
+ for _, name := range remove {
+ deletions = append(deletions, landProposalRefOp{name: name, delete: true})
+ }
+ if err := s.landUpdateProposalRefs(ctx, repo, deletions); err != nil {
+ return fmt.Errorf("pruning proposals: %w", err)
+ }
+ return nil
+}
+
+// landProposalRefOp is one update of a proposal reference: to newOID from oldOID, or a deletion.
+type landProposalRefOp struct {
+ name git.ReferenceName
+ newOID, oldOID git.ObjectID
+ delete bool
+}
+
+// landUpdateProposalRefs is the one writer of the proposal references (PLAN10 14): it updates
+// only references of the form refs/graft/proposals/<16 hex of the branch>/<commit ID>, and refuses
+// anything else before git runs. It updates them as the server, without the identity of the
+// request, through the reference transaction like any update: the agent whose land made the
+// proposals may not write refs/graft/ itself (the reference-transaction hook reserves it), and
+// its policy does not judge the server's write. Who caused it is in the proposals' commit.
+func (s *Server) landUpdateProposalRefs(ctx context.Context, repo *localrepo.Repo, ops []landProposalRefOp) error {
+ for _, op := range ops {
+ if !landProposalRefNameValid(op.name) {
+ return fmt.Errorf("refusing to update %q: not a proposal reference", op.name)
+ }
+ }
+ ctx = identity.NewContext(ctx, identity.Identity{})
+ updater, err := updateref.New(ctx, repo)
+ if err != nil {
+ return fmt.Errorf("updating proposal references: %w", err)
+ }
+ defer func() { _ = updater.Close() }()
+ if err := updater.Start(); err != nil {
+ return fmt.Errorf("updating proposal references: %w", err)
+ }
+ for _, op := range ops {
+ if op.delete {
+ err = updater.Delete(op.name)
+ } else {
+ err = updater.Update(op.name, op.newOID, op.oldOID)
+ }
+ if err != nil {
+ return fmt.Errorf("updating %s: %w", op.name, err)
+ }
+ }
+ if err := updater.Commit(); err != nil {
+ return fmt.Errorf("updating proposal references: %w", err)
+ }
+ return nil
+}
+
+// landProposalRefNameValid reports whether name is refs/graft/proposals/<16 hex>/<object ID>.
+func landProposalRefNameValid(name git.ReferenceName) bool {
+ rest, ok := strings.CutPrefix(name.String(), landProposalRefPrefix)
+ if !ok {
+ return false
+ }
+ dir, commit, ok := strings.Cut(rest, "/")
+ return ok && len(dir) == 16 && landHex(dir) && (len(commit) == 40 || len(commit) == 64) && landHex(commit)
+}
+
+// landHex reports whether s is lower-case hexadecimal.
+func landHex(s string) bool {
+ for _, c := range s {
+ if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
+ return false
+ }
+ }
+ return true
+}
+
+// landPruneAfterLand prunes the proposals of the branch after a land that asked for resolution or
+// brought one, and drops the proposal of the change that landed. Only those lands prune, so that a
+// plain land pays nothing for proposals; the bound of landMaxProposalsPerBranch holds anyway, since
+// only those lands write proposals. The land has happened: a failure is logged and counted, and
+// the land's result stands.
+func (s *Server) landPruneAfterLand(ctx context.Context, in *gitalypb.UserLandRequest) {
+ if !in.GetResolveConflicts() && in.GetResolution() == nil {
+ return
+ }
+ repo := s.localRepoFactory.Build(in.GetRepository())
+ drop := git.ReferenceName("")
+ if commitID, err := repo.ResolveRevision(ctx, git.Revision(in.GetCommitId()+"^{commit}")); err == nil {
+ drop = landProposalRef(string(in.GetBranch()), commitID)
+ }
+ if err := s.landPruneProposals(ctx, repo, string(in.GetBranch()), drop); err != nil {
+ landProposalPruneErrors.Inc()
+ s.logger.WithError(err).WithField("branch", string(in.GetBranch())).ErrorContext(ctx, "graft: pruning the proposals of the branch failed after the land")
+ }
+}
diff --git a/internal/gitaly/service/operations/land_proposals_test.go b/internal/gitaly/service/operations/land_proposals_test.go
new file mode 100755
index 0000000..4c582f4
--- /dev/null
+++ b/internal/gitaly/service/operations/land_proposals_test.go
@@ -0,0 +1,261 @@
+package operations
+
+import (
+ "fmt"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/require"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
+
+ "github.com/feder-cr/git-ai/internal/git"
+ "github.com/feder-cr/git-ai/internal/git/gittest"
+ "github.com/feder-cr/git-ai/internal/gitaly/config"
+ "github.com/feder-cr/git-ai/internal/graft/resolver"
+ "github.com/feder-cr/git-ai/internal/helper/text"
+ "github.com/feder-cr/git-ai/proto/go/gitalypb"
+)
+
+// modelAnswer is validAnswer as the llm strategy gives it: both files proposals.
+func modelAnswer() resolver.Response {
+ answer := validAnswer()
+ answer.Resolver = "graft-resolve/llm"
+ answer.Explanation = "patched by the model"
+ for i := range answer.Files {
+ answer.Files[i].Proposal = true
+ }
+ return answer
+}
+
+// proposalRefTarget returns the commit the proposal reference of the fixture's land points at, or
+// "" when there is none.
+func proposalRefTarget(t *testing.T, fx resolveFixture) string {
+ t.Helper()
+ out, err := gittest.NewCommand(t, fx.cfg, "-C", fx.repoPath, "rev-parse", "--verify", "--quiet", landProposalRef(git.DefaultBranch, fx.commit).String()).Output()
+ if err != nil {
+ return ""
+ }
+ return text.ChompBytes(out)
+}
+
+func TestUserLand_proposals(t *testing.T) {
+ t.Parallel()
+
+ t.Run("a model's answer is proposed, never landed", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ writeAnswer(t, dir, modelAnswer())
+ fx := newResolveFixture(t, enabledResolver(argv))
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ requireMergeConflict(t, err)
+ requireBranchAt(t, fx.cfg, fx.repoPath, git.DefaultBranch, fx.tip)
+ pkg := landConflictDetail(err)
+ require.NotNil(t, pkg)
+ require.Equal(t, landProposalRef(git.DefaultBranch, fx.commit).String(), pkg.GetProposalRef())
+
+ target := proposalRefTarget(t, fx)
+ require.NotEmpty(t, target, "the proposal reference exists")
+ parents := strings.Fields(text.ChompBytes(gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "rev-list", "--parents", "-n1", target)))
+ require.Equal(t, []string{target, fx.tip.String(), fx.commit.String()}, parents)
+ // Who caused the proposals is in their commit (the reference is written by the server).
+ message := string(gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "log", "-1", "--format=%B", target))
+ require.Contains(t, message, "Resolver: graft-resolve/llm\n")
+ require.Contains(t, message, "Requested-By: "+gittest.TestUser.GetGlId()+"\n")
+ for _, p := range []string{"a", "b"} {
+ f := packageFile(t, pkg, p)
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_PROPOSED, f.GetOutcome(), p)
+ require.Contains(t, f.GetReason(), "never lands a model's resolution", p)
+ prop := f.GetProposal()
+ require.NotNil(t, prop, p)
+ require.Equal(t, resolver.ActionWrite, prop.GetAction())
+ require.Equal(t, resolver.ModeRegular, prop.GetMode())
+ require.Equal(t, "graft-resolve/llm", prop.GetResolver())
+ require.Equal(t, "patched by the model", prop.GetExplanation())
+ // The blob is kept by the reference, at the file's path, and reads by its oid.
+ require.Equal(t, prop.GetOid(), text.ChompBytes(gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "rev-parse", target+":"+p)))
+ require.Equal(t, "merged-"+p+"\n", string(gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "cat-file", "blob", prop.GetOid())))
+ }
+ })
+
+ t.Run("an answer of the llm strategy without the mark is proposed too", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ answer := validAnswer()
+ answer.Resolver = "graft-resolve/trivial,llm"
+ writeAnswer(t, dir, answer)
+ fx := newResolveFixture(t, enabledResolver(argv))
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ requireMergeConflict(t, err)
+ requireBranchAt(t, fx.cfg, fx.repoPath, git.DefaultBranch, fx.tip)
+ pkg := landConflictDetail(err)
+ for _, p := range []string{"a", "b"} {
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_PROPOSED, packageFile(t, pkg, p).GetOutcome(), p)
+ }
+ })
+
+ t.Run("a file the rules resolved keeps its outcome and gets its proposal", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ answer := modelAnswer()
+ answer.Resolver = "graft-resolve/trivial,llm"
+ answer.Files[1].Proposal = false
+ writeAnswer(t, dir, answer)
+ fx := newResolveFixture(t, enabledResolver(argv))
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ requireMergeConflict(t, err)
+ pkg := landConflictDetail(err)
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_PROPOSED, packageFile(t, pkg, "a").GetOutcome())
+ b := packageFile(t, pkg, "b")
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_RESOLVED, b.GetOutcome())
+ require.Equal(t, "merged-b\n", string(gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "cat-file", "blob", b.GetProposal().GetOid())))
+ })
+
+ t.Run("the rules' answer of a land that fails for another file is kept", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ answer := validAnswer()
+ answer.Files[1].Mode = resolver.ModeExecutable // no side has it: b is rejected
+ writeAnswer(t, dir, answer)
+ fx := newResolveFixture(t, enabledResolver(argv))
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ requireMergeConflict(t, err)
+ pkg := landConflictDetail(err)
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_REJECTED, packageFile(t, pkg, "b").GetOutcome())
+ a := packageFile(t, pkg, "a")
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_RESOLVED, a.GetOutcome())
+ require.NotEmpty(t, a.GetProposal().GetOid())
+ require.NotEmpty(t, pkg.GetProposalRef())
+ })
+
+ t.Run("a rules' answer that lands keeps nothing", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ writeAnswer(t, dir, validAnswer())
+ fx := newResolveFixture(t, enabledResolver(argv))
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ require.NoError(t, err)
+ require.Empty(t, proposalRefTarget(t, fx))
+ })
+
+ t.Run("the agent's land of the change drops its proposal", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ writeAnswer(t, dir, modelAnswer())
+ fx := newResolveFixture(t, enabledResolver(argv))
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ requireMergeConflict(t, err)
+ require.NotEmpty(t, proposalRefTarget(t, fx))
+
+ // The agent lands the proposals as its own resolution; the resolver checks them.
+ writeRawAnswer(t, dir, resolver.CheckResponse{
+ Version: resolver.ProtocolVersion, Operation: resolver.OperationCheck, Resolver: "graft-resolve",
+ Files: []resolver.CheckFile{{Path: "a", OK: true, Syntax: resolver.SyntaxNone}, {Path: "b", OK: true, Syntax: resolver.SyntaxNone}},
+ })
+ req := fx.request("Land")
+ req.ResolveConflicts = false
+ req.Resolution = resolutionOf(fx, "merged-a\n", "merged-b\n")
+ _, err = fx.client.UserLand(fx.ctx, req)
+ require.NoError(t, err)
+ require.Empty(t, proposalRefTarget(t, fx), "the proposal of the change that landed is gone")
+ })
+
+ t.Run("a branch keeps at most 20 proposals, none older than proposal_ttl", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ writeAnswer(t, dir, modelAnswer())
+ fx := newResolveFixture(t, enabledResolver(argv))
+ branchDir := landProposalBranchDir(git.DefaultBranch)
+ now := time.Now()
+ // Proposal references are named by the commit they are for: fake commit IDs name these.
+ name := func(i int) string { return fmt.Sprintf("%s%040x", branchDir, i+1) }
+ old := gittest.WriteCommit(t, fx.cfg, fx.repoPath, gittest.WithMessage("old"), gittest.WithCommitterDate(now.Add(-8*24*time.Hour)))
+ gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "update-ref", name(100), old.String())
+ for i := 0; i < 21; i++ {
+ c := gittest.WriteCommit(t, fx.cfg, fx.repoPath, gittest.WithMessage(fmt.Sprintf("recent %d", i)), gittest.WithCommitterDate(now.Add(-time.Hour-time.Duration(i)*time.Minute)))
+ gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "update-ref", name(i), c.String())
+ }
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ requireMergeConflict(t, err)
+
+ refs := strings.Fields(text.ChompBytes(gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "for-each-ref", "--format=%(refname)", branchDir)))
+ require.Len(t, refs, 20)
+ require.Contains(t, refs, landProposalRef(git.DefaultBranch, fx.commit).String(), "the newest is kept")
+ require.NotContains(t, refs, name(100), "past proposal_ttl")
+ require.NotContains(t, refs, name(20), "the oldest beyond 20")
+ require.NotContains(t, refs, name(19), "the oldest beyond 20")
+ require.Contains(t, refs, name(18))
+ })
+
+ t.Run("a proposal reference that cannot be written fails the land with Internal", func(t *testing.T) {
+ t.Parallel()
+
+ dir, argv := resolverScript(t, "")
+ writeAnswer(t, dir, modelAnswer())
+ fx := newResolveFixture(t, enabledResolver(argv))
+ // A reference where the branch's directory of proposals goes: the update cannot create it.
+ gittest.Exec(t, fx.cfg, "-C", fx.repoPath, "update-ref", strings.TrimSuffix(landProposalBranchDir(git.DefaultBranch), "/"), fx.tip.String())
+
+ _, err := fx.client.UserLand(fx.ctx, fx.request("Land"))
+ require.Equal(t, codes.Internal, status.Code(err), "err = %v", err)
+ require.Contains(t, err.Error(), "keeping the resolver's answer as proposals")
+ requireBranchAt(t, fx.cfg, fx.repoPath, git.DefaultBranch, fx.tip)
+ })
+}
+
+func TestLandAnswerProposes(t *testing.T) {
+ t.Parallel()
+
+ for _, tc := range []struct {
+ resolver string
+ flagged bool
+ want bool
+ }{
+ {"graft-resolve/trivial", false, false},
+ {"graft-resolve/trivial,union", false, false},
+ {"graft-resolve/llm", false, true},
+ {"graft-resolve/trivial, llm", false, true},
+ {"graft-resolve/llm-ish", false, false},
+ {"graft-resolve/trivial", true, true},
+ } {
+ answer := &resolver.Response{Resolver: tc.resolver, Files: []resolver.ResponseFile{{Path: "a", Proposal: tc.flagged}}}
+ require.Equal(t, tc.want, landAnswerProposes(answer), "%s, flagged %v", tc.resolver, tc.flagged)
+ }
+}
+
+// TestLandUpdateProposalRefs_onlyProposalReferences: the one writer of the proposal references
+// refuses any other reference before git runs, whatever the caller passes.
+func TestLandUpdateProposalRefs_onlyProposalReferences(t *testing.T) {
+ t.Parallel()
+
+ fx := newResolveFixture(t, config.GraftResolver{})
+ s := fx.server(t, config.GraftResolver{})
+ valid := landProposalRef(git.DefaultBranch, fx.commit)
+ require.True(t, landProposalRefNameValid(valid))
+ for _, name := range []git.ReferenceName{
+ "refs/heads/main",
+ "refs/graft/green/main",
+ "refs/graft/proposals/x/" + git.ReferenceName(fx.commit.String()),
+ git.ReferenceName(strings.TrimSuffix(landProposalBranchDir(git.DefaultBranch), "/")),
+ git.ReferenceName(landProposalBranchDir(git.DefaultBranch) + "not-an-oid"),
+ git.ReferenceName(landProposalBranchDir(git.DefaultBranch) + fx.commit.String() + "/x"),
+ } {
+ err := s.landUpdateProposalRefs(fx.ctx, fx.repo, []landProposalRefOp{{name: valid, newOID: fx.tip, oldOID: gittest.DefaultObjectHash.ZeroOID}, {name: name, newOID: fx.tip, oldOID: gittest.DefaultObjectHash.ZeroOID}})
+ require.ErrorContains(t, err, "not a proposal reference", "%s", name)
+ }
+ require.Empty(t, proposalRefTarget(t, fx), "nothing was written")
+}
diff --git a/internal/gitaly/service/operations/land_resolve.go b/internal/gitaly/service/operations/land_resolve.go
index 18cf630..04d5d55 100644
--- a/internal/gitaly/service/operations/land_resolve.go
+++ b/internal/gitaly/service/operations/land_resolve.go
@@ -134,8 +134,11 @@ func (s *Server) resolveLandConflicts(
// answer is the resolver's accepted answer, the only thing ever written. A refusal is never
// written, whatever its outcomes say: answer stays nil, and the land fails with the package.
+ // An answer that holds a model's resolution is never landed: it is kept as proposals for the
+ // agent, who lands its own resolution (PLAN10 14).
var answer *resolver.Response
var resolveErr error
+ proposes := false
if len(sent) > 0 {
req := resolver.Request{
Version: resolver.ProtocolVersion,
@@ -165,6 +168,10 @@ func (s *Server) resolveLandConflicts(
landFailSent(files, gitalypb.LandConflictFile_OUTCOME_FAILED, fmt.Sprintf("the resolver's answer names an invalid resolver %q", resp.Resolver))
default:
answer = resp
+ proposes = landAnswerProposes(resp)
+ // A resolver that names the llm strategy but marks no file is taken to have proposed
+ // every file: the mark may be missing, never the other way round.
+ flagged := landAnswerFlagsProposals(resp)
written := make(map[string]resolver.ResponseFile, len(resp.Files))
for _, rf := range resp.Files {
written[rf.Path] = rf
@@ -173,14 +180,28 @@ func (s *Server) resolveLandConflicts(
if !f.sent() {
continue
}
+ rf := written[f.conflict.path]
f.outcome = gitalypb.LandConflictFile_OUTCOME_RESOLVED
- if err := landModeOfSides(f.conflict, written[f.conflict.path]); err != nil {
+ switch err := landModeOfSides(f.conflict, rf); {
+ case err != nil:
f.outcome, f.reason = gitalypb.LandConflictFile_OUTCOME_REJECTED, err.Error()
+ case rf.Proposal || (proposes && !flagged):
+ f.outcome, f.reason = gitalypb.LandConflictFile_OUTCOME_PROPOSED, landProposedReason
}
}
}
}
+ // An answer that does not land, because a model made part of it or another file is left, is
+ // kept for the agent: the files that rules resolved can be landed as they are. Failing to keep
+ // it fails the land with Internal, not with a package that lacks the proposals.
+ if answer != nil && (proposes || !landAllResolved(files)) {
+ ref, err := s.landWriteProposals(ctx, in, l, answer, committer)
+ if err != nil {
+ return landResolution{}, &landProposalsError{err: err}
+ }
+ l.proposalRef = ref
+ }
if answer == nil || !landAllResolved(files) {
return landResolution{}, l.unresolved("", landUnresolvedCause(files), resolveErr)
}
@@ -223,6 +244,9 @@ type landListing struct {
// conflicting file (a directory rename split): then files is empty and only messages
// describe it.
messages []landMergeMessage
+ // proposalRef is the reference that keeps the resolver's answer of a land that did not
+ // happen (landWriteProposals), empty when there is none.
+ proposalRef git.ReferenceName
}
// landNoConflictingFiles is the reason of a merge that is unclean without a conflicting file.
diff --git a/internal/gitaly/service/operations/land_resolve_test.go b/internal/gitaly/service/operations/land_resolve_test.go
index 6797265..d98a786 100644
--- a/internal/gitaly/service/operations/land_resolve_test.go
+++ b/internal/gitaly/service/operations/land_resolve_test.go
@@ -20,6 +20,7 @@ import (
"github.com/feder-cr/git-ai/internal/featureflag"
"github.com/feder-cr/git-ai/internal/git"
+ "github.com/feder-cr/git-ai/internal/git/catfile"
"github.com/feder-cr/git-ai/internal/git/gittest"
"github.com/feder-cr/git-ai/internal/git/localrepo"
"github.com/feder-cr/git-ai/internal/gitaly/config"
@@ -207,7 +208,12 @@ func (fx resolveFixture) server(t *testing.T, rcfg config.GraftResolver) *Server
client, err := resolver.New(rcfg)
require.NoError(t, err)
- return &Server{logger: testhelper.NewLogger(t), gitConfig: fx.cfg.Git, resolveCfg: rcfg, conflictResolver: client}
+ cache := catfile.NewCache(fx.cfg)
+ t.Cleanup(cache.Stop)
+ return &Server{
+ logger: testhelper.NewLogger(t), gitConfig: fx.cfg.Git, resolveCfg: rcfg, conflictResolver: client,
+ localRepoFactory: localrepo.NewFactory(testhelper.NewLogger(t), config.NewLocator(fx.cfg), gittest.NewCommandFactory(t, fx.cfg), cache),
+ }
}
func (fx resolveFixture) request(message string) *gitalypb.UserLandRequest {
diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go
index 7557ee7..faf6229 100644
--- a/internal/gitaly/service/smarthttp/inforefs_test.go
+++ b/internal/gitaly/service/smarthttp/inforefs_test.go
@@ -122,6 +122,14 @@ func testInfoRefsUploadPackInternalRefs(t *testing.T, ctx context.Context) {
"refs/heads/main\n",
},
},
+ {
+ // The proposals of a land (PLAN10 14) are read by object ID only.
+ ref: "refs/graft/proposals/0123456789abcdef/1",
+ expectedAdvertisements: []string{
+ "HEAD",
+ "refs/heads/main\n",
+ },
+ },
} {
t.Run(tc.ref, func(t *testing.T) {
repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 0fe8962..ab3b347 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -204,6 +204,8 @@ func TestPostReceivePack_hiddenRefs(t *testing.T) {
"refs/merge-requests/1/head",
"refs/merge-requests/1/merge",
"refs/pipelines/1",
+ // The proposals of a land (PLAN10 14) are written by the server only.
+ "refs/graft/proposals/0123456789abcdef/1",
} {
t.Run(ref, func(t *testing.T) {
t.Parallel()
diff --git a/internal/graft/e2e/proposals_test.go b/internal/graft/e2e/proposals_test.go
new file mode 100755
index 0000000..0848125
--- /dev/null
+++ b/internal/graft/e2e/proposals_test.go
@@ -0,0 +1,96 @@
+package e2e
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/feder-cr/git-ai/internal/gitaly/config"
+ "github.com/feder-cr/git-ai/proto/go/gitalypb"
+ "github.com/feder-cr/git-ai/sdk"
+)
+
+// fakeModel is a model for the llm strategy's command provider: it answers every region with the
+// CODE of the request unchanged, OURS' version, between the PATCHED CODE lines. No network.
+const fakeModel = `import json, re, sys
+req = json.load(sys.stdin)
+m = re.search(r"===== BEGIN CODE ([0-9a-f]+) =====\n(.*?)===== END CODE ([0-9a-f]+) =====", req["prompt"], re.S)
+n, code = m.group(1), m.group(2)
+sys.stdout.write("===== BEGIN PATCHED CODE %s =====\n%s===== END PATCHED CODE %s =====\n" % (n, code, n))
+`
+
+// TestPhase2ModelResolutionIsProposedThenLandedByTheAgent is decision 1 of PLAN10 14 end to end:
+// the real graft-resolve answers with its llm strategy, the server lands nothing and proposes the
+// answer in the conflict package, the SDK reads the proposal, and the agent lands it as its own.
+func TestPhase2ModelResolutionIsProposedThenLandedByTheAgent(t *testing.T) {
+ t.Parallel()
+
+ dir := t.TempDir()
+ model := filepath.Join(dir, "model.py")
+ require.NoError(t, os.WriteFile(model, []byte(fakeModel), 0o600))
+ resolveConfig := filepath.Join(dir, "resolve.toml")
+ require.NoError(t, os.WriteFile(resolveConfig, []byte(`[[strategy]]
+type = "llm"
+paths = ["shared-log.txt"]
+
+[strategy.llm]
+type = "command"
+command = ["python3", "-I", "`+model+`"]
+model = "fake"
+`), 0o600))
+
+ ex := loadExample(t)
+ ex.graft.Land.Resolver = config.GraftResolver{
+ Enabled: true,
+ Command: []string{buildAgentsTool(t, "./cmd/graft-resolve"), "--config", resolveConfig},
+ }
+ s := startGitaly(t, ex.graft, ex.sharedToken)
+ repo := s.repoAs(t, exampleTokens["planner"])
+ ctx := s.ctx
+
+ base := writeMain(t, s, map[string]string{sharedLogPath: sharedLogHeader})
+ const branch = "propose"
+ _, err := landAs(ctx, repo, "planner", branch, base)
+ require.NoError(t, err)
+ first, err := sharedChange(ctx, repo, "agent", base, 1, true)
+ require.NoError(t, err)
+ _, err = landOn(ctx, repo, branch, first, true)
+ require.NoError(t, err)
+ tip := s.git(t, "rev-parse", branch)
+
+ // The second change conflicts; the model resolves it, and the server only proposes that.
+ second, err := sharedChange(ctx, repo, "agent", base, 2, true)
+ require.NoError(t, err)
+ _, err = landOn(ctx, repo, branch, second, true)
+ require.True(t, sdk.IsMergeConflict(err), "a model's resolution must not land: %v", err)
+ require.Equal(t, tip, s.git(t, "rev-parse", branch), "the branch did not move")
+ pkg, ok := sdk.LandConflict(err)
+ require.True(t, ok)
+ require.NotEmpty(t, pkg.GetProposalRef())
+ require.Len(t, pkg.GetFiles(), 1)
+ f := pkg.GetFiles()[0]
+ require.Equal(t, gitalypb.LandConflictFile_OUTCOME_PROPOSED, f.GetOutcome())
+ require.Contains(t, f.GetProposal().GetResolver(), "llm")
+
+ sides, err := repo.ConflictSides(ctx, pkg)
+ require.NoError(t, err)
+ prop := sides[sharedLogPath].Proposal
+ require.NotNil(t, prop)
+ require.Equal(t, string(sides[sharedLogPath].Ours), string(prop.Content), "the fake model kept OURS")
+
+ // The agent lands the proposal as its own resolution.
+ res, err := repo.Land(ctx, sdk.LandOptions{
+ Branch: branch,
+ Commit: second,
+ User: sdk.User{Name: "planner", Email: "[email protected]"},
+ Strategy: sdk.LandMerge,
+ Resolution: sdk.ResolutionFromProposals(pkg, sides),
+ })
+ require.NoError(t, err)
+ msg := s.git(t, "log", "-1", "--format=%B", res.LandedCommitID)
+ require.Contains(t, msg, "Graft-Resolved-By: agent/planner")
+ require.NotContains(t, msg, "Graft-Resolved-By: graft-resolve")
+ require.Empty(t, s.git(t, "for-each-ref", pkg.GetProposalRef()), "the proposal of the change that landed is gone")
+}
diff --git a/internal/graft/resolver/client.go b/internal/graft/resolver/client.go
index f8ce0a6..38e4f38 100644
--- a/internal/graft/resolver/client.go
+++ b/internal/graft/resolver/client.go
@@ -128,6 +128,9 @@ func New(cfg config.GraftResolver) (*Client, error) {
if err != nil {
return nil, err
}
+ if _, err := cfg.ProposalTTLOrDefault(); err != nil {
+ return nil, err
+ }
if cfg.MaxFiles < 0 || cfg.MaxFileBytes < 0 || cfg.CheckConcurrency < 0 {
return nil, errors.New("graft land resolver: max_files, max_file_bytes and check_concurrency must not be negative")
diff --git a/internal/graft/resolver/protocol.go b/internal/graft/resolver/protocol.go
index 75a9311..a87ab21 100644
--- a/internal/graft/resolver/protocol.go
+++ b/internal/graft/resolver/protocol.go
@@ -205,10 +205,13 @@ type Response struct {
}
// ResponseFile is the resolution of one conflicting path. Content is base64
-// on the wire and is only meaningful for ActionWrite.
+// on the wire and is only meaningful for ActionWrite. Proposal marks a
+// resolution made by a model: the server never lands it, it proposes it to the
+// agent (PLAN10 14).
type ResponseFile struct {
- Path string `json:"path"`
- Action string `json:"action"`
- Mode string `json:"mode,omitempty"`
- Content []byte `json:"content,omitempty"`
+ Path string `json:"path"`
+ Action string `json:"action"`
+ Mode string `json:"mode,omitempty"`
+ Content []byte `json:"content,omitempty"`
+ Proposal bool `json:"proposal,omitempty"`
}
diff --git a/internal/graft/resolver/testdata/protocol-fields.json b/internal/graft/resolver/testdata/protocol-fields.json
index 40cedcb..eeb08ff 100644
--- a/internal/graft/resolver/testdata/protocol-fields.json
+++ b/internal/graft/resolver/testdata/protocol-fields.json
@@ -7,7 +7,7 @@
"side": ["content", "mode", "oid"],
"limits": ["max_file_bytes"],
"response": ["explanation", "files", "resolver", "version"],
- "response_file": ["action", "content", "mode", "path"],
+ "response_file": ["action", "content", "mode", "path", "proposal"],
"error_response": ["error", "files"],
"file_outcome": ["outcome", "path", "reason"],
"check_response": ["files", "operation", "resolver", "version"],
diff --git a/proto/go/gitalypb/operations.pb.go b/proto/go/gitalypb/operations.pb.go
index 7df5e11..a598ac2 100644
--- a/proto/go/gitalypb/operations.pb.go
+++ b/proto/go/gitalypb/operations.pb.go
@@ -278,6 +278,9 @@ const (
// OUTCOME_NOT_ATTEMPTED: the request was not resolved at all (see
// LandConflict.reason).
LandConflictFile_OUTCOME_NOT_ATTEMPTED LandConflictFile_Outcome = 5
+ // OUTCOME_PROPOSED: a model resolved the file; the server never lands a
+ // model's resolution, it proposes it (see proposal).
+ LandConflictFile_OUTCOME_PROPOSED LandConflictFile_Outcome = 6
)
// Enum value maps for LandConflictFile_Outcome.
@@ -289,6 +292,7 @@ var (
3: "OUTCOME_FAILED",
4: "OUTCOME_RESOLVED",
5: "OUTCOME_NOT_ATTEMPTED",
+ 6: "OUTCOME_PROPOSED",
}
LandConflictFile_Outcome_value = map[string]int32{
"OUTCOME_UNSPECIFIED": 0,
@@ -297,6 +301,7 @@ var (
"OUTCOME_FAILED": 3,
"OUTCOME_RESOLVED": 4,
"OUTCOME_NOT_ATTEMPTED": 5,
+ "OUTCOME_PROPOSED": 6,
}
)
@@ -377,7 +382,7 @@ func (x LandResolvedFile_Action) Number() protoreflect.EnumNumber {
// Deprecated: Use LandResolvedFile_Action.Descriptor instead.
func (LandResolvedFile_Action) EnumDescriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{57, 0}
+ return file_operations_proto_rawDescGZIP(), []int{58, 0}
}
// UserCreateBranchRequest is a request for the UserCreateBranch RPC.
@@ -4875,7 +4880,11 @@ type LandConflict struct {
// 512 bytes.
Reason string `protobuf:"bytes,8,opt,name=reason,proto3" json:"reason,omitempty"`
// messages are the messages of the merge about its conflicts, at most 1000.
- Messages []*LandConflictMessage `protobuf:"bytes,9,rep,name=messages,proto3" json:"messages,omitempty"`
+ Messages []*LandConflictMessage `protobuf:"bytes,9,rep,name=messages,proto3" json:"messages,omitempty"`
+ // proposal_ref is the hidden reference that keeps the proposals of the package
+ // (refs/graft/proposals/...), empty when no file has a proposal. Its blobs are
+ // read by the oids of LandConflictProposal.
+ ProposalRef string `protobuf:"bytes,10,opt,name=proposal_ref,json=proposalRef,proto3" json:"proposal_ref,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -4973,6 +4982,13 @@ func (x *LandConflict) GetMessages() []*LandConflictMessage {
return nil
}
+func (x *LandConflict) GetProposalRef() string {
+ if x != nil {
+ return x.ProposalRef
+ }
+ return ""
+}
+
// LandConflictFile is one conflicting file of a LandConflict.
type LandConflictFile struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -5000,7 +5016,12 @@ type LandConflictFile struct {
// conflict: a side too large to read, a diff over its cost bound, more regions
// than a file lists, or a package over its size bound. It is empty when hunks is
// complete, and for the kinds of conflict that have no hunks.
- HunksOmitted string `protobuf:"bytes,10,opt,name=hunks_omitted,json=hunksOmitted,proto3" json:"hunks_omitted,omitempty"`
+ HunksOmitted string `protobuf:"bytes,10,opt,name=hunks_omitted,json=hunksOmitted,proto3" json:"hunks_omitted,omitempty"`
+ // proposal is the resolution the resolver made of the file, for a file that a
+ // model proposed (OUTCOME_PROPOSED) or that the rules resolved in a land that
+ // failed for another file (OUTCOME_RESOLVED), so that the agent can land it as
+ // it is or edit it.
+ Proposal *LandConflictProposal `protobuf:"bytes,11,opt,name=proposal,proto3" json:"proposal,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -5105,6 +5126,96 @@ func (x *LandConflictFile) GetHunksOmitted() string {
return ""
}
+func (x *LandConflictFile) GetProposal() *LandConflictProposal {
+ if x != nil {
+ return x.Proposal
+ }
+ return nil
+}
+
+// LandConflictProposal is the resolver's resolution of one conflicting file.
+type LandConflictProposal struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // action is "write" or "delete".
+ Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"`
+ // oid is the blob of the resolved content, for a write; it is kept in the
+ // repository by LandConflict.proposal_ref.
+ Oid string `protobuf:"bytes,2,opt,name=oid,proto3" json:"oid,omitempty"`
+ // mode is the file mode of a write.
+ Mode string `protobuf:"bytes,3,opt,name=mode,proto3" json:"mode,omitempty"`
+ // resolver names what made it: the resolver and its strategies.
+ Resolver string `protobuf:"bytes,4,opt,name=resolver,proto3" json:"resolver,omitempty"`
+ // explanation is the resolver's explanation, cut to 512 bytes.
+ Explanation string `protobuf:"bytes,5,opt,name=explanation,proto3" json:"explanation,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *LandConflictProposal) Reset() {
+ *x = LandConflictProposal{}
+ mi := &file_operations_proto_msgTypes[52]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *LandConflictProposal) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*LandConflictProposal) ProtoMessage() {}
+
+func (x *LandConflictProposal) ProtoReflect() protoreflect.Message {
+ mi := &file_operations_proto_msgTypes[52]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use LandConflictProposal.ProtoReflect.Descriptor instead.
+func (*LandConflictProposal) Descriptor() ([]byte, []int) {
+ return file_operations_proto_rawDescGZIP(), []int{52}
+}
+
+func (x *LandConflictProposal) GetAction() string {
+ if x != nil {
+ return x.Action
+ }
+ return ""
+}
+
+func (x *LandConflictProposal) GetOid() string {
+ if x != nil {
+ return x.Oid
+ }
+ return ""
+}
+
+func (x *LandConflictProposal) GetMode() string {
+ if x != nil {
+ return x.Mode
+ }
+ return ""
+}
+
+func (x *LandConflictProposal) GetResolver() string {
+ if x != nil {
+ return x.Resolver
+ }
+ return ""
+}
+
+func (x *LandConflictProposal) GetExplanation() string {
+ if x != nil {
+ return x.Explanation
+ }
+ return ""
+}
+
// LandConflictSide is one side of a conflicting file; its content is read by oid.
type LandConflictSide struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -5125,7 +5236,7 @@ type LandConflictSide struct {
func (x *LandConflictSide) Reset() {
*x = LandConflictSide{}
- mi := &file_operations_proto_msgTypes[52]
+ mi := &file_operations_proto_msgTypes[53]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5137,7 +5248,7 @@ func (x *LandConflictSide) String() string {
func (*LandConflictSide) ProtoMessage() {}
func (x *LandConflictSide) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[52]
+ mi := &file_operations_proto_msgTypes[53]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5150,7 +5261,7 @@ func (x *LandConflictSide) ProtoReflect() protoreflect.Message {
// Deprecated: Use LandConflictSide.ProtoReflect.Descriptor instead.
func (*LandConflictSide) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{52}
+ return file_operations_proto_rawDescGZIP(), []int{53}
}
func (x *LandConflictSide) GetOid() string {
@@ -5191,7 +5302,7 @@ type LandConflictMessage struct {
func (x *LandConflictMessage) Reset() {
*x = LandConflictMessage{}
- mi := &file_operations_proto_msgTypes[53]
+ mi := &file_operations_proto_msgTypes[54]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5203,7 +5314,7 @@ func (x *LandConflictMessage) String() string {
func (*LandConflictMessage) ProtoMessage() {}
func (x *LandConflictMessage) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[53]
+ mi := &file_operations_proto_msgTypes[54]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5216,7 +5327,7 @@ func (x *LandConflictMessage) ProtoReflect() protoreflect.Message {
// Deprecated: Use LandConflictMessage.ProtoReflect.Descriptor instead.
func (*LandConflictMessage) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{53}
+ return file_operations_proto_rawDescGZIP(), []int{54}
}
func (x *LandConflictMessage) GetPaths() [][]byte {
@@ -5258,7 +5369,7 @@ type LandConflictHunk struct {
func (x *LandConflictHunk) Reset() {
*x = LandConflictHunk{}
- mi := &file_operations_proto_msgTypes[54]
+ mi := &file_operations_proto_msgTypes[55]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5270,7 +5381,7 @@ func (x *LandConflictHunk) String() string {
func (*LandConflictHunk) ProtoMessage() {}
func (x *LandConflictHunk) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[54]
+ mi := &file_operations_proto_msgTypes[55]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5283,7 +5394,7 @@ func (x *LandConflictHunk) ProtoReflect() protoreflect.Message {
// Deprecated: Use LandConflictHunk.ProtoReflect.Descriptor instead.
func (*LandConflictHunk) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{54}
+ return file_operations_proto_rawDescGZIP(), []int{55}
}
func (x *LandConflictHunk) GetBase() *LineRange {
@@ -5320,7 +5431,7 @@ type LineRange struct {
func (x *LineRange) Reset() {
*x = LineRange{}
- mi := &file_operations_proto_msgTypes[55]
+ mi := &file_operations_proto_msgTypes[56]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5332,7 +5443,7 @@ func (x *LineRange) String() string {
func (*LineRange) ProtoMessage() {}
func (x *LineRange) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[55]
+ mi := &file_operations_proto_msgTypes[56]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5345,7 +5456,7 @@ func (x *LineRange) ProtoReflect() protoreflect.Message {
// Deprecated: Use LineRange.ProtoReflect.Descriptor instead.
func (*LineRange) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{55}
+ return file_operations_proto_rawDescGZIP(), []int{56}
}
func (x *LineRange) GetStart() uint32 {
@@ -5377,7 +5488,7 @@ type LandResolution struct {
func (x *LandResolution) Reset() {
*x = LandResolution{}
- mi := &file_operations_proto_msgTypes[56]
+ mi := &file_operations_proto_msgTypes[57]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5389,7 +5500,7 @@ func (x *LandResolution) String() string {
func (*LandResolution) ProtoMessage() {}
func (x *LandResolution) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[56]
+ mi := &file_operations_proto_msgTypes[57]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5402,7 +5513,7 @@ func (x *LandResolution) ProtoReflect() protoreflect.Message {
// Deprecated: Use LandResolution.ProtoReflect.Descriptor instead.
func (*LandResolution) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{56}
+ return file_operations_proto_rawDescGZIP(), []int{57}
}
func (x *LandResolution) GetTip() string {
@@ -5443,7 +5554,7 @@ type LandResolvedFile struct {
func (x *LandResolvedFile) Reset() {
*x = LandResolvedFile{}
- mi := &file_operations_proto_msgTypes[57]
+ mi := &file_operations_proto_msgTypes[58]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5455,7 +5566,7 @@ func (x *LandResolvedFile) String() string {
func (*LandResolvedFile) ProtoMessage() {}
func (x *LandResolvedFile) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[57]
+ mi := &file_operations_proto_msgTypes[58]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5468,7 +5579,7 @@ func (x *LandResolvedFile) ProtoReflect() protoreflect.Message {
// Deprecated: Use LandResolvedFile.ProtoReflect.Descriptor instead.
func (*LandResolvedFile) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{57}
+ return file_operations_proto_rawDescGZIP(), []int{58}
}
func (x *LandResolvedFile) GetPath() []byte {
@@ -5535,7 +5646,7 @@ type UserLandResponse struct {
func (x *UserLandResponse) Reset() {
*x = UserLandResponse{}
- mi := &file_operations_proto_msgTypes[58]
+ mi := &file_operations_proto_msgTypes[59]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5547,7 +5658,7 @@ func (x *UserLandResponse) String() string {
func (*UserLandResponse) ProtoMessage() {}
func (x *UserLandResponse) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[58]
+ mi := &file_operations_proto_msgTypes[59]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5560,7 +5671,7 @@ func (x *UserLandResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use UserLandResponse.ProtoReflect.Descriptor instead.
func (*UserLandResponse) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{58}
+ return file_operations_proto_rawDescGZIP(), []int{59}
}
func (x *UserLandResponse) GetBranchUpdate() *OperationBranchUpdate {
@@ -5651,7 +5762,7 @@ type UserLandError struct {
func (x *UserLandError) Reset() {
*x = UserLandError{}
- mi := &file_operations_proto_msgTypes[59]
+ mi := &file_operations_proto_msgTypes[60]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5663,7 +5774,7 @@ func (x *UserLandError) String() string {
func (*UserLandError) ProtoMessage() {}
func (x *UserLandError) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[59]
+ mi := &file_operations_proto_msgTypes[60]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5676,7 +5787,7 @@ func (x *UserLandError) ProtoReflect() protoreflect.Message {
// Deprecated: Use UserLandError.ProtoReflect.Descriptor instead.
func (*UserLandError) Descriptor() ([]byte, []int) {
- return file_operations_proto_rawDescGZIP(), []int{59}
+ return file_operations_proto_rawDescGZIP(), []int{60}
}
func (x *UserLandError) GetError() isUserLandError_Error {
@@ -5811,7 +5922,7 @@ type UserRebaseConfirmableRequest_Header struct {
func (x *UserRebaseConfirmableRequest_Header) Reset() {
*x = UserRebaseConfirmableRequest_Header{}
- mi := &file_operations_proto_msgTypes[60]
+ mi := &file_operations_proto_msgTypes[61]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5823,7 +5934,7 @@ func (x *UserRebaseConfirmableRequest_Header) String() string {
func (*UserRebaseConfirmableRequest_Header) ProtoMessage() {}
func (x *UserRebaseConfirmableRequest_Header) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[60]
+ mi := &file_operations_proto_msgTypes[61]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -5931,7 +6042,7 @@ type UserApplyPatchRequest_Header struct {
func (x *UserApplyPatchRequest_Header) Reset() {
*x = UserApplyPatchRequest_Header{}
- mi := &file_operations_proto_msgTypes[61]
+ mi := &file_operations_proto_msgTypes[62]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -5943,7 +6054,7 @@ func (x *UserApplyPatchRequest_Header) String() string {
func (*UserApplyPatchRequest_Header) ProtoMessage() {}
func (x *UserApplyPatchRequest_Header) ProtoReflect() protoreflect.Message {
- mi := &file_operations_proto_msgTypes[61]
+ mi := &file_operations_proto_msgTypes[62]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -6370,7 +6481,7 @@ const file_operations_proto_rawDesc = "" +
"\bStrategy\x12\x1f\n" +
"\x1bSTRATEGY_REBASE_UNSPECIFIED\x10\x00\x12\x12\n" +
"\x0eSTRATEGY_MERGE\x10\x01\x12\x14\n" +
- "\x10STRATEGY_FF_ONLY\x10\x02\"\xcf\x02\n" +
+ "\x10STRATEGY_FF_ONLY\x10\x02\"\xf2\x02\n" +
"\fLandConflict\x12\x10\n" +
"\x03tip\x18\x01 \x01(\tR\x03tip\x12\x16\n" +
"\x06commit\x18\x02 \x01(\tR\x06commit\x12\x1d\n" +
@@ -6382,7 +6493,9 @@ const file_operations_proto_rawDesc = "" +
"\x12messages_truncated\x18\x06 \x01(\bR\x11messagesTruncated\x12.\n" +
"\x05files\x18\a \x03(\v2\x18.gitaly.LandConflictFileR\x05files\x12\x16\n" +
"\x06reason\x18\b \x01(\tR\x06reason\x127\n" +
- "\bmessages\x18\t \x03(\v2\x1b.gitaly.LandConflictMessageR\bmessages\"\xba\x05\n" +
+ "\bmessages\x18\t \x03(\v2\x1b.gitaly.LandConflictMessageR\bmessages\x12!\n" +
+ "\fproposal_ref\x18\n" +
+ " \x01(\tR\vproposalRef\"\x8a\x06\n" +
"\x10LandConflictFile\x12\x12\n" +
"\x04path\x18\x01 \x01(\fR\x04path\x121\n" +
"\x04kind\x18\x02 \x01(\x0e2\x1d.gitaly.LandConflictFile.KindR\x04kind\x12,\n" +
@@ -6394,20 +6507,28 @@ const file_operations_proto_rawDesc = "" +
"\x06reason\x18\b \x01(\tR\x06reason\x12)\n" +
"\x10syntax_unchecked\x18\t \x01(\bR\x0fsyntaxUnchecked\x12#\n" +
"\rhunks_omitted\x18\n" +
- " \x01(\tR\fhunksOmitted\"g\n" +
+ " \x01(\tR\fhunksOmitted\x128\n" +
+ "\bproposal\x18\v \x01(\v2\x1c.gitaly.LandConflictProposalR\bproposal\"g\n" +
"\x04Kind\x12\x14\n" +
"\x10KIND_UNSPECIFIED\x10\x00\x12\x10\n" +
"\fKIND_CONTENT\x10\x01\x12\x16\n" +
"\x12KIND_MODIFY_DELETE\x10\x02\x12\x10\n" +
"\fKIND_ADD_ADD\x10\x03\x12\r\n" +
- "\tKIND_MODE\x10\x04\"\x93\x01\n" +
+ "\tKIND_MODE\x10\x04\"\xa9\x01\n" +
"\aOutcome\x12\x17\n" +
"\x13OUTCOME_UNSPECIFIED\x10\x00\x12\x14\n" +
"\x10OUTCOME_NOT_SENT\x10\x01\x12\x14\n" +
"\x10OUTCOME_REJECTED\x10\x02\x12\x12\n" +
"\x0eOUTCOME_FAILED\x10\x03\x12\x14\n" +
"\x10OUTCOME_RESOLVED\x10\x04\x12\x19\n" +
- "\x15OUTCOME_NOT_ATTEMPTED\x10\x05\"Z\n" +
+ "\x15OUTCOME_NOT_ATTEMPTED\x10\x05\x12\x14\n" +
+ "\x10OUTCOME_PROPOSED\x10\x06\"\x92\x01\n" +
+ "\x14LandConflictProposal\x12\x16\n" +
+ "\x06action\x18\x01 \x01(\tR\x06action\x12\x10\n" +
+ "\x03oid\x18\x02 \x01(\tR\x03oid\x12\x12\n" +
+ "\x04mode\x18\x03 \x01(\tR\x04mode\x12\x1a\n" +
+ "\bresolver\x18\x04 \x01(\tR\bresolver\x12 \n" +
+ "\vexplanation\x18\x05 \x01(\tR\vexplanation\"Z\n" +
"\x10LandConflictSide\x12\x10\n" +
"\x03oid\x18\x01 \x01(\tR\x03oid\x12\x12\n" +
"\x04mode\x18\x02 \x01(\tR\x04mode\x12 \n" +
@@ -6491,7 +6612,7 @@ func file_operations_proto_rawDescGZIP() []byte {
}
var file_operations_proto_enumTypes = make([]protoimpl.EnumInfo, 6)
-var file_operations_proto_msgTypes = make([]protoimpl.MessageInfo, 62)
+var file_operations_proto_msgTypes = make([]protoimpl.MessageInfo, 63)
var file_operations_proto_goTypes = []any{
(UserRevertResponse_CreateTreeError)(0), // 0: gitaly.UserRevertResponse.CreateTreeError
(UserCommitFilesActionHeader_ActionType)(0), // 1: gitaly.UserCommitFilesActionHeader.ActionType
@@ -6551,197 +6672,199 @@ var file_operations_proto_goTypes = []any{
(*UserLandRequest)(nil), // 55: gitaly.UserLandRequest
(*LandConflict)(nil), // 56: gitaly.LandConflict
(*LandConflictFile)(nil), // 57: gitaly.LandConflictFile
- (*LandConflictSide)(nil), // 58: gitaly.LandConflictSide
- (*LandConflictMessage)(nil), // 59: gitaly.LandConflictMessage
- (*LandConflictHunk)(nil), // 60: gitaly.LandConflictHunk
- (*LineRange)(nil), // 61: gitaly.LineRange
- (*LandResolution)(nil), // 62: gitaly.LandResolution
- (*LandResolvedFile)(nil), // 63: gitaly.LandResolvedFile
- (*UserLandResponse)(nil), // 64: gitaly.UserLandResponse
- (*UserLandError)(nil), // 65: gitaly.UserLandError
- (*UserRebaseConfirmableRequest_Header)(nil), // 66: gitaly.UserRebaseConfirmableRequest.Header
- (*UserApplyPatchRequest_Header)(nil), // 67: gitaly.UserApplyPatchRequest.Header
- (*Repository)(nil), // 68: gitaly.Repository
- (*User)(nil), // 69: gitaly.User
- (*Branch)(nil), // 70: gitaly.Branch
- (*CustomHookError)(nil), // 71: gitaly.CustomHookError
- (*AccessCheckError)(nil), // 72: gitaly.AccessCheckError
- (*ReferenceUpdateError)(nil), // 73: gitaly.ReferenceUpdateError
- (*timestamppb.Timestamp)(nil), // 74: google.protobuf.Timestamp
- (*Tag)(nil), // 75: gitaly.Tag
- (*ReferenceExistsError)(nil), // 76: gitaly.ReferenceExistsError
- (*MergeConflictError)(nil), // 77: gitaly.MergeConflictError
- (*GitCommit)(nil), // 78: gitaly.GitCommit
- (*NotAncestorError)(nil), // 79: gitaly.NotAncestorError
- (*ChangesAlreadyAppliedError)(nil), // 80: gitaly.ChangesAlreadyAppliedError
- (*IndexError)(nil), // 81: gitaly.IndexError
- (*ResolveRevisionError)(nil), // 82: gitaly.ResolveRevisionError
- (*PathError)(nil), // 83: gitaly.PathError
+ (*LandConflictProposal)(nil), // 58: gitaly.LandConflictProposal
+ (*LandConflictSide)(nil), // 59: gitaly.LandConflictSide
+ (*LandConflictMessage)(nil), // 60: gitaly.LandConflictMessage
+ (*LandConflictHunk)(nil), // 61: gitaly.LandConflictHunk
+ (*LineRange)(nil), // 62: gitaly.LineRange
+ (*LandResolution)(nil), // 63: gitaly.LandResolution
+ (*LandResolvedFile)(nil), // 64: gitaly.LandResolvedFile
+ (*UserLandResponse)(nil), // 65: gitaly.UserLandResponse
+ (*UserLandError)(nil), // 66: gitaly.UserLandError
+ (*UserRebaseConfirmableRequest_Header)(nil), // 67: gitaly.UserRebaseConfirmableRequest.Header
+ (*UserApplyPatchRequest_Header)(nil), // 68: gitaly.UserApplyPatchRequest.Header
+ (*Repository)(nil), // 69: gitaly.Repository
+ (*User)(nil), // 70: gitaly.User
+ (*Branch)(nil), // 71: gitaly.Branch
+ (*CustomHookError)(nil), // 72: gitaly.CustomHookError
+ (*AccessCheckError)(nil), // 73: gitaly.AccessCheckError
+ (*ReferenceUpdateError)(nil), // 74: gitaly.ReferenceUpdateError
+ (*timestamppb.Timestamp)(nil), // 75: google.protobuf.Timestamp
+ (*Tag)(nil), // 76: gitaly.Tag
+ (*ReferenceExistsError)(nil), // 77: gitaly.ReferenceExistsError
+ (*MergeConflictError)(nil), // 78: gitaly.MergeConflictError
+ (*GitCommit)(nil), // 79: gitaly.GitCommit
+ (*NotAncestorError)(nil), // 80: gitaly.NotAncestorError
+ (*ChangesAlreadyAppliedError)(nil), // 81: gitaly.ChangesAlreadyAppliedError
+ (*IndexError)(nil), // 82: gitaly.IndexError
+ (*ResolveRevisionError)(nil), // 83: gitaly.ResolveRevisionError
+ (*PathError)(nil), // 84: gitaly.PathError
}
var file_operations_proto_depIdxs = []int32{
- 68, // 0: gitaly.UserCreateBranchRequest.repository:type_name -> gitaly.Repository
- 69, // 1: gitaly.UserCreateBranchRequest.user:type_name -> gitaly.User
- 70, // 2: gitaly.UserCreateBranchResponse.branch:type_name -> gitaly.Branch
- 71, // 3: gitaly.UserCreateBranchError.custom_hook:type_name -> gitaly.CustomHookError
- 68, // 4: gitaly.UserUpdateBranchRequest.repository:type_name -> gitaly.Repository
- 69, // 5: gitaly.UserUpdateBranchRequest.user:type_name -> gitaly.User
- 68, // 6: gitaly.UserDeleteBranchRequest.repository:type_name -> gitaly.Repository
- 69, // 7: gitaly.UserDeleteBranchRequest.user:type_name -> gitaly.User
- 72, // 8: gitaly.UserDeleteBranchError.access_check:type_name -> gitaly.AccessCheckError
- 73, // 9: gitaly.UserDeleteBranchError.reference_update:type_name -> gitaly.ReferenceUpdateError
- 71, // 10: gitaly.UserDeleteBranchError.custom_hook:type_name -> gitaly.CustomHookError
- 68, // 11: gitaly.UserDeleteTagRequest.repository:type_name -> gitaly.Repository
- 69, // 12: gitaly.UserDeleteTagRequest.user:type_name -> gitaly.User
- 68, // 13: gitaly.UserCreateTagRequest.repository:type_name -> gitaly.Repository
- 69, // 14: gitaly.UserCreateTagRequest.user:type_name -> gitaly.User
- 74, // 15: gitaly.UserCreateTagRequest.timestamp:type_name -> google.protobuf.Timestamp
- 75, // 16: gitaly.UserCreateTagResponse.tag:type_name -> gitaly.Tag
- 72, // 17: gitaly.UserCreateTagError.access_check:type_name -> gitaly.AccessCheckError
- 73, // 18: gitaly.UserCreateTagError.reference_update:type_name -> gitaly.ReferenceUpdateError
- 71, // 19: gitaly.UserCreateTagError.custom_hook:type_name -> gitaly.CustomHookError
- 76, // 20: gitaly.UserCreateTagError.reference_exists:type_name -> gitaly.ReferenceExistsError
- 68, // 21: gitaly.UserMergeBranchRequest.repository:type_name -> gitaly.Repository
- 69, // 22: gitaly.UserMergeBranchRequest.user:type_name -> gitaly.User
- 74, // 23: gitaly.UserMergeBranchRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 69, // 0: gitaly.UserCreateBranchRequest.repository:type_name -> gitaly.Repository
+ 70, // 1: gitaly.UserCreateBranchRequest.user:type_name -> gitaly.User
+ 71, // 2: gitaly.UserCreateBranchResponse.branch:type_name -> gitaly.Branch
+ 72, // 3: gitaly.UserCreateBranchError.custom_hook:type_name -> gitaly.CustomHookError
+ 69, // 4: gitaly.UserUpdateBranchRequest.repository:type_name -> gitaly.Repository
+ 70, // 5: gitaly.UserUpdateBranchRequest.user:type_name -> gitaly.User
+ 69, // 6: gitaly.UserDeleteBranchRequest.repository:type_name -> gitaly.Repository
+ 70, // 7: gitaly.UserDeleteBranchRequest.user:type_name -> gitaly.User
+ 73, // 8: gitaly.UserDeleteBranchError.access_check:type_name -> gitaly.AccessCheckError
+ 74, // 9: gitaly.UserDeleteBranchError.reference_update:type_name -> gitaly.ReferenceUpdateError
+ 72, // 10: gitaly.UserDeleteBranchError.custom_hook:type_name -> gitaly.CustomHookError
+ 69, // 11: gitaly.UserDeleteTagRequest.repository:type_name -> gitaly.Repository
+ 70, // 12: gitaly.UserDeleteTagRequest.user:type_name -> gitaly.User
+ 69, // 13: gitaly.UserCreateTagRequest.repository:type_name -> gitaly.Repository
+ 70, // 14: gitaly.UserCreateTagRequest.user:type_name -> gitaly.User
+ 75, // 15: gitaly.UserCreateTagRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 76, // 16: gitaly.UserCreateTagResponse.tag:type_name -> gitaly.Tag
+ 73, // 17: gitaly.UserCreateTagError.access_check:type_name -> gitaly.AccessCheckError
+ 74, // 18: gitaly.UserCreateTagError.reference_update:type_name -> gitaly.ReferenceUpdateError
+ 72, // 19: gitaly.UserCreateTagError.custom_hook:type_name -> gitaly.CustomHookError
+ 77, // 20: gitaly.UserCreateTagError.reference_exists:type_name -> gitaly.ReferenceExistsError
+ 69, // 21: gitaly.UserMergeBranchRequest.repository:type_name -> gitaly.Repository
+ 70, // 22: gitaly.UserMergeBranchRequest.user:type_name -> gitaly.User
+ 75, // 23: gitaly.UserMergeBranchRequest.timestamp:type_name -> google.protobuf.Timestamp
27, // 24: gitaly.UserMergeBranchResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 72, // 25: gitaly.UserMergeBranchError.access_check:type_name -> gitaly.AccessCheckError
- 73, // 26: gitaly.UserMergeBranchError.reference_update:type_name -> gitaly.ReferenceUpdateError
- 71, // 27: gitaly.UserMergeBranchError.custom_hook:type_name -> gitaly.CustomHookError
- 77, // 28: gitaly.UserMergeBranchError.merge_conflict:type_name -> gitaly.MergeConflictError
- 68, // 29: gitaly.UserMergeToRefRequest.repository:type_name -> gitaly.Repository
- 69, // 30: gitaly.UserMergeToRefRequest.user:type_name -> gitaly.User
- 74, // 31: gitaly.UserMergeToRefRequest.timestamp:type_name -> google.protobuf.Timestamp
- 77, // 32: gitaly.UserMergeToRefError.merge_conflict:type_name -> gitaly.MergeConflictError
- 68, // 33: gitaly.UserRebaseToRefRequest.repository:type_name -> gitaly.Repository
- 69, // 34: gitaly.UserRebaseToRefRequest.user:type_name -> gitaly.User
- 74, // 35: gitaly.UserRebaseToRefRequest.timestamp:type_name -> google.protobuf.Timestamp
- 71, // 36: gitaly.UserFFBranchError.custom_hook:type_name -> gitaly.CustomHookError
- 73, // 37: gitaly.UserFFBranchError.reference_update:type_name -> gitaly.ReferenceUpdateError
- 68, // 38: gitaly.UserFFBranchRequest.repository:type_name -> gitaly.Repository
- 69, // 39: gitaly.UserFFBranchRequest.user:type_name -> gitaly.User
+ 73, // 25: gitaly.UserMergeBranchError.access_check:type_name -> gitaly.AccessCheckError
+ 74, // 26: gitaly.UserMergeBranchError.reference_update:type_name -> gitaly.ReferenceUpdateError
+ 72, // 27: gitaly.UserMergeBranchError.custom_hook:type_name -> gitaly.CustomHookError
+ 78, // 28: gitaly.UserMergeBranchError.merge_conflict:type_name -> gitaly.MergeConflictError
+ 69, // 29: gitaly.UserMergeToRefRequest.repository:type_name -> gitaly.Repository
+ 70, // 30: gitaly.UserMergeToRefRequest.user:type_name -> gitaly.User
+ 75, // 31: gitaly.UserMergeToRefRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 78, // 32: gitaly.UserMergeToRefError.merge_conflict:type_name -> gitaly.MergeConflictError
+ 69, // 33: gitaly.UserRebaseToRefRequest.repository:type_name -> gitaly.Repository
+ 70, // 34: gitaly.UserRebaseToRefRequest.user:type_name -> gitaly.User
+ 75, // 35: gitaly.UserRebaseToRefRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 72, // 36: gitaly.UserFFBranchError.custom_hook:type_name -> gitaly.CustomHookError
+ 74, // 37: gitaly.UserFFBranchError.reference_update:type_name -> gitaly.ReferenceUpdateError
+ 69, // 38: gitaly.UserFFBranchRequest.repository:type_name -> gitaly.Repository
+ 70, // 39: gitaly.UserFFBranchRequest.user:type_name -> gitaly.User
27, // 40: gitaly.UserFFBranchResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 68, // 41: gitaly.UserCherryPickRequest.repository:type_name -> gitaly.Repository
- 69, // 42: gitaly.UserCherryPickRequest.user:type_name -> gitaly.User
- 78, // 43: gitaly.UserCherryPickRequest.commit:type_name -> gitaly.GitCommit
- 68, // 44: gitaly.UserCherryPickRequest.start_repository:type_name -> gitaly.Repository
- 74, // 45: gitaly.UserCherryPickRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 69, // 41: gitaly.UserCherryPickRequest.repository:type_name -> gitaly.Repository
+ 70, // 42: gitaly.UserCherryPickRequest.user:type_name -> gitaly.User
+ 79, // 43: gitaly.UserCherryPickRequest.commit:type_name -> gitaly.GitCommit
+ 69, // 44: gitaly.UserCherryPickRequest.start_repository:type_name -> gitaly.Repository
+ 75, // 45: gitaly.UserCherryPickRequest.timestamp:type_name -> google.protobuf.Timestamp
27, // 46: gitaly.UserCherryPickResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 77, // 47: gitaly.UserCherryPickError.cherry_pick_conflict:type_name -> gitaly.MergeConflictError
- 79, // 48: gitaly.UserCherryPickError.target_branch_diverged:type_name -> gitaly.NotAncestorError
- 80, // 49: gitaly.UserCherryPickError.changes_already_applied:type_name -> gitaly.ChangesAlreadyAppliedError
- 72, // 50: gitaly.UserCherryPickError.access_check:type_name -> gitaly.AccessCheckError
- 68, // 51: gitaly.UserRevertRequest.repository:type_name -> gitaly.Repository
- 69, // 52: gitaly.UserRevertRequest.user:type_name -> gitaly.User
- 78, // 53: gitaly.UserRevertRequest.commit:type_name -> gitaly.GitCommit
- 68, // 54: gitaly.UserRevertRequest.start_repository:type_name -> gitaly.Repository
- 74, // 55: gitaly.UserRevertRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 78, // 47: gitaly.UserCherryPickError.cherry_pick_conflict:type_name -> gitaly.MergeConflictError
+ 80, // 48: gitaly.UserCherryPickError.target_branch_diverged:type_name -> gitaly.NotAncestorError
+ 81, // 49: gitaly.UserCherryPickError.changes_already_applied:type_name -> gitaly.ChangesAlreadyAppliedError
+ 73, // 50: gitaly.UserCherryPickError.access_check:type_name -> gitaly.AccessCheckError
+ 69, // 51: gitaly.UserRevertRequest.repository:type_name -> gitaly.Repository
+ 70, // 52: gitaly.UserRevertRequest.user:type_name -> gitaly.User
+ 79, // 53: gitaly.UserRevertRequest.commit:type_name -> gitaly.GitCommit
+ 69, // 54: gitaly.UserRevertRequest.start_repository:type_name -> gitaly.Repository
+ 75, // 55: gitaly.UserRevertRequest.timestamp:type_name -> google.protobuf.Timestamp
27, // 56: gitaly.UserRevertResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
0, // 57: gitaly.UserRevertResponse.create_tree_error_code:type_name -> gitaly.UserRevertResponse.CreateTreeError
- 77, // 58: gitaly.UserRevertError.merge_conflict:type_name -> gitaly.MergeConflictError
- 80, // 59: gitaly.UserRevertError.changes_already_applied:type_name -> gitaly.ChangesAlreadyAppliedError
- 71, // 60: gitaly.UserRevertError.custom_hook:type_name -> gitaly.CustomHookError
- 79, // 61: gitaly.UserRevertError.not_ancestor:type_name -> gitaly.NotAncestorError
+ 78, // 58: gitaly.UserRevertError.merge_conflict:type_name -> gitaly.MergeConflictError
+ 81, // 59: gitaly.UserRevertError.changes_already_applied:type_name -> gitaly.ChangesAlreadyAppliedError
+ 72, // 60: gitaly.UserRevertError.custom_hook:type_name -> gitaly.CustomHookError
+ 80, // 61: gitaly.UserRevertError.not_ancestor:type_name -> gitaly.NotAncestorError
1, // 62: gitaly.UserCommitFilesActionHeader.action:type_name -> gitaly.UserCommitFilesActionHeader.ActionType
37, // 63: gitaly.UserCommitFilesAction.header:type_name -> gitaly.UserCommitFilesActionHeader
- 68, // 64: gitaly.UserCommitFilesRequestHeader.repository:type_name -> gitaly.Repository
- 69, // 65: gitaly.UserCommitFilesRequestHeader.user:type_name -> gitaly.User
- 68, // 66: gitaly.UserCommitFilesRequestHeader.start_repository:type_name -> gitaly.Repository
- 74, // 67: gitaly.UserCommitFilesRequestHeader.timestamp:type_name -> google.protobuf.Timestamp
+ 69, // 64: gitaly.UserCommitFilesRequestHeader.repository:type_name -> gitaly.Repository
+ 70, // 65: gitaly.UserCommitFilesRequestHeader.user:type_name -> gitaly.User
+ 69, // 66: gitaly.UserCommitFilesRequestHeader.start_repository:type_name -> gitaly.Repository
+ 75, // 67: gitaly.UserCommitFilesRequestHeader.timestamp:type_name -> google.protobuf.Timestamp
39, // 68: gitaly.UserCommitFilesRequest.header:type_name -> gitaly.UserCommitFilesRequestHeader
38, // 69: gitaly.UserCommitFilesRequest.action:type_name -> gitaly.UserCommitFilesAction
27, // 70: gitaly.UserCommitFilesResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 72, // 71: gitaly.UserCommitFilesError.access_check:type_name -> gitaly.AccessCheckError
- 81, // 72: gitaly.UserCommitFilesError.index_update:type_name -> gitaly.IndexError
- 71, // 73: gitaly.UserCommitFilesError.custom_hook:type_name -> gitaly.CustomHookError
- 66, // 74: gitaly.UserRebaseConfirmableRequest.header:type_name -> gitaly.UserRebaseConfirmableRequest.Header
- 68, // 75: gitaly.UserSquashRequest.repository:type_name -> gitaly.Repository
- 69, // 76: gitaly.UserSquashRequest.user:type_name -> gitaly.User
- 69, // 77: gitaly.UserSquashRequest.author:type_name -> gitaly.User
- 74, // 78: gitaly.UserSquashRequest.timestamp:type_name -> google.protobuf.Timestamp
- 77, // 79: gitaly.UserRebaseConfirmableError.rebase_conflict:type_name -> gitaly.MergeConflictError
- 72, // 80: gitaly.UserRebaseConfirmableError.access_check:type_name -> gitaly.AccessCheckError
- 82, // 81: gitaly.UserSquashError.resolve_revision:type_name -> gitaly.ResolveRevisionError
- 77, // 82: gitaly.UserSquashError.rebase_conflict:type_name -> gitaly.MergeConflictError
- 67, // 83: gitaly.UserApplyPatchRequest.header:type_name -> gitaly.UserApplyPatchRequest.Header
- 71, // 84: gitaly.UserApplyPatchError.custom_hook:type_name -> gitaly.CustomHookError
+ 73, // 71: gitaly.UserCommitFilesError.access_check:type_name -> gitaly.AccessCheckError
+ 82, // 72: gitaly.UserCommitFilesError.index_update:type_name -> gitaly.IndexError
+ 72, // 73: gitaly.UserCommitFilesError.custom_hook:type_name -> gitaly.CustomHookError
+ 67, // 74: gitaly.UserRebaseConfirmableRequest.header:type_name -> gitaly.UserRebaseConfirmableRequest.Header
+ 69, // 75: gitaly.UserSquashRequest.repository:type_name -> gitaly.Repository
+ 70, // 76: gitaly.UserSquashRequest.user:type_name -> gitaly.User
+ 70, // 77: gitaly.UserSquashRequest.author:type_name -> gitaly.User
+ 75, // 78: gitaly.UserSquashRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 78, // 79: gitaly.UserRebaseConfirmableError.rebase_conflict:type_name -> gitaly.MergeConflictError
+ 73, // 80: gitaly.UserRebaseConfirmableError.access_check:type_name -> gitaly.AccessCheckError
+ 83, // 81: gitaly.UserSquashError.resolve_revision:type_name -> gitaly.ResolveRevisionError
+ 78, // 82: gitaly.UserSquashError.rebase_conflict:type_name -> gitaly.MergeConflictError
+ 68, // 83: gitaly.UserApplyPatchRequest.header:type_name -> gitaly.UserApplyPatchRequest.Header
+ 72, // 84: gitaly.UserApplyPatchError.custom_hook:type_name -> gitaly.CustomHookError
27, // 85: gitaly.UserApplyPatchResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 68, // 86: gitaly.UserUpdateSubmoduleRequest.repository:type_name -> gitaly.Repository
- 69, // 87: gitaly.UserUpdateSubmoduleRequest.user:type_name -> gitaly.User
- 74, // 88: gitaly.UserUpdateSubmoduleRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 69, // 86: gitaly.UserUpdateSubmoduleRequest.repository:type_name -> gitaly.Repository
+ 70, // 87: gitaly.UserUpdateSubmoduleRequest.user:type_name -> gitaly.User
+ 75, // 88: gitaly.UserUpdateSubmoduleRequest.timestamp:type_name -> google.protobuf.Timestamp
27, // 89: gitaly.UserUpdateSubmoduleResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 71, // 90: gitaly.UserUpdateSubmoduleError.custom_hook:type_name -> gitaly.CustomHookError
- 73, // 91: gitaly.UserUpdateSubmoduleError.reference_update:type_name -> gitaly.ReferenceUpdateError
- 83, // 92: gitaly.UserUpdateSubmoduleError.path_error:type_name -> gitaly.PathError
- 68, // 93: gitaly.UserLandRequest.repository:type_name -> gitaly.Repository
- 69, // 94: gitaly.UserLandRequest.user:type_name -> gitaly.User
+ 72, // 90: gitaly.UserUpdateSubmoduleError.custom_hook:type_name -> gitaly.CustomHookError
+ 74, // 91: gitaly.UserUpdateSubmoduleError.reference_update:type_name -> gitaly.ReferenceUpdateError
+ 84, // 92: gitaly.UserUpdateSubmoduleError.path_error:type_name -> gitaly.PathError
+ 69, // 93: gitaly.UserLandRequest.repository:type_name -> gitaly.Repository
+ 70, // 94: gitaly.UserLandRequest.user:type_name -> gitaly.User
2, // 95: gitaly.UserLandRequest.strategy:type_name -> gitaly.UserLandRequest.Strategy
- 74, // 96: gitaly.UserLandRequest.timestamp:type_name -> google.protobuf.Timestamp
- 62, // 97: gitaly.UserLandRequest.resolution:type_name -> gitaly.LandResolution
+ 75, // 96: gitaly.UserLandRequest.timestamp:type_name -> google.protobuf.Timestamp
+ 63, // 97: gitaly.UserLandRequest.resolution:type_name -> gitaly.LandResolution
57, // 98: gitaly.LandConflict.files:type_name -> gitaly.LandConflictFile
- 59, // 99: gitaly.LandConflict.messages:type_name -> gitaly.LandConflictMessage
+ 60, // 99: gitaly.LandConflict.messages:type_name -> gitaly.LandConflictMessage
3, // 100: gitaly.LandConflictFile.kind:type_name -> gitaly.LandConflictFile.Kind
- 58, // 101: gitaly.LandConflictFile.base:type_name -> gitaly.LandConflictSide
- 58, // 102: gitaly.LandConflictFile.ours:type_name -> gitaly.LandConflictSide
- 58, // 103: gitaly.LandConflictFile.theirs:type_name -> gitaly.LandConflictSide
- 60, // 104: gitaly.LandConflictFile.hunks:type_name -> gitaly.LandConflictHunk
+ 59, // 101: gitaly.LandConflictFile.base:type_name -> gitaly.LandConflictSide
+ 59, // 102: gitaly.LandConflictFile.ours:type_name -> gitaly.LandConflictSide
+ 59, // 103: gitaly.LandConflictFile.theirs:type_name -> gitaly.LandConflictSide
+ 61, // 104: gitaly.LandConflictFile.hunks:type_name -> gitaly.LandConflictHunk
4, // 105: gitaly.LandConflictFile.outcome:type_name -> gitaly.LandConflictFile.Outcome
- 61, // 106: gitaly.LandConflictHunk.base:type_name -> gitaly.LineRange
- 61, // 107: gitaly.LandConflictHunk.ours:type_name -> gitaly.LineRange
- 61, // 108: gitaly.LandConflictHunk.theirs:type_name -> gitaly.LineRange
- 63, // 109: gitaly.LandResolution.files:type_name -> gitaly.LandResolvedFile
- 5, // 110: gitaly.LandResolvedFile.action:type_name -> gitaly.LandResolvedFile.Action
- 27, // 111: gitaly.UserLandResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
- 77, // 112: gitaly.UserLandError.merge_conflict:type_name -> gitaly.MergeConflictError
- 79, // 113: gitaly.UserLandError.not_ancestor:type_name -> gitaly.NotAncestorError
- 73, // 114: gitaly.UserLandError.reference_update:type_name -> gitaly.ReferenceUpdateError
- 71, // 115: gitaly.UserLandError.custom_hook:type_name -> gitaly.CustomHookError
- 72, // 116: gitaly.UserLandError.access_check:type_name -> gitaly.AccessCheckError
- 68, // 117: gitaly.UserRebaseConfirmableRequest.Header.repository:type_name -> gitaly.Repository
- 69, // 118: gitaly.UserRebaseConfirmableRequest.Header.user:type_name -> gitaly.User
- 68, // 119: gitaly.UserRebaseConfirmableRequest.Header.remote_repository:type_name -> gitaly.Repository
- 74, // 120: gitaly.UserRebaseConfirmableRequest.Header.timestamp:type_name -> google.protobuf.Timestamp
- 68, // 121: gitaly.UserApplyPatchRequest.Header.repository:type_name -> gitaly.Repository
- 69, // 122: gitaly.UserApplyPatchRequest.Header.user:type_name -> gitaly.User
- 74, // 123: gitaly.UserApplyPatchRequest.Header.timestamp:type_name -> google.protobuf.Timestamp
- 6, // 124: gitaly.OperationService.UserCreateBranch:input_type -> gitaly.UserCreateBranchRequest
- 9, // 125: gitaly.OperationService.UserUpdateBranch:input_type -> gitaly.UserUpdateBranchRequest
- 11, // 126: gitaly.OperationService.UserDeleteBranch:input_type -> gitaly.UserDeleteBranchRequest
- 16, // 127: gitaly.OperationService.UserCreateTag:input_type -> gitaly.UserCreateTagRequest
- 14, // 128: gitaly.OperationService.UserDeleteTag:input_type -> gitaly.UserDeleteTagRequest
- 22, // 129: gitaly.OperationService.UserMergeToRef:input_type -> gitaly.UserMergeToRefRequest
- 25, // 130: gitaly.OperationService.UserRebaseToRef:input_type -> gitaly.UserRebaseToRefRequest
- 19, // 131: gitaly.OperationService.UserMergeBranch:input_type -> gitaly.UserMergeBranchRequest
- 29, // 132: gitaly.OperationService.UserFFBranch:input_type -> gitaly.UserFFBranchRequest
- 31, // 133: gitaly.OperationService.UserCherryPick:input_type -> gitaly.UserCherryPickRequest
- 40, // 134: gitaly.OperationService.UserCommitFiles:input_type -> gitaly.UserCommitFilesRequest
- 43, // 135: gitaly.OperationService.UserRebaseConfirmable:input_type -> gitaly.UserRebaseConfirmableRequest
- 34, // 136: gitaly.OperationService.UserRevert:input_type -> gitaly.UserRevertRequest
- 45, // 137: gitaly.OperationService.UserSquash:input_type -> gitaly.UserSquashRequest
- 49, // 138: gitaly.OperationService.UserApplyPatch:input_type -> gitaly.UserApplyPatchRequest
- 52, // 139: gitaly.OperationService.UserUpdateSubmodule:input_type -> gitaly.UserUpdateSubmoduleRequest
- 55, // 140: gitaly.OperationService.UserLand:input_type -> gitaly.UserLandRequest
- 7, // 141: gitaly.OperationService.UserCreateBranch:output_type -> gitaly.UserCreateBranchResponse
- 10, // 142: gitaly.OperationService.UserUpdateBranch:output_type -> gitaly.UserUpdateBranchResponse
- 12, // 143: gitaly.OperationService.UserDeleteBranch:output_type -> gitaly.UserDeleteBranchResponse
- 17, // 144: gitaly.OperationService.UserCreateTag:output_type -> gitaly.UserCreateTagResponse
- 15, // 145: gitaly.OperationService.UserDeleteTag:output_type -> gitaly.UserDeleteTagResponse
- 23, // 146: gitaly.OperationService.UserMergeToRef:output_type -> gitaly.UserMergeToRefResponse
- 26, // 147: gitaly.OperationService.UserRebaseToRef:output_type -> gitaly.UserRebaseToRefResponse
- 20, // 148: gitaly.OperationService.UserMergeBranch:output_type -> gitaly.UserMergeBranchResponse
- 30, // 149: gitaly.OperationService.UserFFBranch:output_type -> gitaly.UserFFBranchResponse
- 32, // 150: gitaly.OperationService.UserCherryPick:output_type -> gitaly.UserCherryPickResponse
- 41, // 151: gitaly.OperationService.UserCommitFiles:output_type -> gitaly.UserCommitFilesResponse
- 44, // 152: gitaly.OperationService.UserRebaseConfirmable:output_type -> gitaly.UserRebaseConfirmableResponse
- 35, // 153: gitaly.OperationService.UserRevert:output_type -> gitaly.UserRevertResponse
- 46, // 154: gitaly.OperationService.UserSquash:output_type -> gitaly.UserSquashResponse
- 51, // 155: gitaly.OperationService.UserApplyPatch:output_type -> gitaly.UserApplyPatchResponse
- 53, // 156: gitaly.OperationService.UserUpdateSubmodule:output_type -> gitaly.UserUpdateSubmoduleResponse
- 64, // 157: gitaly.OperationService.UserLand:output_type -> gitaly.UserLandResponse
- 141, // [141:158] is the sub-list for method output_type
- 124, // [124:141] is the sub-list for method input_type
- 124, // [124:124] is the sub-list for extension type_name
- 124, // [124:124] is the sub-list for extension extendee
- 0, // [0:124] is the sub-list for field type_name
+ 58, // 106: gitaly.LandConflictFile.proposal:type_name -> gitaly.LandConflictProposal
+ 62, // 107: gitaly.LandConflictHunk.base:type_name -> gitaly.LineRange
+ 62, // 108: gitaly.LandConflictHunk.ours:type_name -> gitaly.LineRange
+ 62, // 109: gitaly.LandConflictHunk.theirs:type_name -> gitaly.LineRange
+ 64, // 110: gitaly.LandResolution.files:type_name -> gitaly.LandResolvedFile
+ 5, // 111: gitaly.LandResolvedFile.action:type_name -> gitaly.LandResolvedFile.Action
+ 27, // 112: gitaly.UserLandResponse.branch_update:type_name -> gitaly.OperationBranchUpdate
+ 78, // 113: gitaly.UserLandError.merge_conflict:type_name -> gitaly.MergeConflictError
+ 80, // 114: gitaly.UserLandError.not_ancestor:type_name -> gitaly.NotAncestorError
+ 74, // 115: gitaly.UserLandError.reference_update:type_name -> gitaly.ReferenceUpdateError
+ 72, // 116: gitaly.UserLandError.custom_hook:type_name -> gitaly.CustomHookError
+ 73, // 117: gitaly.UserLandError.access_check:type_name -> gitaly.AccessCheckError
+ 69, // 118: gitaly.UserRebaseConfirmableRequest.Header.repository:type_name -> gitaly.Repository
+ 70, // 119: gitaly.UserRebaseConfirmableRequest.Header.user:type_name -> gitaly.User
+ 69, // 120: gitaly.UserRebaseConfirmableRequest.Header.remote_repository:type_name -> gitaly.Repository
+ 75, // 121: gitaly.UserRebaseConfirmableRequest.Header.timestamp:type_name -> google.protobuf.Timestamp
+ 69, // 122: gitaly.UserApplyPatchRequest.Header.repository:type_name -> gitaly.Repository
+ 70, // 123: gitaly.UserApplyPatchRequest.Header.user:type_name -> gitaly.User
+ 75, // 124: gitaly.UserApplyPatchRequest.Header.timestamp:type_name -> google.protobuf.Timestamp
+ 6, // 125: gitaly.OperationService.UserCreateBranch:input_type -> gitaly.UserCreateBranchRequest
+ 9, // 126: gitaly.OperationService.UserUpdateBranch:input_type -> gitaly.UserUpdateBranchRequest
+ 11, // 127: gitaly.OperationService.UserDeleteBranch:input_type -> gitaly.UserDeleteBranchRequest
+ 16, // 128: gitaly.OperationService.UserCreateTag:input_type -> gitaly.UserCreateTagRequest
+ 14, // 129: gitaly.OperationService.UserDeleteTag:input_type -> gitaly.UserDeleteTagRequest
+ 22, // 130: gitaly.OperationService.UserMergeToRef:input_type -> gitaly.UserMergeToRefRequest
+ 25, // 131: gitaly.OperationService.UserRebaseToRef:input_type -> gitaly.UserRebaseToRefRequest
+ 19, // 132: gitaly.OperationService.UserMergeBranch:input_type -> gitaly.UserMergeBranchRequest
+ 29, // 133: gitaly.OperationService.UserFFBranch:input_type -> gitaly.UserFFBranchRequest
+ 31, // 134: gitaly.OperationService.UserCherryPick:input_type -> gitaly.UserCherryPickRequest
+ 40, // 135: gitaly.OperationService.UserCommitFiles:input_type -> gitaly.UserCommitFilesRequest
+ 43, // 136: gitaly.OperationService.UserRebaseConfirmable:input_type -> gitaly.UserRebaseConfirmableRequest
+ 34, // 137: gitaly.OperationService.UserRevert:input_type -> gitaly.UserRevertRequest
+ 45, // 138: gitaly.OperationService.UserSquash:input_type -> gitaly.UserSquashRequest
+ 49, // 139: gitaly.OperationService.UserApplyPatch:input_type -> gitaly.UserApplyPatchRequest
+ 52, // 140: gitaly.OperationService.UserUpdateSubmodule:input_type -> gitaly.UserUpdateSubmoduleRequest
+ 55, // 141: gitaly.OperationService.UserLand:input_type -> gitaly.UserLandRequest
+ 7, // 142: gitaly.OperationService.UserCreateBranch:output_type -> gitaly.UserCreateBranchResponse
+ 10, // 143: gitaly.OperationService.UserUpdateBranch:output_type -> gitaly.UserUpdateBranchResponse
+ 12, // 144: gitaly.OperationService.UserDeleteBranch:output_type -> gitaly.UserDeleteBranchResponse
+ 17, // 145: gitaly.OperationService.UserCreateTag:output_type -> gitaly.UserCreateTagResponse
+ 15, // 146: gitaly.OperationService.UserDeleteTag:output_type -> gitaly.UserDeleteTagResponse
+ 23, // 147: gitaly.OperationService.UserMergeToRef:output_type -> gitaly.UserMergeToRefResponse
+ 26, // 148: gitaly.OperationService.UserRebaseToRef:output_type -> gitaly.UserRebaseToRefResponse
+ 20, // 149: gitaly.OperationService.UserMergeBranch:output_type -> gitaly.UserMergeBranchResponse
+ 30, // 150: gitaly.OperationService.UserFFBranch:output_type -> gitaly.UserFFBranchResponse
+ 32, // 151: gitaly.OperationService.UserCherryPick:output_type -> gitaly.UserCherryPickResponse
+ 41, // 152: gitaly.OperationService.UserCommitFiles:output_type -> gitaly.UserCommitFilesResponse
+ 44, // 153: gitaly.OperationService.UserRebaseConfirmable:output_type -> gitaly.UserRebaseConfirmableResponse
+ 35, // 154: gitaly.OperationService.UserRevert:output_type -> gitaly.UserRevertResponse
+ 46, // 155: gitaly.OperationService.UserSquash:output_type -> gitaly.UserSquashResponse
+ 51, // 156: gitaly.OperationService.UserApplyPatch:output_type -> gitaly.UserApplyPatchResponse
+ 53, // 157: gitaly.OperationService.UserUpdateSubmodule:output_type -> gitaly.UserUpdateSubmoduleResponse
+ 65, // 158: gitaly.OperationService.UserLand:output_type -> gitaly.UserLandResponse
+ 142, // [142:159] is the sub-list for method output_type
+ 125, // [125:142] is the sub-list for method input_type
+ 125, // [125:125] is the sub-list for extension type_name
+ 125, // [125:125] is the sub-list for extension extendee
+ 0, // [0:125] is the sub-list for field type_name
}
func init() { file_operations_proto_init() }
@@ -6832,7 +6955,7 @@ func file_operations_proto_init() {
(*UserUpdateSubmoduleError_ReferenceUpdate)(nil),
(*UserUpdateSubmoduleError_PathError)(nil),
}
- file_operations_proto_msgTypes[59].OneofWrappers = []any{
+ file_operations_proto_msgTypes[60].OneofWrappers = []any{
(*UserLandError_MergeConflict)(nil),
(*UserLandError_NotAncestor)(nil),
(*UserLandError_ReferenceUpdate)(nil),
@@ -6845,7 +6968,7 @@ func file_operations_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_operations_proto_rawDesc), len(file_operations_proto_rawDesc)),
NumEnums: 6,
- NumMessages: 62,
+ NumMessages: 63,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/operations.proto b/proto/operations.proto
index ec1f4b1..ed5d3b0 100644
--- a/proto/operations.proto
+++ b/proto/operations.proto
@@ -1310,6 +1310,10 @@ message LandConflict {
string reason = 8;
// messages are the messages of the merge about its conflicts, at most 1000.
repeated LandConflictMessage messages = 9;
+ // proposal_ref is the hidden reference that keeps the proposals of the package
+ // (refs/graft/proposals/...), empty when no file has a proposal. Its blobs are
+ // read by the oids of LandConflictProposal.
+ string proposal_ref = 10;
}
// LandConflictFile is one conflicting file of a LandConflict.
@@ -1345,6 +1349,9 @@ message LandConflictFile {
// OUTCOME_NOT_ATTEMPTED: the request was not resolved at all (see
// LandConflict.reason).
OUTCOME_NOT_ATTEMPTED = 5;
+ // OUTCOME_PROPOSED: a model resolved the file; the server never lands a
+ // model's resolution, it proposes it (see proposal).
+ OUTCOME_PROPOSED = 6;
}
// path is the path of the conflict in the merged tree.
bytes path = 1;
@@ -1371,6 +1378,26 @@ message LandConflictFile {
// than a file lists, or a package over its size bound. It is empty when hunks is
// complete, and for the kinds of conflict that have no hunks.
string hunks_omitted = 10;
+ // proposal is the resolution the resolver made of the file, for a file that a
+ // model proposed (OUTCOME_PROPOSED) or that the rules resolved in a land that
+ // failed for another file (OUTCOME_RESOLVED), so that the agent can land it as
+ // it is or edit it.
+ LandConflictProposal proposal = 11;
+}
+
+// LandConflictProposal is the resolver's resolution of one conflicting file.
+message LandConflictProposal {
+ // action is "write" or "delete".
+ string action = 1;
+ // oid is the blob of the resolved content, for a write; it is kept in the
+ // repository by LandConflict.proposal_ref.
+ string oid = 2;
+ // mode is the file mode of a write.
+ string mode = 3;
+ // resolver names what made it: the resolver and its strategies.
+ string resolver = 4;
+ // explanation is the resolver's explanation, cut to 512 bytes.
+ string explanation = 5;
}
// LandConflictSide is one side of a conflicting file; its content is read by oid.
diff --git a/sdk/conflict.go b/sdk/conflict.go
index 92a8343..4c0af30 100644
--- a/sdk/conflict.go
+++ b/sdk/conflict.go
@@ -24,10 +24,25 @@ func LandConflict(err error) (*gitalypb.LandConflict, bool) {
// ConflictSides are the contents of the sides of a conflicting file. An absent side is nil, and so
// is a side that cannot be read: Unreadable gives the reason of each, by side ("base", "ours",
-// "theirs").
+// "theirs"), and "proposal" for a proposal whose content cannot be read.
type ConflictSides struct {
Base, Ours, Theirs []byte
Unreadable map[string]string
+ // Proposal is the resolver's resolution of the file, when it made one: a model's, which the
+ // server never lands (OUTCOME_PROPOSED), or the rules' in a land that failed for another file.
+ // Land it, edited or not, as your own (ResolutionFromProposals).
+ Proposal *Proposal
+}
+
+// Proposal is the resolver's resolution of one conflicting file.
+type Proposal struct {
+ // Delete proposes to delete the path; otherwise Content is written with Mode. Content is nil
+ // when it cannot be read (ConflictSides.Unreadable["proposal"]).
+ Delete bool
+ Mode string
+ Content []byte
+ // Resolver names what made it; Explanation is the resolver's, cut to 512 bytes.
+ Resolver, Explanation string
}
// ConflictSides reads the sides of every file of a conflict package, by path, with GetObjects. A
@@ -44,6 +59,10 @@ func (r *Repo) ConflictSides(ctx context.Context, c *gitalypb.LandConflict) (map
oids = append(oids, oid)
}
}
+ if oid := f.GetProposal().GetOid(); oid != "" && !seen[oid] {
+ seen[oid] = true
+ oids = append(oids, oid)
+ }
}
data := make(map[string][]byte, len(oids))
missing := map[string]bool{}
@@ -80,6 +99,21 @@ func (r *Repo) ConflictSides(ctx context.Context, c *gitalypb.LandConflict) (map
}
}
cs := ConflictSides{Base: sides[0], Ours: sides[1], Theirs: sides[2]}
+ if prop := f.GetProposal(); prop != nil {
+ cs.Proposal = &Proposal{Delete: prop.GetAction() == "delete", Resolver: prop.GetResolver(), Explanation: prop.GetExplanation()}
+ if !cs.Proposal.Delete {
+ cs.Proposal.Mode = prop.GetMode()
+ switch {
+ case prop.GetOid() == "" || missing[prop.GetOid()]:
+ unreadable["proposal"] = "the blob " + prop.GetOid() + " of the proposal is missing from the repository"
+ default:
+ cs.Proposal.Content = data[prop.GetOid()]
+ if cs.Proposal.Content == nil {
+ cs.Proposal.Content = []byte{}
+ }
+ }
+ }
+ }
if len(unreadable) > 0 {
cs.Unreadable = unreadable
}
@@ -112,6 +146,25 @@ func ResolutionFor(c *gitalypb.LandConflict) *Resolution {
return &Resolution{Tip: c.GetTip(), Commit: c.GetCommit()}
}
+// ResolutionFromProposals returns the resolution of the conflicts of c that takes every readable
+// proposal of sides (ConflictSides) as it is. The paths without one are left out: add them, and
+// review or edit the proposals, before landing it. The proposals land as yours.
+func ResolutionFromProposals(c *gitalypb.LandConflict, sides map[string]ConflictSides) *Resolution {
+ res := ResolutionFor(c)
+ for _, f := range c.GetFiles() {
+ p := string(f.GetPath())
+ prop := sides[p].Proposal
+ switch {
+ case prop == nil:
+ case prop.Delete:
+ res.Files = append(res.Files, ResolvedFile{Path: p, Delete: true})
+ case prop.Content != nil:
+ res.Files = append(res.Files, ResolvedFile{Path: p, Mode: prop.Mode, Content: prop.Content})
+ }
+ }
+ return res
+}
+
// toProto returns the resolution as the request field.
func (r *Resolution) toProto() *gitalypb.LandResolution {
out := &gitalypb.LandResolution{Tip: r.Tip, Commit: r.Commit}