From af74b35a385adf8c179bcb3ff8a2a7ceaa4f6500 Mon Sep 17 00:00:00 2001 From: VotingPlugin Control Automation Date: Thu, 19 Nov 2026 01:15:34 +0000 Subject: [PATCH] Add typed scalar Reward edits over MCP --- README.md | 2 +- docs/agent-setup.md | 11 ++++ docs/mcp-network-coverage.md | 4 +- .../control/domain/AgentOperations.java | 22 ++++++- .../control/domain/AgentSetup.java | 33 +++++++++++ .../domain/ConfigurationOperations.java | 54 +++++++++++++++++- .../control/http/ControlHttpServer.java | 3 + .../control/mcp/StdioAdapter.java | 17 +++++- src/main/resources/web/index.html | 1 + .../control/domain/AgentOperationsTest.java | 57 +++++++++++++++++++ .../control/http/AgentMcpHttpTest.java | 2 +- 11 files changed, 198 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 59bb135..0c3a90c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ VotingPlugin Control is designed to manage and troubleshoot a VotingPlugin netwo - Run guided setup for standalone and proxy/backend networks. - Configure common settings through searchable presets. -- Let Codex CLI or Claude Code read and preview a named backend vote site or automatic site-creation policy for up to ten explicit backends through opt-in local MCP, then review and apply it in Control. Separately grant agents scoped topology, Network Doctor checks, proxy routing previews, non-vote transport checks, and typed General Settings and Vote Sites editor previews. See [agent setup](docs/agent-setup.md). +- Let Codex CLI or Claude Code read and preview a named backend vote site or automatic site-creation policy for up to ten explicit backends through opt-in local MCP, then review and apply it in Control. Separately grant agents scoped topology, Network Doctor checks, proxy routing previews, non-vote transport checks, and typed General Settings, Vote Sites, and Rewards editor previews. See [agent setup](docs/agent-setup.md). - Set up or synchronize Vote Sites while preserving existing rewards and sensitive values. - Configure automatic Vote Site creation. - Configure VoteLogging and retention. diff --git a/docs/agent-setup.md b/docs/agent-setup.md index e1f1ed0..495cb7c 100644 --- a/docs/agent-setup.md +++ b/docs/agent-setup.md @@ -118,3 +118,14 @@ more changed fields. Remove takes no fields. A site with inline Rewards or unrev The proposal preserves unrelated sites and sections. Control checks the current redacted source and complete changed paths against the reviewed proposal before making browser approval available. MCP returns typed fields and a Rewards presence indicator, and omits raw documents and approval material. + + +## Optional typed Rewards editor + +Grant **Read and preview typed Reward fields** and **Track operations** to use `read_reward_field` +and `preview_reward_field` on one Bukkit backend. Select an exact `siteKey` for an inline reward with +`config.files.v1`, or an exact `rewardName` for an enrolled named reward file with `config.reward-files.v1`. +Select an existing money, chance, player or broadcast message, or named item material or amount field. +Preview uses that read operation ID and one replacement scalar. Control checks the source, revision and exact +changed path before browser approval. Command payloads, reward creation or removal, raw files, and execution +are outside this tool surface. diff --git a/docs/mcp-network-coverage.md b/docs/mcp-network-coverage.md index 1c7cc89..a8f8524 100644 --- a/docs/mcp-network-coverage.md +++ b/docs/mcp-network-coverage.md @@ -6,7 +6,7 @@ A proxy-network grant limits where an agent may use MCP. The negotiated node cap | --- | --- | --- | | Enrolled identity, liveness, accepted capabilities, proxy/backend presence and topology | Bounded discovery and topology, with proxy snapshot freshness and truncation indicators | Extend large-network link pagination | | Network Doctor, overview, diagnostics, vote-site health, vote-log summary/search/trace, exact player lookup, site resolution, reward simulation | Network Doctor status and read-only observation refresh with a separate health action | Further diagnostic projections. Player and log data need separate projections and access decisions | -| Bukkit managed YAML, split VoteSites, named reward files, supported file comments, General Settings, typed Vote Sites and Rewards | Typed backend and proxy General Settings, plus a named-site guided preview and typed Vote Sites editor | Add typed editor tools using their existing validators, per-target revisions, and bounded results | +| Bukkit managed YAML, split VoteSites, named reward files, supported file comments, General Settings, typed Vote Sites and Rewards | Typed backend and proxy General Settings, plus a named-site guided preview and typed Vote Sites and scalar Rewards editors | Add typed editor tools using their existing validators, per-target revisions, and bounded results | | Quick setup v1/v2, standalone/proxy setup, common settings, auto-create, vote logging, Vote Party, rewards and VoteSites sync | Named vote-site and automatic site-creation policy presets | Add remaining preset-specific schemas and their exact capability and role checks | | Proxy routing, fixed proxy YAML, coordinated proxy-method v1/v2 and transport tests | One typed routing read and preview with browser approval, plus a separately granted non-vote transport check | Add fixed proxy YAML projections. Proxy-method changes need the complete reported target set and existing rollback and restart reporting | | Configuration review, apply, status, retries, durable operation history, snapshots and drift | Token-free, per-target status for operations from the same grant. Browser-only Apply. Automatic site policy supports 1–10 explicit backends with immutable revisions | Extend bounded multi-node review and partial-failure reporting to other safe typed operations | @@ -27,7 +27,7 @@ MCP uses an opt-in server boundary, proxy-network grants, bounded discovery and | Batch site policy | Implemented and tested | Explicit unique targets, separate batch permission, revision per backend, all previews successful before approval, per-target terminal results | | Typed General Settings | Implemented and tested | Both node roles use the curated editor, scoped reads, exact revision and diff, and browser approval. Proxy applies report restart required | | Typed Vote Sites editor | Implemented and tested | Exact-site read, typed add/edit, and removal for reviewable sites without inline Rewards. Revision, masked source and leaf changes checked before browser approval | -| Typed Rewards editor | Remaining | Reuse curated reward inventory and safe source-preserving edits without executing rewards | +| Typed Rewards editor | Implemented and tested for supported scalar fields | Inline and named-file reward reads, exact same-scope scalar previews and browser approval. Command payloads and whole-scope edits stay in administrator workflows | | Remaining guided presets, fixed proxy-file projections, proxy-method changes and VoteSites sync | Remaining | Scope and type each supported request, preserve existing version and role gates, prove rollback and restart outcomes where applicable | | Other multi-node proposals, typed retries and snapshot or drift projections | Remaining | Add bounded per-target reads, target-specific proposal data and clear validation/partial failure handling | | Player and vote-log inspections | Separately gated | Require distinct grants and purpose-specific redacted results before exposure | diff --git a/src/main/java/com/bencodez/votingplugin/control/domain/AgentOperations.java b/src/main/java/com/bencodez/votingplugin/control/domain/AgentOperations.java index 8153c12..1ea9261 100644 --- a/src/main/java/com/bencodez/votingplugin/control/domain/AgentOperations.java +++ b/src/main/java/com/bencodez/votingplugin/control/domain/AgentOperations.java @@ -20,7 +20,7 @@ import java.util.function.Supplier; public final class AgentOperations { - private static final Set ACTIONS = Set.of("discover", "read", "preview", "status", "health", "routing", "transport", "site-policy", "site-policy-batch", "general-settings", "vote-sites-editor"); + private static final Set ACTIONS = Set.of("discover", "read", "preview", "status", "health", "routing", "transport", "site-policy", "site-policy-batch", "general-settings", "vote-sites-editor", "rewards-editor"); private final Map grants = new HashMap<>(); private final Map healthRefreshes = new HashMap<>(); private final NodeRegistry registry; @@ -163,6 +163,24 @@ public synchronized Map refreshHealth(String token, RefreshHealt } } + public synchronized Object readReward(String token, RewardRead request) { + Grant grant = authorize(token, "rewards-editor"); + return withStableTopology(() -> { + requireNode(grant, request.nodeId()); + return project(operations.readAgentReward(grant.id(), request.nodeId(), + AgentSetup.RewardField.select(request.siteKey(), request.rewardName(), request.field()))); + }); + } + + public synchronized Object previewReward(String token, RewardPreview request) { + Grant grant = authorize(token, "rewards-editor"); + return withStableTopology(() -> { + requireNode(grant, request.nodeId()); + return project(operations.previewAgentReward(grant.id(), request.nodeId(), + parseId(request.readOperationId()), request.value())); + }); + } + public synchronized Object readVoteSitesEditor(String token, VoteSitesEditorRead request) { Grant grant = authorize(token, "vote-sites-editor"); return withStableTopology(() -> { @@ -466,6 +484,8 @@ public record Issue(List nodeIds, List actions, Integer minutes, public record Discovery(Integer offset) { } public record HealthRequest(List nodeIds) { } public record RefreshHealth(String nodeId) { } + public record RewardRead(String nodeId, String siteKey, String rewardName, String field) { } + public record RewardPreview(String nodeId, String readOperationId, Object value) { } public record VoteSitesEditorRead(String nodeId, String siteKey) { } public record VoteSitesEditorPreview(String nodeId, String siteKey, String readOperationId, String action, Map fields) { } diff --git a/src/main/java/com/bencodez/votingplugin/control/domain/AgentSetup.java b/src/main/java/com/bencodez/votingplugin/control/domain/AgentSetup.java index 5a59eed..f85e5a4 100644 --- a/src/main/java/com/bencodez/votingplugin/control/domain/AgentSetup.java +++ b/src/main/java/com/bencodez/votingplugin/control/domain/AgentSetup.java @@ -94,6 +94,39 @@ static Map editorSiteValues(String key, String document) { return Map.copyOf(values); } + record RewardField(String file, String scope, String field) { + static RewardField select(String siteKey, String rewardName, String field) { + if ((siteKey == null) == (rewardName == null) || field == null + || !field.matches("Money|Chance|Messages[.](Player|Broadcast)|Items[.][A-Za-z0-9_-]{1,64}[.](Material|Amount)")) { + throw new IllegalArgumentException("Select one reward and one supported scalar field"); + } + if (siteKey != null && siteKey.matches("[A-Za-z0-9_-]{1,64}")) { + return new RewardField("VoteSites.yml", "VoteSites." + siteKey + ".Rewards", field); + } + if (rewardName != null && rewardName.matches("[A-Za-z0-9][A-Za-z0-9_-]{0,99}")) { + return new RewardField("Rewards/" + rewardName + ".yml", "$", field); + } + throw new IllegalArgumentException("Invalid reward selector"); + } + + String changePath() { + return "$".equals(scope) ? field : scope + "." + field; + } + + Map values(String content) { + var selected = RewardsDocument.inventory(content, file).stream() + .filter(row -> scope.equals(row.path())).findFirst().orElseThrow(IllegalArgumentException::new); + if (!selected.editable() || !List.of("PRESENT", "EMPTY").contains(selected.status())) { + throw new IllegalArgumentException("Reward scope is missing or unsupported"); + } + Object value = selected.fields().get(field); + if (!(value instanceof String text) || text.length() > 500) { + throw new IllegalArgumentException("Reward field must already be a reviewable scalar"); + } + return Map.of("rewardField", field, "rewardValue", text); + } + } + static Map settingsValues(Map fields) { Map values = new LinkedHashMap<>(); fields.forEach((key, field) -> { diff --git a/src/main/java/com/bencodez/votingplugin/control/domain/ConfigurationOperations.java b/src/main/java/com/bencodez/votingplugin/control/domain/ConfigurationOperations.java index 3142339..b3a01ff 100644 --- a/src/main/java/com/bencodez/votingplugin/control/domain/ConfigurationOperations.java +++ b/src/main/java/com/bencodez/votingplugin/control/domain/ConfigurationOperations.java @@ -300,6 +300,26 @@ synchronized OperationView previewAgentVoteSitesEditor(UUID agent, String nodeId return createVoteSitesPreview(readId, nodeId, action, siteKey, fields, agent); } + synchronized OperationView readAgentReward(UUID agent, String nodeId, AgentSetup.RewardField field) { + prune(); + requireAgentCapacity(agent); + var selector = ManagedConfiguration.file(field.file(), null); + ValidatedTargets targets = validateTargets(List.of(nodeId), selector.capability()); + validateConfigurationTargets(targets, selector); + var read = create("READ", targets, selector, null, Map.of(), agent); + operations.get(read.operationId()).agentRewardField = field; + return read; + } + + synchronized OperationView previewAgentReward(UUID agent, String nodeId, UUID readId, Object value) { + prune(); + requireAgentCapacity(agent); + var field = agentOperation(agent, readId).agentRewardField; + if (field == null) throw invalid("A typed reward field read is required"); + return createRewardsPreview(readId, nodeId, field.file(), field.scope(), "SET_SCALAR", + field.field(), value, agent, field); + } + private void requireAgentCapacity(UUID agent) { var retained = operations.values().stream().filter(op -> agent.equals(op.agent)).toList(); if (retained.size() >= 48 || retained.stream().filter(op -> !op.complete()).count() >= 4) { @@ -629,6 +649,11 @@ public synchronized OperationView createRewardsPreview(UUID readId, String nodeI String rewardPath, String action, String field, Object value) { StoredOperation read = operations.get(readId); if (read != null && read.agent != null) throw invalid("Agent reads require the agent editor"); + return createRewardsPreview(readId, nodeId, fileName, rewardPath, action, field, value, null, null); + } + + private OperationView createRewardsPreview(UUID readId, String nodeId, String fileName, + String rewardPath, String action, String field, Object value, UUID agent, AgentSetup.RewardField agentField) { if (!"VoteSites.yml".equals(fileName) && !isNamedRewardFile(fileName)) throw invalid("This reward scope is advanced-only"); ConfigurationTaskResult snapshot = fileSnapshot(readId, nodeId, fileName); @@ -645,8 +670,27 @@ public synchronized OperationView createRewardsPreview(UUID readId, String nodeI validateConfigurationTargets(targets, configuration); byte[] token = new byte[32]; random.nextBytes(token); - return create("PREVIEW", targets, configuration, - Base64.getUrlEncoder().withoutPadding().encodeToString(token), Map.of(nodeId, snapshot.revision())); + String approval = Base64.getUrlEncoder().withoutPadding().encodeToString(token); + var revisions = Map.of(nodeId, snapshot.revision()); + if (agent == null) return create("PREVIEW", targets, configuration, approval, revisions); + String prior; + String next; + try { + prior = agentField.values(snapshot.configuration().content()).get("rewardValue"); + next = agentField.values(proposal).get("rewardValue"); + } catch (IllegalArgumentException unsupported) { + throw invalid("Reward field cannot be reviewed safely"); + } + if (prior.equals(next)) throw invalid("Reward field has no reviewable change"); + var preview = create("PREVIEW", targets, configuration, approval, revisions, agent); + var stored = operations.get(preview.operationId()); + String path = agentField.changePath(); + String label = fileName + " / " + path; + stored.agentBefore = Map.of(label, prior); + stored.agentAfter = Map.of(label, next); + stored.agentDocumentDigest = AgentSetup.documentDigest(snapshot.configuration().content()); + stored.agentExpectedChanges = Set.of("changed " + path); + return preview; } public record RewardsState(UUID readOperationId, String nodeId, String fileName, UUID sessionId, String revision, @@ -1169,6 +1213,11 @@ private OperationView completeCurrentSession(UUID operationId, String nodeId, Co } agentRead = AgentSetup.settingsValues(GeneralSettingsDocument.fields(result.configuration().content(), GeneralSettingsDocument.profileForFile(operation.configuration.fileName()))); + } else if (operation.agentRewardField != null) { + if (result.configuration() == null || result.configuration().content() == null) { + throw new IllegalArgumentException("Missing redacted reward source"); + } + agentRead = operation.agentRewardField.values(result.configuration().content()); } else if (operation.agentEditorSite != null) { if (result.configuration() == null || result.configuration().content() == null) { throw new IllegalArgumentException("Missing redacted VoteSites source"); @@ -1664,6 +1713,7 @@ private static final class StoredOperation { private UUID agent; private String agentSite; private String agentEditorSite; + private AgentSetup.RewardField agentRewardField; private boolean agentGeneralSettings; private String agentDocumentDigest; private Set agentExpectedChanges = Set.of(); diff --git a/src/main/java/com/bencodez/votingplugin/control/http/ControlHttpServer.java b/src/main/java/com/bencodez/votingplugin/control/http/ControlHttpServer.java index b5fc425..1564c98 100644 --- a/src/main/java/com/bencodez/votingplugin/control/http/ControlHttpServer.java +++ b/src/main/java/com/bencodez/votingplugin/control/http/ControlHttpServer.java @@ -1137,6 +1137,7 @@ private void routeAgent(HttpExchange exchange, String path) throws IOException { case "transport" -> "transport"; case "site-policy-read", "site-policy-preview" -> "site-policy"; case "site-policy-batch" -> "site-policy-batch"; + case "reward-read", "reward-preview" -> "rewards-editor"; case "vote-sites-editor-read", "vote-sites-editor-preview" -> "vote-sites-editor"; case "settings-read", "settings-preview" -> "general-settings"; case "read", "preview", "status" -> route; @@ -1155,6 +1156,8 @@ private void routeAgent(HttpExchange exchange, String path) throws IOException { case "topology" -> agentOperations.topology(token, read(exchange, AgentOperations.Discovery.class, true)); case "health" -> agentOperations.health(token, read(exchange, AgentOperations.HealthRequest.class, true)); case "health-refresh" -> agentOperations.refreshHealth(token, read(exchange, AgentOperations.RefreshHealth.class, true)); + case "reward-read" -> agentOperations.readReward(token, read(exchange, AgentOperations.RewardRead.class, true)); + case "reward-preview" -> agentOperations.previewReward(token, read(exchange, AgentOperations.RewardPreview.class, true)); case "vote-sites-editor-read" -> agentOperations.readVoteSitesEditor(token, read(exchange, AgentOperations.VoteSitesEditorRead.class, true)); case "vote-sites-editor-preview" -> agentOperations.previewVoteSitesEditor(token, diff --git a/src/main/java/com/bencodez/votingplugin/control/mcp/StdioAdapter.java b/src/main/java/com/bencodez/votingplugin/control/mcp/StdioAdapter.java index 5dae152..805b14e 100644 --- a/src/main/java/com/bencodez/votingplugin/control/mcp/StdioAdapter.java +++ b/src/main/java/com/bencodez/votingplugin/control/mcp/StdioAdapter.java @@ -261,7 +261,7 @@ private static boolean validValues(JsonNode result) { JsonNode values = result.path("values"); Set keys = new java.util.HashSet<>(GeneralSettingsDocument.editableKeys()); keys.addAll(VoteSitesDocument.editableKeys()); - keys.addAll(Set.of("siteKey", "rewardsConfigured")); + keys.addAll(Set.of("siteKey", "rewardsConfigured", "rewardField", "rewardValue")); keys.addAll(Set.of("name", "exists", "serviceSite", "voteUrl", "enabled", "displayName", "priority", "hidden", "voteDelay", "material", "displayItem.amount", "sendVotesToAllServers", "blockedServers")); if (!"READ".equals(result.path("type").asText()) || !fields(values, keys)) return false; @@ -335,6 +335,21 @@ private static Map tools() { tools.put("refresh_node_health", new Tool("refresh_node_health", "health-refresh", "Queue the read-only Network Doctor observation for an authorized node.", object(Map.of("nodeId", node), List.of("nodeId")))); + var rewardFields = Map.of( + "type", "string", "pattern", "^(Money|Chance|Messages[.](Player|Broadcast)|Items[.][A-Za-z0-9_-]{1,64}[.](Material|Amount))$"); + var rewardSelector = new LinkedHashMap<>(object(Map.of("nodeId", node, "siteKey", name, + "rewardName", Map.of("type", "string", "pattern", "^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$"), + "field", rewardFields), List.of("nodeId", "field"))); + rewardSelector.put("oneOf", List.of(Map.of("required", List.of("siteKey")), Map.of("required", List.of("rewardName")))); + tools.put("read_reward_field", new Tool("read_reward_field", "reward-read", + "Read one supported scalar field from an inline vote-site reward or one named reward.", + rewardSelector)); + tools.put("preview_reward_field", new Tool("preview_reward_field", "reward-preview", + "Preview replacing the exact scalar selected by a current reward read. Browser approval is required.", + object(Map.of("nodeId", node, "readOperationId", id, "value", + Map.of("oneOf", List.of(Map.of("type", "number", "minimum", 0), + Map.of("type", "string", "maxLength", 500)))), + List.of("nodeId", "readOperationId", "value")))); Map editorFields = Map.of( "Enabled", flag, "Hidden", flag, "Name", Map.of("type", "string", "maxLength", 200), "ServiceSite", Map.of("type", "string", "minLength", 1, "maxLength", 2048), diff --git a/src/main/resources/web/index.html b/src/main/resources/web/index.html index a76e6f5..0c16cb4 100644 --- a/src/main/resources/web/index.html +++ b/src/main/resources/web/index.html @@ -744,6 +744,7 @@

Agent access

+ diff --git a/src/test/java/com/bencodez/votingplugin/control/domain/AgentOperationsTest.java b/src/test/java/com/bencodez/votingplugin/control/domain/AgentOperationsTest.java index 7ff104b..164a889 100644 --- a/src/test/java/com/bencodez/votingplugin/control/domain/AgentOperationsTest.java +++ b/src/test/java/com/bencodez/votingplugin/control/domain/AgentOperationsTest.java @@ -581,6 +581,63 @@ private static ConfigurationTaskResult routingResult(UUID session, UUID attempt, } } + @Test void typedRewardsBindOneSupportedFieldAndPreserveAllOtherRewardData() throws Exception { + MutableClock clock = new MutableClock(); + var registry = new InMemoryNodeRegistry(clock, Duration.ofMinutes(2)); + String node = "backend"; + UUID session = UUID.randomUUID(); + registry.register(new NodeRegistration(node, session, node, "BUKKIT", "fixture", 1, + Set.of(ConfigurationOperations.FILE_CAPABILITY, ManagedConfiguration.REWARD_FILE_CAPABILITY), Set.of())); + try (var operations = new ConfigurationOperations(registry, new ConfigurationAuditLog(directory, clock), clock)) { + var agents = new AgentOperations(registry, operations, clock); + var grant = agents.issue(new AgentOperations.Issue(List.of(node), List.of("rewards-editor", "status"), 10, null)); + var other = agents.issue(new AgentOperations.Issue(List.of(node), List.of("rewards-editor", "status"), 10, null)); + assertThrows(IllegalArgumentException.class, () -> agents.readReward(grant.token(), + new AgentOperations.RewardRead(node, null, "../Example", "Money"))); + assertThrows(IllegalArgumentException.class, () -> agents.readReward(grant.token(), + new AgentOperations.RewardRead(node, "Example", null, "Commands"))); + for (boolean named : List.of(false, true)) { + var request = new AgentOperations.RewardRead(node, named ? null : "Example", named ? "Example" : null, "Money"); + UUID id = (UUID) ((Map) agents.readReward(grant.token(), request)).get("operationId"); + String file = named ? "Rewards/Example.yml" : "VoteSites.yml"; + String path = named ? "Money" : "VoteSites.Example.Rewards.Money"; + String yaml = named ? "Money: 5\nCommands:\n- sample-action\n" + : "VoteSites:\n Example:\n Rewards:\n Money: 5\n Commands:\n - sample-action\n"; + String revision = "a".repeat(64); + var source = ManagedConfiguration.file(file, yaml); + var read = operations.claim(node, session); + assertEquals(file, read.configuration().fileName()); + operations.complete(id, node, new ConfigurationTaskResult(session, true, "OK", "fixture", + revision, source, List.of(), false, false, read.attemptId())); + var status = (Map) agents.status(grant.token(), id); + assertEquals(Map.of("rewardField", "Money", "rewardValue", "5"), status.get("values")); + assertFalse(status.toString().contains("sample-action")); + var previewRequest = new AgentOperations.RewardPreview(node, id.toString(), 7); + assertThrows(ValidationException.class, () -> agents.previewReward(other.token(), previewRequest)); + assertThrows(ValidationException.class, () -> agents.previewReward(grant.token(), + new AgentOperations.RewardPreview(node, id.toString(), List.of("sample-action")))); + UUID denied = (UUID) ((Map) agents.previewReward(grant.token(), previewRequest)).get("operationId"); + var bad = operations.claim(node, session); + operations.complete(denied, node, new ConfigurationTaskResult(session, true, "OK", "fixture", + revision, source, List.of("changed " + path, "changed Commands"), + false, false, bad.attemptId())); + assertFalse(operations.get(denied).browserReviewReady()); + UUID preview = (UUID) ((Map) agents.previewReward(grant.token(), previewRequest)).get("operationId"); + var task = operations.claim(node, session); + assertEquals(yaml.replace("Money: 5", "Money: 7"), task.configuration().content()); + operations.complete(preview, node, new ConfigurationTaskResult(session, true, "OK", "fixture", + revision, source, List.of("changed " + path), false, false, task.attemptId())); + assertEquals(Map.of(file + " / " + path, "7"), operations.getAgentReview(preview).after()); + assertNull(operations.get(preview).approvalToken()); + var apply = agents.approve(preview); + var applyTask = operations.claim(node, session); + assertEquals(revision, applyTask.expectedRevision()); + operations.complete(apply.operationId(), node, new ConfigurationTaskResult(session, true, "OK", "fixture", + "b".repeat(64), task.configuration(), List.of("changed " + path), true, false, applyTask.attemptId())); + } + } + } + private static final class MutableClock extends Clock { private Instant now = Instant.EPOCH; diff --git a/src/test/java/com/bencodez/votingplugin/control/http/AgentMcpHttpTest.java b/src/test/java/com/bencodez/votingplugin/control/http/AgentMcpHttpTest.java index 0b6ba75..d49b409 100644 --- a/src/test/java/com/bencodez/votingplugin/control/http/AgentMcpHttpTest.java +++ b/src/test/java/com/bencodez/votingplugin/control/http/AgentMcpHttpTest.java @@ -148,7 +148,7 @@ private void start(boolean agentEnabled) throws Exception { new StdioAdapter(base.toString(), token).run(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)), frames); var replies = frames.toString(StandardCharsets.UTF_8).lines().toList(); assertEquals(4, replies.size()); - assertEquals(17, json.readTree(replies.get(1)).path("result").path("tools").size()); + assertEquals(19, json.readTree(replies.get(1)).path("result").path("tools").size()); assertEquals("proxy-a", json.readTree(replies.get(2)).path("result").path("structuredContent") .path("items").get(0).path("nodeId").asText()); assertEquals(applyId, json.readTree(replies.get(3)).path("result").path("structuredContent")