Skip to content

Git designed for AI agents.

graft: held reasons say why, and the tools and sdk review minors

Federico Elia94859a0c6fa1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index dd332f1..1bdd2ae 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -157,3 +157,18 @@ jobs:
- name: Test (graft-agents module)
run: go -C tools/graft-agents test ./...
+
+ graft-agents-nocgo:
+ # The llm strategy needs the tree-sitter grammars (cgo): without them the module still has to
+ # build and its tests run, and graft-resolve refuses an llm strategy at startup.
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: tools/graft-agents/go.mod
+
+ - name: Test (graft-agents module, CGO_ENABLED=0)
+ run: CGO_ENABLED=0 go -C tools/graft-agents test ./...
diff --git a/cmd/graft/conflicts.go b/cmd/graft/conflicts.go
index 84121d2..f095541 100644
--- a/cmd/graft/conflicts.go
+++ b/cmd/graft/conflicts.go
@@ -30,10 +30,10 @@ import (
// 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 did not land because no verification passed on
-// it, or the rules' of a land
-// that failed for another file); copy it over DIR/files/<path> to
-// land it as yours
+// resolution, which did not land because verify.command did not pass
+// on its tree, is not configured, or the resolver held it back; or
+// the rules' resolution 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
diff --git a/doc/graft/CONFIGURATION.md b/doc/graft/CONFIGURATION.md
index 8a6eb1c..15e0b96 100644
--- a/doc/graft/CONFIGURATION.md
+++ b/doc/graft/CONFIGURATION.md
@@ -240,7 +240,7 @@ are in [STORAGE.md](STORAGE.md).
| `database` | string | required when on | `sqlite:///absolute/path.db`, or `postgres://user@host:port/db?sslmode=...` (`postgresql://` too). All nodes use the same database. Credentials are not written here: Postgres reads the `PG*` environment variables and `.pgpass`. The schema is created at startup. |
| `bucket` | string | required when on | gocloud URL of the object storage: `file:///absolute/dir`, `s3://bucket?region=...`, `gs://bucket` or `azblob://container`. All nodes use the same bucket. Credentials come from the cloud SDK's environment (`AWS_*`, `GOOGLE_APPLICATION_CREDENTIALS`, `AZURE_*`). |
| `node_id` | string | the host name | Name of this node in the database (changesets record it, and `graft storage state` shows it). Must not contain spaces or slashes. Give every node its own. |
-| `sync_timeout` | string (Go duration) | `"10s"` | Budget of one sync round before a request in authoritative mode. A round that cannot reach the head in time keeps what it did: the local repository stays at the changeset it reached, the request fails with `Unavailable`, and the next request's round goes on from there. A round that cannot finish at all (for example because the database is unreachable or a local writer holds a reference lock) fails the request with `Unavailable` too. Concurrent requests share a round; a request that arrives during a round that read the head before it then runs one of its own, so it waits at most two rounds (and stops waiting with `Unavailable` after twice `sync_timeout` plus a second per round, should a round not end within its budget). Clients retry `Unavailable`: the SDK does it for merge and fast-forward lands (`LandOptions.RetryUnavailable`, see [LAND-BATCHING](LAND-BATCHING.md#limits)); rebase lands are not retried by default, because the server cannot yet tell that a rebased change already landed. A client without the SDK must follow the same rules. Must be positive. |
+| `sync_timeout` | string (Go duration) | `"10s"` | Budget of one sync round before a request in authoritative mode. A round that cannot reach the head in time keeps what it did: the local repository stays at the changeset it reached, the request fails with `Unavailable`, and the next request's round goes on from there. A round that cannot finish at all (for example because the database is unreachable or a local writer holds a reference lock) fails the request with `Unavailable` too. Concurrent requests share a round; a request that arrives during a round that read the head before it then runs one of its own, so it waits at most two rounds (and stops waiting with `Unavailable` after twice `sync_timeout` plus a second per round, should a round not end within its budget). Clients retry `Unavailable`: the SDK does it for merge and fast-forward lands and for re-lands with a resolution (`LandOptions.RetryUnavailable`, see [LAND-BATCHING](LAND-BATCHING.md#limits)); rebase lands are not retried by default, because the server cannot yet tell that a rebased change already landed. A client without the SDK must follow the same rules. Must be positive. |
| `shadow_timeout` | string (Go duration) | `"5s"` | Budget of the shadow-mode work of one reference transaction, for its Preparing phase (pack build and upload, before git locks the references) and its Prepared phase together. When it runs out, the work is abandoned, logged and counted, and the git write proceeds. Must be positive. |
| `gc_grace` | string (Go duration) | `"1h"` | How long garbage collection waits before it deletes a pack it observed unreferenced, and how old a checkpoint must be before the packs it covers are deleted. Must be greater than `sync_timeout + gc_margin`. |
| `gc_margin` | string (Go duration) | `"5m"` | Safety margin of the writers' deadline: a write uploads its pack and commits its changeset within `gc_grace - gc_margin`, else it fails. It also covers the difference between a node's clock and the database's. Must be positive. |
diff --git a/doc/graft/LAND-BATCHING.md b/doc/graft/LAND-BATCHING.md
index 66fadcc..37d6e5e 100644
--- a/doc/graft/LAND-BATCHING.md
+++ b/doc/graft/LAND-BATCHING.md
@@ -487,7 +487,10 @@ member) and removed it; see [PLAN8.md](PLAN8.md).
- Merge and fast-forward lands are retried by default. The response of a call
can be lost after the change landed; the change itself is then on the
branch, and the retry reports it as already landed.
- - Rebase lands, with or without conflict resolution, are not retried by
+ - A land with a `Resolution` (the re-land of a conflict package) is a merge of
+ the tip and the change, whatever its strategy: it is retried by default
+ too, and the retry finds the change already landed.
+ - Rebase lands, with or without server-side conflict resolution, are not retried by
default (`RebaseLands` turns it on). The branch holds a rebased copy of the
change, and the server cannot yet tell that this change landed: a retry
replays it, and a change that a later commit reverted in between (for
diff --git a/internal/gitaly/service/operations/land_design_test.go b/internal/gitaly/service/operations/land_design_test.go
index 0aa600e..eeae340 100644
--- a/internal/gitaly/service/operations/land_design_test.go
+++ b/internal/gitaly/service/operations/land_design_test.go
@@ -10,7 +10,7 @@ import (
"github.com/feder-cr/git-ai/proto/go/gitalypb"
)
-// Tests of the server side of the design step (PLAN10 15.11): the composition report of a model's
+// Tests of the server side of the design step (PLAN10 15.3, 15.10): the composition report of a model's
// resolution goes to the agent with the proposal.
// TestUserLand_theReportGoesWithTheProposal: the composition report of a model's resolution is the start
diff --git a/internal/gitaly/service/operations/land_proposals.go b/internal/gitaly/service/operations/land_proposals.go
index 17348c9..20050b2 100644
--- a/internal/gitaly/service/operations/land_proposals.go
+++ b/internal/gitaly/service/operations/land_proposals.go
@@ -56,9 +56,14 @@ const landNoVerifyReason = "no verify.command is configured, so nothing verifies
// landHeldReason is the reason of a file that the resolver holds back: the second model of the llm
// strategy's agree_with gate did not agree with the first, so the resolution is a proposal that
-// does not land by itself, even on a tree that verify.command passed on. The resolver's own words
-// follow it.
-const landHeldReason = "held back by the resolver, so it does not land by itself even if verify.command passes (see proposal): "
+// does not land by itself, even on a tree that verify.command passed on. The reason starts with
+// "held:" and the resolver's own words (hold), and says what that means for the land.
+func landHeldReason(hold string) string {
+ if !strings.HasPrefix(hold, "held: ") {
+ hold = "held: " + hold
+ }
+ return hold + " (the proposal does not land by itself, even if verify.command passes)"
+}
// landAnswerHolds reports whether a resolver's answer holds back a file (ResponseFile.Hold): such an
// answer never lands, whatever verify.command says.
diff --git a/internal/gitaly/service/operations/land_resolve.go b/internal/gitaly/service/operations/land_resolve.go
index 69fab4d..fe1b1f4 100644
--- a/internal/gitaly/service/operations/land_resolve.go
+++ b/internal/gitaly/service/operations/land_resolve.go
@@ -327,7 +327,7 @@ func landSetOutcomes(answer *resolver.Response, files []*landFileState) {
case err != nil:
f.outcome, f.reason = gitalypb.LandConflictFile_OUTCOME_REJECTED, err.Error()
case rf.Hold != "":
- f.outcome, f.reason = gitalypb.LandConflictFile_OUTCOME_PROPOSED, landCutString(landHeldReason+rf.Hold, landPackageReasonBytes)
+ f.outcome, f.reason = gitalypb.LandConflictFile_OUTCOME_PROPOSED, landCutString(landHeldReason(rf.Hold), landPackageReasonBytes)
case rf.FromModel():
f.outcome, f.reason = gitalypb.LandConflictFile_OUTCOME_PROPOSED, landProposedReason
}
diff --git a/internal/gitaly/service/operations/land_verified_test.go b/internal/gitaly/service/operations/land_verified_test.go
index 6a76073..118c2f3 100644
--- a/internal/gitaly/service/operations/land_verified_test.go
+++ b/internal/gitaly/service/operations/land_verified_test.go
@@ -807,7 +807,7 @@ func TestUserLand_aHeldModelResolutionNeverLands(t *testing.T) {
t.Parallel()
held := modelAnswer()
- held.Files[0].Hold = "the second model (glm) disagreed"
+ held.Files[0].Hold = "held: the second model (glm) disagreed"
fx, rdir, vdir := verifiedFixture(t, held, "grep -qx merged-a a && grep -qx merged-b b && grep -qx d d", nil)
_, err := fx.client.UserLand(fx.ctx, fx.request("Land agent work"))
@@ -819,7 +819,7 @@ func TestUserLand_aHeldModelResolutionNeverLands(t *testing.T) {
require.Equal(t, gitalypb.LandConflictFile_OUTCOME_PROPOSED, f.GetOutcome(), f.GetPath())
reasons = append(reasons, f.GetReason())
}
- require.Contains(t, strings.Join(reasons, "\n"), landHeldReason+"the second model (glm) disagreed")
+ require.Contains(t, strings.Join(reasons, "\n"), landHeldReason("held: the second model (glm) disagreed"))
require.Equal(t, 1, resolverCalls(t, rdir))
require.Equal(t, 0, verifyRuns(t, vdir), "a land that cannot land is not verified")
requireBranchAt(t, fx.cfg, fx.repoPath, git.DefaultBranch, fx.tip)
diff --git a/internal/graft/e2e/proposals_agree_test.go b/internal/graft/e2e/proposals_agree_test.go
index ab8101f..289be94 100644
--- a/internal/graft/e2e/proposals_agree_test.go
+++ b/internal/graft/e2e/proposals_agree_test.go
@@ -119,10 +119,10 @@ func TestAgreeWithTheModelsThatDisagreeAreHeld(t *testing.T) {
require.Len(t, pkg.GetFiles(), 1)
f := pkg.GetFiles()[0]
require.Equal(t, gitalypb.LandConflictFile_OUTCOME_PROPOSED, f.GetOutcome())
- require.Contains(t, f.GetReason(), "held back by the resolver")
+ require.Contains(t, f.GetReason(), "held: the second model (fake-b) disagreed")
require.Contains(t, f.GetReason(), "fake-b")
require.NotNil(t, f.GetProposal(), "the first model's proposal is kept for the agent")
- require.Contains(t, f.GetProposal().GetExplanation(), "the second model disagreed")
+ require.Contains(t, f.GetProposal().GetExplanation(), "held: the second model (fake-b) disagreed")
}
// TestStorageProposalsInAuthoritativeMode: the references of the proposals are written and pruned
diff --git a/internal/graft/resolver/protocol_enums_test.go b/internal/graft/resolver/protocol_enums_test.go
new file mode 100644
index 0000000..55d8bed
--- /dev/null
+++ b/internal/graft/resolver/protocol_enums_test.go
@@ -0,0 +1,43 @@
+package resolver
+
+import (
+ "encoding/json"
+ "os"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+// TestProtocolEnumValuesMatchTheGolden pins the values of the enumerations of protocol v1 to
+// testdata/protocol-enums.json, which tools/graft-agents/protocol is tested against too: a value
+// that changes on one side only would make the two programs misread each other.
+func TestProtocolEnumValuesMatchTheGolden(t *testing.T) {
+ t.Parallel()
+
+ data, err := os.ReadFile("testdata/protocol-enums.json")
+ require.NoError(t, err)
+ var golden map[string]any
+ require.NoError(t, json.Unmarshal(data, &golden))
+
+ require.EqualValues(t, ProtocolVersion, golden["version"])
+ got := map[string][]string{
+ "kind": {KindContent, KindModifyDelete, KindAddAdd, KindMode},
+ "action": {ActionWrite, ActionDelete},
+ "mode": {ModeRegular, ModeExecutable, ModeSymlink},
+ "operation": {OperationResolve, OperationCheck},
+ "syntax": {SyntaxChecked, SyntaxUnchecked, SyntaxNone},
+ "origin": {OriginRule, OriginModel},
+ "outcome": {OutcomeResolved, OutcomeRejected, OutcomeFailed},
+ }
+ for name, want := range got {
+ raw, ok := golden[name].([]any)
+ require.True(t, ok, "the golden file lacks %q", name)
+ var values []string
+ for _, v := range raw {
+ values = append(values, v.(string))
+ }
+ require.Equal(t, values, want, name)
+ }
+ // Every enumeration of the golden file is checked here.
+ require.Len(t, golden, len(got)+2, "the golden file holds a comment, the version and the enumerations")
+}
diff --git a/internal/graft/resolver/testdata/protocol-enums.json b/internal/graft/resolver/testdata/protocol-enums.json
new file mode 100644
index 0000000..810cade
--- /dev/null
+++ b/internal/graft/resolver/testdata/protocol-enums.json
@@ -0,0 +1,11 @@
+{
+ "comment": "The values of the enumerations of protocol v1. Both copies of the protocol (internal/graft/resolver and tools/graft-agents/protocol) are tested against this file, so a value cannot change or drift between the server and graft-resolve without a failing test. A change of a value is a new protocol version.",
+ "version": 1,
+ "kind": ["content", "modify-delete", "add-add", "mode"],
+ "action": ["write", "delete"],
+ "mode": ["100644", "100755", "120000"],
+ "operation": ["resolve", "check"],
+ "syntax": ["checked", "unchecked", "none"],
+ "origin": ["rule", "model"],
+ "outcome": ["resolved", "rejected", "failed"]
+}
diff --git a/sdk/land.go b/sdk/land.go
index 005700c..ab4583e 100644
--- a/sdk/land.go
+++ b/sdk/land.go
@@ -68,7 +68,8 @@ type LandOptions struct {
Resolution *Resolution
// RetryUnavailable is how Land retries a call that the server answers
// with Unavailable (see UnavailableRetry). It is on by default for
- // LandMerge and LandFastForwardOnly, and off for LandRebase.
+ // LandMerge, LandFastForwardOnly and any land with a Resolution (a merge
+ // of the tip and the change, safe to retry), and off for LandRebase.
RetryUnavailable UnavailableRetry
}
@@ -82,7 +83,8 @@ type LandOptions struct {
//
// The response of a call can be lost after the server landed the change. With
// LandMerge and LandFastForwardOnly, Commit is then reachable from the tip, and
-// the retry is reported as AlreadyLanded: these lands are retried by default.
+// the retry is reported as AlreadyLanded: these lands are retried by default,
+// and so is a land with a Resolution, which is a merge whatever its strategy.
// With LandRebase, ResolveConflicts included (a land without conflicts is a
// plain rebase), the branch holds a rebased copy, not Commit itself, and the
// server cannot tell yet that the change landed: the retry replays the change
@@ -155,9 +157,13 @@ func (r UnavailableRetry) backoff(n int) time.Duration {
}
// maxRetries returns the retries of a land with the given strategy.
-func (r UnavailableRetry) maxRetries(strategy LandStrategy) int {
+//
+// A land with a Resolution is always a merge of the tip and the change, whatever its strategy: after a
+// lost response Commit is reachable from the tip, so the retry is reported as AlreadyLanded and nothing is
+// replayed. It is retried like a merge land.
+func (r UnavailableRetry) maxRetries(strategy LandStrategy, resolution bool) int {
switch {
- case r.Disabled, strategy == LandRebase && !r.RebaseLands:
+ case r.Disabled, strategy == LandRebase && !resolution && !r.RebaseLands:
return 0
case r.MaxRetries > 0:
return r.MaxRetries
@@ -262,7 +268,7 @@ func (r *Repo) Land(ctx context.Context, opts LandOptions) (*LandResult, error)
)
for {
resp, err = r.client.operations.UserLand(ctx, req)
- if status.Code(err) != codes.Unavailable || retries >= opts.RetryUnavailable.maxRetries(opts.Strategy) {
+ if status.Code(err) != codes.Unavailable || retries >= opts.RetryUnavailable.maxRetries(opts.Strategy, opts.Resolution != nil) {
break
}
retries++
diff --git a/sdk/land_retry_test.go b/sdk/land_retry_test.go
index 6b2ba5f..45f4852 100644
--- a/sdk/land_retry_test.go
+++ b/sdk/land_retry_test.go
@@ -55,6 +55,40 @@ func TestRepo_Land_RebaseLandsAreNotRetriedByDefault(t *testing.T) {
}
}
+// TestRepo_Land_ARelandWithAResolutionIsRetriedByDefault: a Resolution lands as a merge of the tip and the
+// change, so a retry after a lost response finds Commit reachable and nothing is replayed: it is retried
+// by default whatever the strategy, the rebase one included, and Disabled still turns the retries off.
+func TestRepo_Land_ARelandWithAResolutionIsRetriedByDefault(t *testing.T) {
+ t.Parallel()
+
+ for _, tc := range []struct {
+ desc string
+ strategy sdk.LandStrategy
+ retry sdk.UnavailableRetry
+ expectedRequests int
+ }{
+ {desc: "rebase strategy", strategy: sdk.LandRebase, retry: fastRetry, expectedRequests: 6},
+ {desc: "merge strategy", strategy: sdk.LandMerge, retry: fastRetry, expectedRequests: 6},
+ {desc: "disabled", strategy: sdk.LandRebase, retry: sdk.UnavailableRetry{Disabled: true}, expectedRequests: 1},
+ } {
+ t.Run(tc.desc, func(t *testing.T) {
+ t.Parallel()
+
+ fakes := newFakeServices()
+ fakes.operations.landErr = status.Error(codes.Unavailable, "still syncing")
+ repo := dialFake(t, fakes.register).Repo("repo")
+
+ opts := validLand()
+ opts.Strategy = tc.strategy
+ opts.Resolution = &sdk.Resolution{Tip: "tip-sha", Commit: "change-sha", Files: []sdk.ResolvedFile{{Path: "a", Mode: "100644", Content: []byte("x\n")}}}
+ opts.RetryUnavailable = tc.retry
+ _, err := repo.Land(t.Context(), opts)
+ require.Equal(t, codes.Unavailable, sdk.Code(err))
+ require.Len(t, fakes.operations.landRequests, tc.expectedRequests)
+ })
+ }
+}
+
func TestRepo_Land_RetriesUnavailable(t *testing.T) {
t.Parallel()
diff --git a/tools/graft-agents/NOTICE b/tools/graft-agents/NOTICE
new file mode 100644
index 0000000..fb60c28
--- /dev/null
+++ b/tools/graft-agents/NOTICE
@@ -0,0 +1,702 @@
+The following third-party components are linked into the programs of tools/graft-agents (graft-resolve, graft-superfan).
+The tree-sitter grammars are what the llm strategy's syntax check parses with (cgo); the anthropic provider uses
+anthropic-sdk-go. This file lists the licences of the modules the programs of this module link, as they were
+in the module cache at the version of go.mod. The licences of the server's own dependencies are in the NOTICE
+of the repository.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v1.80.0 - github.com/anthropics/anthropic-sdk-go
+
+Copyright 2023 Anthropic, PBC.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.2.0 - github.com/bahlo/generic-list-go
+
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v1.1.2 - github.com/buger/jsonparser
+
+MIT License
+
+Copyright (c) 2016 Leonid Bugaev
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+COPYING v0.14.0 - github.com/invopop/jsonschema
+
+Copyright (C) 2014 Alec Thomas
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.0.1 - github.com/mattn/go-pointer
+
+The MIT License (MIT)
+
+Copyright (c) 2019 Yasuhiro Matsumoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v2.3.1 - github.com/pb33f/ordered-map/v2
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.0.1 - github.com/standard-webhooks/standard-webhooks/libraries
+
+The MIT License
+
+Copyright (c) 2023 Svix (https://www.svix.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v1.18.0 - github.com/tidwall/gjson
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Josh Baker
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v1.1.1 - github.com/tidwall/match
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Josh Baker
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v1.2.1 - github.com/tidwall/pretty
+
+The MIT License (MIT)
+
+Copyright (c) 2017 Josh Baker
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v1.2.5 - github.com/tidwall/sjson
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Josh Baker
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.25.0 - github.com/tree-sitter/go-tree-sitter
+
+The MIT License (MIT)
+
+Copyright (c) 2024 Amaan Qureshi <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.25.0 - github.com/tree-sitter/tree-sitter-go
+
+The MIT License (MIT)
+
+Copyright (c) 2014 Max Brunsfeld
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.23.5 - github.com/tree-sitter/tree-sitter-java
+
+MIT License
+
+Copyright (c) 2017 Ayman Nadeem
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.25.0 - github.com/tree-sitter/tree-sitter-javascript
+
+The MIT License (MIT)
+
+Copyright (c) 2014 Max Brunsfeld
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.25.0 - github.com/tree-sitter/tree-sitter-python
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Max Brunsfeld
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.24.2 - github.com/tree-sitter/tree-sitter-rust
+
+The MIT License (MIT)
+
+Copyright (c) 2017 Maxim Sokolov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.23.2 - github.com/tree-sitter/tree-sitter-typescript
+
+The MIT License (MIT)
+
+Copyright (c) 2017 Max Brunsfeld
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v4.0.0-rc.2 - go.yaml.in/yaml/v4
+
+
+This project is covered by two different licenses: MIT and Apache.
+
+#### MIT License ####
+
+The following files were ported to Go from C files of libyaml, and thus
+are still covered by their original MIT license, with the additional
+copyright staring in 2011 when the project was ported over:
+
+ apic.go emitterc.go parserc.go readerc.go scannerc.go
+ writerc.go yamlh.go yamlprivateh.go
+
+Copyright (c) 2006-2010 Kirill Simonov
+Copyright (c) 2006-2011 Kirill Simonov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+### Apache License ###
+
+All the remaining project files are covered by the Apache license:
+
+Copyright (c) 2011-2019 Canonical Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+NOTICE v4.0.0-rc.2 - go.yaml.in/yaml/v4
+
+Copyright 2011-2016 Canonical Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE v0.16.0 - golang.org/x/sync
+
+Copyright 2009 The Go Authors.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google LLC nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/tools/graft-agents/protocol/enums_test.go b/tools/graft-agents/protocol/enums_test.go
new file mode 100644
index 0000000..03d2009
--- /dev/null
+++ b/tools/graft-agents/protocol/enums_test.go
@@ -0,0 +1,51 @@
+package protocol
+
+import (
+ "encoding/json"
+ "os"
+ "reflect"
+ "testing"
+)
+
+// TestEnumValuesMatchTheServerCopy pins the values of the enumerations of protocol v1 to the
+// server's golden file (internal/graft/resolver/testdata/protocol-enums.json), which the server's
+// copy is tested against too: a value that changes on one side only would make the two programs
+// misread each other.
+func TestEnumValuesMatchTheServerCopy(t *testing.T) {
+ data, err := os.ReadFile("../../../internal/graft/resolver/testdata/protocol-enums.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var golden map[string]any
+ if err := json.Unmarshal(data, &golden); err != nil {
+ t.Fatal(err)
+ }
+ if v, _ := golden["version"].(float64); int(v) != Version {
+ t.Fatalf("version = %v, golden %v", Version, golden["version"])
+ }
+ got := map[string][]string{
+ "kind": {KindContent, KindModifyDelete, KindAddAdd, KindMode},
+ "action": {ActionWrite, ActionDelete},
+ "mode": {ModeFile, ModeExecutable, ModeSymlink},
+ "operation": {OperationResolve, OperationCheck},
+ "syntax": {SyntaxChecked, SyntaxUnchecked, SyntaxNone},
+ "origin": {OriginRule, OriginModel},
+ "outcome": {OutcomeResolved, OutcomeRejected, OutcomeFailed},
+ }
+ for name, want := range got {
+ raw, ok := golden[name].([]any)
+ if !ok {
+ t.Fatalf("golden file lacks %q", name)
+ }
+ var values []string
+ for _, v := range raw {
+ values = append(values, v.(string))
+ }
+ if !reflect.DeepEqual(values, want) {
+ t.Errorf("%s = %v, golden %v", name, want, values)
+ }
+ }
+ if len(golden) != len(got)+2 {
+ t.Errorf("the golden file holds %d entries, want a comment, the version and %d enumerations", len(golden), len(got))
+ }
+}
diff --git a/tools/graft-agents/resolve/bench/judge.go b/tools/graft-agents/resolve/bench/judge.go
index a3d5077..8829aa3 100644
--- a/tools/graft-agents/resolve/bench/judge.go
+++ b/tools/graft-agents/resolve/bench/judge.go
@@ -13,8 +13,6 @@ import (
// and trailing blank lines dropped: the equivalence by which a result is judged correct.
func normalize(content []byte) []byte { return resolve.LLMNormalize(content) }
-// judge reports whether a result equals the human resolution after normalization, and whether it
-// is byte-identical. A nil content is a deletion.
// blankLinesOnly reports whether two contents differ only in blank lines once normalized:
// a wrong result that is the human resolution with blank lines added or removed. It is reported
// beside the wrong count, which it stays part of; indentation and every other character count.
@@ -31,6 +29,8 @@ func blankLinesOnly(result, human []byte) bool {
return strip(result) == strip(human)
}
+// judge reports whether a result equals the human resolution after normalization, and whether it
+// is byte-identical. A deletion (resultDeleted, humanDeleted) is correct when both are.
func judge(result, human []byte, resultDeleted, humanDeleted bool) (correct, exact bool) {
if resultDeleted || humanDeleted {
return resultDeleted == humanDeleted, resultDeleted == humanDeleted
diff --git a/tools/graft-agents/resolve/bench/report.go b/tools/graft-agents/resolve/bench/report.go
index 083fdb5..7c2d899 100644
--- a/tools/graft-agents/resolve/bench/report.go
+++ b/tools/graft-agents/resolve/bench/report.go
@@ -22,7 +22,7 @@ type Counts struct {
NotRun int `json:"not_run_cap"`
Stopped int `json:"not_run_stopped"`
Abstained int `json:"abstained"`
- // Calls and Repairs are the model calls and the repair rounds among them (PLAN10 15.11).
+ // Calls and Repairs are the model calls and the repair rounds among them (PLAN10 15.10).
Calls int `json:"calls"`
Repairs int `json:"repairs"`
// BlankLinesOnly counts the wrong results that differ from the human resolution in blank
diff --git a/tools/graft-agents/resolve/budget_strategy.go b/tools/graft-agents/resolve/budget_strategy.go
index e97a538..4b8e96c 100644
--- a/tools/graft-agents/resolve/budget_strategy.go
+++ b/tools/graft-agents/resolve/budget_strategy.go
@@ -20,6 +20,9 @@ import (
// The table needs max_tokens in [strategy.llm], which bounds the worst case of a call. When the
// month's spend plus the worst case of a call would exceed the cap, the call is not made and the
// file fails with "AI budget exhausted", which the server puts into the conflict package.
+//
+// With an agree_with model the cap must cover both: the same table goes into
+// [strategy.llm.agree_with.budget], with the second model's prices and its own state file.
// llmBudgetConfig decodes the optional budget table of the [strategy.llm] table.
func llmBudgetConfig(spec StrategySpec, tbl map[string]any) (*Budget, error) {
diff --git a/tools/graft-agents/resolve/llm_agree_test.go b/tools/graft-agents/resolve/llm_agree_test.go
index a32be0a..d2e119b 100644
--- a/tools/graft-agents/resolve/llm_agree_test.go
+++ b/tools/graft-agents/resolve/llm_agree_test.go
@@ -102,13 +102,13 @@ func TestAgreeWithDisagreementHoldsTheFirstModelsProposal(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !strings.Contains(got.Hold, "model-b") || !strings.Contains(got.Hold, "differently") {
+ if !strings.HasPrefix(got.Hold, "held: the second model (model-b) disagreed") || !strings.Contains(got.Hold, "differently") {
t.Fatalf("hold = %q", got.Hold)
}
if string(got.Content) != "merged\n" || got.Origin != protocol.OriginModel || !got.Proposal {
t.Fatalf("the first model's proposal is not what is held: %+v", got)
}
- if last := got.Report[len(got.Report)-1]; !strings.Contains(last, "the second model disagreed") {
+ if last := got.Report[len(got.Report)-1]; last != got.Hold {
t.Fatalf("report = %v", got.Report)
}
if b.calls() != 1 {
@@ -123,7 +123,7 @@ func TestAgreeWithASecondModelThatFailsHolds(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !strings.Contains(got.Hold, "gave no usable answer") || !strings.Contains(got.Hold, "provider down") {
+ if !strings.HasPrefix(got.Hold, "held: ") || !strings.Contains(got.Hold, "gave no usable answer") || !strings.Contains(got.Hold, "provider down") {
t.Fatalf("hold = %q", got.Hold)
}
if string(got.Content) != "merged\n" {
@@ -165,7 +165,7 @@ func TestAgreeWithAnUncleanReportHoldsEvenWhenTheModelsAgree(t *testing.T) {
"first duplicates": {repeats, clean},
"both drop": {dirty, dirty},
} {
- if why := s.agreement(c.first, run(c.second)); why == "" || !strings.Contains(why, "finding") {
+ if why := s.agreement(c.first, run(c.second)); !strings.HasPrefix(why, "held: a composition report was not clean") {
t.Fatalf("%s: not held: %q", name, why)
}
}
diff --git a/tools/graft-agents/resolve/llm_compose.go b/tools/graft-agents/resolve/llm_compose.go
index 4833324..5b20346 100644
--- a/tools/graft-agents/resolve/llm_compose.go
+++ b/tools/graft-agents/resolve/llm_compose.go
@@ -10,7 +10,7 @@ import (
// base, and the answer for a region should keep what each side changed unless the other side
// changed the same base lines. The definition is the one frozen on 2026-10-19 before it was measured
// (compose2.py of the measurement, sha256 9396326b...); this file is its port to the regions of the
-// llm strategy, and is checked against it (llm_compose_test.go):
+// llm strategy, and is checked against it (bench/compose_parity_test.go):
//
// - A region's answer is a slot of lines. Each side's change is the list of hunks of the line diff
// base -> side inside the region: a base range [a, b) replaced by the side's lines (an insertion
@@ -29,13 +29,12 @@ import (
//
// Lines are compared after the judge's normalization (CRLF, trailing whitespace) and stripped. It is
// a report, never a gate: the measurement showed that the check does not move precision (15.6). What
-// it does is name, in exact words, what the answer dropped or repeated, which a repair round (15.10)
-// can quote back to the model, and which goes to the agent with the proposal.
+// it does is name, in exact words, what the answer dropped or repeated, which goes to the agent with the proposal. A repair round
+// (15.10) is driven by the rules of an answer and its syntax only, never by this report.
// llmComposition is the check of one region's answer.
type llmComposition struct {
- // problems are the drops and the duplicates, in the exact words that the report and a repair round
- // use.
+ // problems are the drops and the duplicates, in the exact words of the report.
problems []string
// kept is the number of uncontested hunks the slot keeps, contested the number of contested ones.
kept, contested int
diff --git a/tools/graft-agents/resolve/llm_core.go b/tools/graft-agents/resolve/llm_core.go
index 53f4d74..e59f99a 100644
--- a/tools/graft-agents/resolve/llm_core.go
+++ b/tools/graft-agents/resolve/llm_core.go
@@ -422,6 +422,7 @@ func llmClip(s string, n int) string {
return s[:cut]
}
+// llmComplete makes one model call and wraps its failure as the strategy's.
func llmComplete(ctx context.Context, p llm.Provider, req llm.Request) (*llm.Response, error) {
resp, err := p.Complete(ctx, req)
if err != nil {
@@ -695,21 +696,3 @@ func llmApply(base []string, start, end int, hs []llmHunk, side int) string {
sb.WriteString(strings.Join(base[pos:end], ""))
return sb.String()
}
-
-// llmAssemble builds the resolved file from base and its regions.
-func llmAssemble(base []string, regions []llmRegion) string {
- var sb strings.Builder
- pos := 0
- for i := range regions {
- r := &regions[i]
- sb.WriteString(strings.Join(base[pos:r.start], ""))
- if r.clean {
- sb.WriteString(r.merged)
- } else {
- sb.WriteString(r.answer)
- }
- pos = r.end
- }
- sb.WriteString(strings.Join(base[pos:], ""))
- return sb.String()
-}
diff --git a/tools/graft-agents/resolve/llm_core_test.go b/tools/graft-agents/resolve/llm_core_test.go
index 07ba8aa..abec624 100644
--- a/tools/graft-agents/resolve/llm_core_test.go
+++ b/tools/graft-agents/resolve/llm_core_test.go
@@ -281,7 +281,7 @@ func TestLLMRegionsCleanWhenSidesAgree(t *testing.T) {
if len(regions) != 1 || !regions[0].clean {
t.Fatalf("regions = %+v, want one clean region", regions)
}
- if got := llmAssemble(base, regions); got != "a\nX\nc\n" {
+ if got := llmJoin(regions); got != "X\n" {
t.Fatalf("assembled = %q", got)
}
}
diff --git a/tools/graft-agents/resolve/llm_design_resolver_test.go b/tools/graft-agents/resolve/llm_design_resolver_test.go
new file mode 100644
index 0000000..32727cf
--- /dev/null
+++ b/tools/graft-agents/resolve/llm_design_resolver_test.go
@@ -0,0 +1,79 @@
+//go:build cgo
+
+package resolve
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "strings"
+ "testing"
+
+ "github.com/feder-cr/git-ai/tools/graft-agents/llm"
+ "github.com/feder-cr/git-ai/tools/graft-agents/protocol"
+)
+
+// The test of the design step that goes through the llm strategy (the resolver builds it, and the
+// strategy needs the tree-sitter grammars: cgo); the rest of the design tests build without cgo.
+
+// TestLLMDesignAtTheResolver: a model answer that breaks the rules of an answer is an attempt of the
+// rejected kind, the composition report goes with the resolution, and the options of the ablations are gone.
+func TestLLMDesignAtTheResolver(t *testing.T) {
+ file := protocol.FileConflict{
+ Path: "x.txt", Kind: protocol.KindContent,
+ Base: wp19Side(protocol.ModeFile, numbered("line", 12)),
+ Ours: wp19Side(protocol.ModeFile, strings.Replace(numbered("line", 12), "line 5\n", "O5\n", 1)),
+ Theirs: wp19Side(protocol.ModeFile, strings.Replace(numbered("line", 12), "line 6\n", "T6\n", 1)),
+ }
+ wp19SetAnswer(func(_ context.Context, req llm.Request) (*llm.Response, error) {
+ return llmRawAnswer("I will not."), nil
+ })
+ r := wp19Build(t, wp19LLMConfig)
+ _, err := r.Resolve(context.Background(), wp19Request(file))
+ var unresolved *UnresolvedError
+ if !errors.As(err, &unresolved) || len(unresolved.Failures) != 1 {
+ t.Fatalf("err = %v", err)
+ }
+ attempts := unresolved.Failures[0].Attempts
+ if len(attempts) != 1 || attempts[0].Kind != AttemptRejected || !errors.Is(attempts[0].Err, ErrLLMRejected) {
+ t.Fatalf("attempts %+v, want one rejection", attempts)
+ }
+
+ // The report goes with the resolution, and a model's resolution is marked as one.
+ wp19SetAnswer(func(_ context.Context, req llm.Request) (*llm.Response, error) {
+ return wp19Answer("O5\nT6\n"), nil
+ })
+ r = wp19Build(t, wp19LLMConfig)
+ resp, err := r.Resolve(context.Background(), wp19Request(file))
+ if err != nil {
+ t.Fatal(err)
+ }
+ got := resp.Files[0]
+ if got.Origin != protocol.OriginModel || !got.Proposal || fmt.Sprint(got.Report) != "[keeps every uncontested change of both sides (2)]" {
+ t.Fatalf("file %+v", got)
+ }
+
+ // The elements that the measurements rejected, or made the rule, are no options any more.
+ for _, gone := range []string{"symmetric_context", "abstain", "repair", "repair_composition", "git_regions", "max_context_bytes"} {
+ value := "false"
+ if gone == "max_context_bytes" {
+ value = "4096"
+ }
+ if _, err := wp19BuildErr(strings.Replace(wp19LLMConfig, `paths = ["*.txt", "**/*.txt"]`, "paths = [\"*.txt\"]\n"+gone+" = "+value, 1)); err == nil {
+ t.Errorf("the option %s is still accepted", gone)
+ }
+ }
+}
+
+// wp19BuildStrategy builds the resolver of config and returns its llm strategy.
+func wp19BuildStrategy(t *testing.T, config string) *llmStrategy {
+ t.Helper()
+ r := wp19Build(t, config)
+ for _, b := range r.bindings {
+ if s, ok := b.Strategy.(*llmStrategy); ok {
+ return s
+ }
+ }
+ t.Fatal("no llm strategy in the resolver")
+ return nil
+}
diff --git a/tools/graft-agents/resolve/llm_design_syntax_test.go b/tools/graft-agents/resolve/llm_design_syntax_test.go
index d2fef07..78dc1b8 100644
--- a/tools/graft-agents/resolve/llm_design_syntax_test.go
+++ b/tools/graft-agents/resolve/llm_design_syntax_test.go
@@ -54,4 +54,38 @@ func TestLLMDesignRepairOnTheSyntaxOfTheFile(t *testing.T) {
if err != nil || len(still.reqs) != 2 || !strings.Contains(string(res.Content), "return 2 +\n") {
t.Fatalf("err %v, requests %d, content %q", err, len(still.reqs), res.Content)
}
+ // The repair call was paid for, and counted as one; the region was not answered again, and the
+ // report does not say it was.
+ if res.Repairs != 1 || res.Calls != 2 {
+ t.Fatalf("repairs %d, calls %d", res.Repairs, res.Calls)
+ }
+ if strings.Contains(strings.Join(res.Report, "\n"), "answered again") {
+ t.Fatalf("a repair that was reverted is reported as an answer given again: %v", res.Report)
+ }
+}
+
+// TestLLMDesignSyntaxRepairMayDeleteTheRegion: an empty replacement is a valid answer of a repair round,
+// as it is of the first one: a region whose lines cannot be fixed may be deleted, and the file that parses
+// without them is the result.
+func TestLLMDesignSyntaxRepairMayDeleteTheRegion(t *testing.T) {
+ f := LLMFile{Path: "a.go",
+ Base: []byte("package a\n\nfunc f() {\n\tprintln(1)\n}\n"),
+ Ours: []byte("package a\n\nfunc f() {\n\tprintln(2)\n}\n"),
+ Theirs: []byte("package a\n\nfunc f() {\n\tprintln(3)\n}\n")}
+ p := &llmFake{answer: func(i int, _ llm.Request) (*llm.Response, error) {
+ if i == 0 {
+ return llmFakeAnswer("\tprintln(\n"), nil
+ }
+ return llmFakeAnswer(""), nil
+ }}
+ res, err := ResolveLLM(context.Background(), p, f, LLMOptions{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(p.reqs) != 2 || string(res.Content) != "package a\n\nfunc f() {\n}\n" {
+ t.Fatalf("requests %d, content %q", len(p.reqs), res.Content)
+ }
+ if !strings.Contains(strings.Join(res.Report, "\n"), "1 of 1 regions were answered again") {
+ t.Fatalf("report %v", res.Report)
+ }
}
diff --git a/tools/graft-agents/resolve/llm_design_test.go b/tools/graft-agents/resolve/llm_design_test.go
index d29edd3..cd83781 100644
--- a/tools/graft-agents/resolve/llm_design_test.go
+++ b/tools/graft-agents/resolve/llm_design_test.go
@@ -8,10 +8,9 @@ import (
"testing"
"github.com/feder-cr/git-ai/tools/graft-agents/llm"
- "github.com/feder-cr/git-ai/tools/graft-agents/protocol"
)
-// Tests of the design step (PLAN10 15.10): the symmetric context, the way out, the one repair round
+// Tests of the design step (PLAN10 15.10): the request, the one repair round
// and the composition report. The provider is always a fake.
// designFile is a file with one conflicting region at line 5 (ours and theirs change it).
@@ -38,7 +37,7 @@ func rawPatched(nonce, code string) *llm.Response {
// TestLLMRequestHoldsWhatTheMeasurementsKept: the request of a region is THEIRS' message, the PATCH and
// the CODE with the other regions for reference, and nothing of the elements that the measurements of
-// PLAN10 15.11 rejected (OURS' change and message, the way out of an abstain block). A model that writes an
+// PLAN10 15.10 removed (OURS' change and message, the way out of an abstain block). A model that writes an
// abstain block has given no answer.
func TestLLMRequestHoldsWhatTheMeasurementsKept(t *testing.T) {
f := designFile()
@@ -142,7 +141,7 @@ func compositionFile() LLMFile {
}
// TestLLMDesignCompositionReportsAndNeverRepairs: an answer that the rules and the syntax accept is never
-// asked for again, whatever the composition check finds in it (PLAN10 15.11: the repair of an accepted
+// asked for again, whatever the composition check finds in it (PLAN10 15.10: the repair of an accepted
// answer made it worse in the paired data): the drop is reported in the check's words and the answer stays.
// A broken answer is still repaired once, and the report says how many regions were.
func TestLLMDesignCompositionReportsAndNeverRepairs(t *testing.T) {
@@ -243,65 +242,3 @@ func TestLLMReportWording(t *testing.T) {
t.Fatalf("a long report is cut: %d lines, last %q", len(got), got[len(got)-1])
}
}
-
-// TestLLMDesignAtTheResolver: a model answer that breaks the rules of an answer is an attempt of the
-// rejected kind, the composition report goes with the resolution, and the options of the ablations are gone.
-func TestLLMDesignAtTheResolver(t *testing.T) {
- file := protocol.FileConflict{
- Path: "x.txt", Kind: protocol.KindContent,
- Base: wp19Side(protocol.ModeFile, numbered("line", 12)),
- Ours: wp19Side(protocol.ModeFile, strings.Replace(numbered("line", 12), "line 5\n", "O5\n", 1)),
- Theirs: wp19Side(protocol.ModeFile, strings.Replace(numbered("line", 12), "line 6\n", "T6\n", 1)),
- }
- wp19SetAnswer(func(_ context.Context, req llm.Request) (*llm.Response, error) {
- return llmRawAnswer("I will not."), nil
- })
- r := wp19Build(t, wp19LLMConfig)
- _, err := r.Resolve(context.Background(), wp19Request(file))
- var unresolved *UnresolvedError
- if !errors.As(err, &unresolved) || len(unresolved.Failures) != 1 {
- t.Fatalf("err = %v", err)
- }
- attempts := unresolved.Failures[0].Attempts
- if len(attempts) != 1 || attempts[0].Kind != AttemptRejected || !errors.Is(attempts[0].Err, ErrLLMRejected) {
- t.Fatalf("attempts %+v, want one rejection", attempts)
- }
-
- // The report goes with the resolution, and a model's resolution is marked as one.
- wp19SetAnswer(func(_ context.Context, req llm.Request) (*llm.Response, error) {
- return wp19Answer("O5\nT6\n"), nil
- })
- r = wp19Build(t, wp19LLMConfig)
- resp, err := r.Resolve(context.Background(), wp19Request(file))
- if err != nil {
- t.Fatal(err)
- }
- got := resp.Files[0]
- if got.Origin != protocol.OriginModel || !got.Proposal || fmt.Sprint(got.Report) != "[keeps every uncontested change of both sides (2)]" {
- t.Fatalf("file %+v", got)
- }
-
- // The elements that the measurements rejected, or made the rule, are no options any more.
- for _, gone := range []string{"symmetric_context", "abstain", "repair", "repair_composition", "git_regions", "max_context_bytes"} {
- value := "false"
- if gone == "max_context_bytes" {
- value = "4096"
- }
- if _, err := wp19BuildErr(strings.Replace(wp19LLMConfig, `paths = ["*.txt", "**/*.txt"]`, "paths = [\"*.txt\"]\n"+gone+" = "+value, 1)); err == nil {
- t.Errorf("the option %s is still accepted", gone)
- }
- }
-}
-
-// wp19BuildStrategy builds the resolver of config and returns its llm strategy.
-func wp19BuildStrategy(t *testing.T, config string) *llmStrategy {
- t.Helper()
- r := wp19Build(t, config)
- for _, b := range r.bindings {
- if s, ok := b.Strategy.(*llmStrategy); ok {
- return s
- }
- }
- t.Fatal("no llm strategy in the resolver")
- return nil
-}
diff --git a/tools/graft-agents/resolve/llm_patch.go b/tools/graft-agents/resolve/llm_patch.go
index 1771b17..8470873 100644
--- a/tools/graft-agents/resolve/llm_patch.go
+++ b/tools/graft-agents/resolve/llm_patch.go
@@ -468,7 +468,7 @@ func llmReport(comps []llmComposition, repairs int) []string {
// before any call. The file is resolved only when every region is: the first rejected region
// rejects the file, and no partial resolution is returned.
//
-// A region is repaired at most once (PLAN10 15.11), by ONE repair round, and only an answer that is
+// A region is repaired at most once (PLAN10 15.10), by ONE repair round, and only an answer that is
// BROKEN: a rule of an answer that it breaks (the anchors, the newline, a patch, markers, size, no
// block), or the syntax error of the assembled file mapped to the region it is in. The finding is
// quoted back exactly, and the round is made only if the repair request fits max_prompt_bytes. An
@@ -591,6 +591,10 @@ func llmResolvePatch(ctx context.Context, p llm.Provider, f LLMFile, opt LLMOpti
}
comps := make([]llmComposition, len(conflicting))
+ // answeredAgain counts the regions whose answer is the one a repair round gave: the report says
+ // how many. A repair call that was made and did not change the file (the syntax round whose answer
+ // was refused or did not parse) is a call that was paid for (repairs), not a region answered again.
+ answeredAgain := 0
for k, i := range conflicting {
r := &regions[i]
resp, err := ask(requests[k].system, requests[k].user)
@@ -620,6 +624,7 @@ func llmResolvePatch(ctx context.Context, p llm.Provider, f LLMFile, opt LLMOpti
return LLMResult{}, rejected(k, err2, resp.Text, resp2.Text)
}
region = region2
+ answeredAgain++
}
r.answer = region
comps[k] = llmCompose(r, r.start, region)
@@ -635,17 +640,19 @@ func llmResolvePatch(ctx context.Context, p llm.Provider, f LLMFile, opt LLMOpti
if i, ok := llmRegionAtLine(spans, se.Line); ok {
k := slices.Index(conflicting, i)
if k >= 0 && !repaired[k] {
- _, _, region2, err2 := repair(k, material[k].head+regions[i].answer+material[k].tail, []string{se.Error()})
+ fitted, _, region2, err2 := repair(k, material[k].head+regions[i].answer+material[k].tail, []string{se.Error()})
if ctxErr := ctx.Err(); ctxErr != nil {
return LLMResult{}, ctxErr
}
- if err2 == nil && region2 != "" {
+ // An empty replacement is a valid answer (the region is deleted), as it is in the first round.
+ if fitted && err2 == nil {
old := regions[i].answer
regions[i].answer = region2
trial, _ := llmJoinSpans(regions)
if _, err := syntax.CheckMerge(ctx, f.Path, []byte(trial), f.Ours, f.Theirs); err == nil {
assembled = trial
comps[k] = llmCompose(&regions[i], regions[i].start, region2)
+ answeredAgain++
} else {
regions[i].answer = old
}
@@ -660,7 +667,7 @@ func llmResolvePatch(ctx context.Context, p llm.Provider, f LLMFile, opt LLMOpti
equalOurs++
}
}
- report := llmReport(comps, repairs)
+ report := llmReport(comps, answeredAgain)
if stats != nil {
stats.RecordReport(report)
}
diff --git a/tools/graft-agents/resolve/llm_r1b_golden_test.go b/tools/graft-agents/resolve/llm_r1b_golden_test.go
index 37a412f..8d5ad8c 100644
--- a/tools/graft-agents/resolve/llm_r1b_golden_test.go
+++ b/tools/graft-agents/resolve/llm_r1b_golden_test.go
@@ -10,10 +10,10 @@ import (
"testing"
)
-// The guarantee that the step of the design (PLAN10 15.10) rests on: with its three elements switched off
-// the requests are those of R1b, byte for byte. The golden files in testdata/r1b were written by the code of
-// R1b (the tree before the design step, GRAFT_WRITE_R1B_GOLDEN=1), for the files below, and this test
-// compares what the strategy sends now with them. The nonce of a request is replaced by NONCE.
+// The guarantee that the step of the design (PLAN10 15.10) rests on: the first request of a region is that of
+// R1b, byte for byte (the options that could change it are gone). The golden files in testdata/r1b were
+// written by the code of R1b (the tree before the design step, GRAFT_WRITE_R1B_GOLDEN=1), for the files
+// below, and this test compares what the strategy sends now with them. The nonce of a request is replaced by NONCE.
//
// The files are chosen so that git's merge and our own line diff agree on their regions: the regions
// are another matter (llmFileRegions), the request of a region is what is pinned here.
diff --git a/tools/graft-agents/resolve/llm_strategy.go b/tools/graft-agents/resolve/llm_strategy.go
index a75c1fd..bae360f 100644
--- a/tools/graft-agents/resolve/llm_strategy.go
+++ b/tools/graft-agents/resolve/llm_strategy.go
@@ -7,7 +7,6 @@ import (
"fmt"
"sort"
"time"
- "unicode/utf8"
"github.com/feder-cr/git-ai/tools/graft-agents/llm"
"github.com/feder-cr/git-ai/tools/graft-agents/protocol"
@@ -247,7 +246,7 @@ func (s *llmStrategy) Resolve(ctx context.Context, f File, req protocol.Request)
if second != nil {
if why := s.agreement(res, second); why != "" {
out.Hold = why
- out.Report = append(append([]string(nil), res.Report...), "the second model disagreed, so the resolution is held as a proposal: "+why)
+ out.Report = append(append([]string(nil), res.Report...), why)
}
}
return out, true, nil
@@ -292,30 +291,19 @@ func (r *agreeRun) wait() { <-r.done }
func (s *llmStrategy) agreement(first LLMResult, second *agreeRun) string {
switch {
case second.err != nil && errors.Is(second.err, ErrLLMNotApplicable):
- return fmt.Sprintf("the second model (%s) could not take the file", s.agree.model)
+ return fmt.Sprintf("held: the second model (%s) could not take the file", s.agree.model)
case second.err != nil:
- return fmt.Sprintf("the second model (%s) gave no usable answer: %s", s.agree.model, llmCutText(second.err.Error(), 200))
+ return fmt.Sprintf("held: the second model (%s) gave no usable answer: %s", s.agree.model, llmClip(second.err.Error(), 200))
case !LLMReportClean(first.Report):
- return fmt.Sprintf("the composition report of the first model (%s) holds a finding", s.model)
+ return fmt.Sprintf("held: a composition report was not clean: the first model (%s) drops or repeats a change", s.model)
case !LLMReportClean(second.res.Report):
- return fmt.Sprintf("the composition report of the second model (%s) holds a finding", s.agree.model)
+ return fmt.Sprintf("held: a composition report was not clean: the second model (%s) drops or repeats a change", s.agree.model)
case !bytes.Equal(LLMNormalize(first.Content), LLMNormalize(second.res.Content)):
- return fmt.Sprintf("the second model (%s) resolved the file differently from the first (%s)", s.agree.model, s.model)
+ return fmt.Sprintf("held: the second model (%s) disagreed: it resolved the file differently from the first (%s)", s.agree.model, s.model)
}
return ""
}
-// llmCutText cuts s to n bytes at a rune boundary.
-func llmCutText(s string, n int) string {
- if len(s) <= n {
- return s
- }
- for n > 0 && !utf8.RuneStart(s[n]) {
- n--
- }
- return s[:n] + "..."
-}
-
// syntaxChecked marks the llm answers for the syntax check (resolveFile).
func (s *llmStrategy) syntaxChecked() {}