Keep other nodes out of a group the agent makes round new nodes
A group made in an agent call is fitted round its nodes only after the call has arranged them, and the arrangement knew nothing of it. With On key held, Move and Owner placed fresh, a group round key and move and one round the owner, the Owner landed beside the key. Move is taller than the key, so the Owner stood in the first group and the two groups lay on each other. lint_graph counted none of it. Found while testing copy_nodes (#434). - arrange takes the new option blocks: sets of arranged nodes a group is fitted round afterwards. Once the columns are laid out, whatever would stand in such a group goes below it, a node or the group of another set, with everything arranged under it. - The flow keeps its columns. A first try laid each set out as one block instead, but then the link from the Owner ran over the key inside the group (throughNodes 1). - AgentEdit passes every group made in the call whose nodes are all new. Groups round nodes already there and the Arrange button stay as they were. Tests: - agent-edit: new test with the setup that showed the fault. No node stands in a group not its own, the groups lie apart, lint_graph has 0 overlaps, throughNodes, backwards and coveredNotes. - Counter-check: without the new step exactly that test is red. - Agent, graph-arrange and graph-follow tests 120/120. - e2e 71 on atx: ALL PASSED, 26 checks. - Gate on atx: CHECK EXIT 0, 327 files, 5025 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb981b5b0f
commit
e4ccf5f72f
5 files changed
+118
-7
No files matched your search
@@ -8,8 +8,9 @@ import { hostFor, text } from './agentTestHost';
|
||||
/** Copying nodes through the agent's tools (#434). */
|
||||
|
||||
/**
|
||||
* Behavior Walk, placed by hand so no group takes in a node not its own: a key held moving its owner, a Variables node reading `speed` (kept), a group round
|
||||
* key and move, a comment above the Variables node, and a group round the owner alone.
|
||||
* Behavior Walk, placed by hand: a key held moving its owner, a Variables node reading `speed`
|
||||
* (kept), a group round key and move, a comment above the Variables node, and a group round the
|
||||
* owner alone.
|
||||
*/
|
||||
async function walkAndRun(fixture: SceneFixture, host: ToolHost) {
|
||||
const steps = [
|
||||
|
||||
@@ -241,6 +241,41 @@ describe('run_commands', () => {
|
||||
expect(behavior.graph.groups![0]).toEqual(before);
|
||||
});
|
||||
|
||||
it('gives a group made round new nodes room, what else would stand in it going below', async () => {
|
||||
const fixture = makeSpriteScene('Hero');
|
||||
const { host } = hostFor(fixture);
|
||||
const steps = [
|
||||
...walkLeft(fixture),
|
||||
{ command: 'add_group', args: { asset: '$walk', nodes: ['$key', '$move'], title: 'Walk' } },
|
||||
{ command: 'add_group', args: { asset: '$walk', nodes: ['$owner'], title: 'Who' } },
|
||||
];
|
||||
const result = await runTool('run_commands', { steps, label: 'walk' }, host);
|
||||
expect(result.isError, text(result)).toBeFalsy();
|
||||
|
||||
const behavior = fixture.project.assets.find((asset) => asset.name === 'Walk')!;
|
||||
const { graph } = findGraphAsset(fixture.project, behavior.id)!;
|
||||
const [walk, who] = graph.groups!;
|
||||
const centred = (box: { x: number; y: number; w: number; h: number }) =>
|
||||
graph.nodes
|
||||
.filter((node) => {
|
||||
const cx = node.x + NODE_WIDTH / 2;
|
||||
const cy = node.y + 20;
|
||||
return cx >= box.x && cx <= box.x + box.w && cy >= box.y && cy <= box.y + box.h;
|
||||
})
|
||||
.map((node) => node.type);
|
||||
// Move is taller than the key: before, the Owner beside the key came to stand in the Walk group.
|
||||
expect(centred(walk!)).toEqual(['OnKeyHeld', 'Move']);
|
||||
expect(centred(who!)).toEqual(['Owner']);
|
||||
const apart =
|
||||
who!.x + who!.w <= walk!.x ||
|
||||
walk!.x + walk!.w <= who!.x ||
|
||||
who!.y + who!.h <= walk!.y ||
|
||||
walk!.y + walk!.h <= who!.y;
|
||||
expect(apart).toBe(true);
|
||||
const lint = JSON.parse(text(await runTool('lint_graph', { asset: behavior.id }, host))) as GraphLint;
|
||||
expect(lint).toMatchObject({ overlaps: 0, throughNodes: 0, backwards: 0, coveredNotes: 0 });
|
||||
});
|
||||
|
||||
it('changes nothing when a step fails, and names the step and why', async () => {
|
||||
const fixture = makeSpriteScene();
|
||||
const { host } = hostFor(fixture);
|
||||
|
||||
Reference in new issue
Block a user