Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions apps/editor/lib/graph-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test('keeps plugin child ids in the parsed graph', () => {
const res = apiGraphSchema.safeParse(graph)

expect(res.success).toBe(true)
expect((res.data?.nodes[LEVEL_ID] as { children: string[] }).children).toEqual([TREE_ID])
expect((res.data!.nodes[LEVEL_ID] as { children: string[] }).children).toEqual([TREE_ID])
})

test('preserves installedPlugins alongside a plugin node', () => {
Expand Down Expand Up @@ -178,7 +178,7 @@ test('migrates legacy wall assemblies before validation and persists canonical l
const result = apiGraphSchema.safeParse(graph)

expect(result.success).toBe(true)
expect((result.data?.nodes[wall.id] as WallNode).assembly).toEqual({
expect((result.data!.nodes[wall.id] as WallNode).assembly).toEqual({
face: 'exterior',
layers: [{ id: 'framing', role: 'structure', thickness: 0.14, core: true, material: 'wood' }],
})
Expand All @@ -195,33 +195,36 @@ test('reports malformed legacy wall assemblies as validation issues', () => {
test.each([
['long', 'a'.repeat(81), 'a'.repeat(121)],
['empty', '', ''],
])('preserves %s legacy text and every layer above the former F2 caps', (_, preset, cavityInsulation) => {
const wall = WallNode.parse({ id: 'wall_unboundedgraph', start: [0, 0], end: [4, 0] })
const graph = buildGraph({
[wall.id]: {
...wall,
assembly: {
preset,
cavityInsulation,
exterior: { finish: 'stone', thickness: 5.001 },
sheathing: { material: 'osb', thickness: 5.001 },
framing: { kind: 'wood', depth: 5.001 },
interior: { finish: 'drywall', thickness: 5.001 },
])(
'preserves %s legacy text and every layer above the former F2 caps',
(_, preset, cavityInsulation) => {
const wall = WallNode.parse({ id: 'wall_unboundedgraph', start: [0, 0], end: [4, 0] })
const graph = buildGraph({
[wall.id]: {
...wall,
assembly: {
preset,
cavityInsulation,
exterior: { finish: 'stone', thickness: 5.001 },
sheathing: { material: 'osb', thickness: 5.001 },
framing: { kind: 'wood', depth: 5.001 },
interior: { finish: 'drywall', thickness: 5.001 },
},
},
},
})

const result = apiGraphSchema.parse(graph)
const assembly = WallNode.parse(result.nodes[wall.id]).assembly!
expect(assembly.presetId).toBe(preset)
expect(assembly.cavityInsulation).toBe(cavityInsulation)
expect(assembly.layers.map(({ id, thickness }) => [id, thickness])).toEqual([
['exterior', 5.001],
['sheathing', 5.001],
['framing', 5.001],
['interior', 5.001],
])
})
})

const result = apiGraphSchema.parse(graph)
const assembly = WallNode.parse(result.nodes[wall.id]).assembly!
expect(assembly.presetId).toBe(preset)
expect(assembly.cavityInsulation).toBe(cavityInsulation)
expect(assembly.layers.map(({ id, thickness }) => [id, thickness])).toEqual([
['exterior', 5.001],
['sheathing', 5.001],
['framing', 5.001],
['interior', 5.001],
])
},
)

// Unnamespaced kinds are legitimate: `wiki/architecture/plugin-authoring.md`
// requires plugin *ids* to look like `vendor:pack`, never kinds, and its worked
Expand Down
36 changes: 18 additions & 18 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"release:major": "gh workflow run release.yml -f bump=major"
},
"devDependencies": {
"@biomejs/biome": "^2.4.16",
"@biomejs/biome": "^2.5.15",
"@typescript/native-preview": "7.0.0-dev.20260624.1",
"@typescript/typescript6": "6.0.2",
"dotenv-cli": "^11.0.0",
"fast-xml-parser": "^5.11.2",
"turbo": "^2.9.17",
"turbo": "^2.11.8",
"typescript": "npm:@typescript/typescript6@6.0.2",
"ultracite": "^7.8.2"
},
Expand Down
21 changes: 12 additions & 9 deletions packages/core/src/agent-operations/hosted-services.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ describe('hosted service operations', () => {
address: 'An address',
walletId: 'somebody_else',
},
])('refuses invalid location, budget or undeclared input before host admission (%#)', async (input) => {
let called = false
await expect(
executeHostedServiceTool('pull_site_data', input, async () => {
called = true
}),
).rejects.toBeInstanceOf(Error)
expect(called).toBe(false)
})
])(
'refuses invalid location, budget or undeclared input before host admission (%#)',
async (input) => {
let called = false
await expect(
executeHostedServiceTool('pull_site_data', input, async () => {
called = true
}),
).rejects.toBeInstanceOf(Error)
expect(called).toBe(false)
},
)

test('reopening dispatches only the retained operation reference', async () => {
let call: HostedServiceRequest | undefined
Expand Down
137 changes: 68 additions & 69 deletions packages/core/src/agent-operations/layout-clearance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,34 +279,34 @@ describe('layout-clearance', () => {
}
})

test.each([
null,
'level_missing',
])('an underlay with unresolved parent %s remains an occupied footprint', (parentId) => {
const rug = ItemNode.parse({
id: 'item_rug',
parentId,
position: [3, 0, 3],
asset: {
id: 'large-rug',
name: 'Large rug',
category: 'furniture',
thumbnail: '',
src: 'asset://large-rug',
dimensions: [4, 0.02, 4],
},
})
expect(collectOccupiedFootprints([rug])).toMatchObject([
{
test.each([null, 'level_missing'])(
'an underlay with unresolved parent %s remains an occupied footprint',
(parentId) => {
const rug = ItemNode.parse({
id: 'item_rug',
levelId: null,
aabb: { minX: 1, maxX: 5, minZ: 1, maxZ: 5 },
},
])
const level = LevelNode.parse({ id: 'level_floor' })
const floorRug = ItemNode.parse({ ...rug, parentId: level.id })
expect(collectOccupiedFootprints([level, floorRug])).toEqual([])
})
parentId,
position: [3, 0, 3],
asset: {
id: 'large-rug',
name: 'Large rug',
category: 'furniture',
thumbnail: '',
src: 'asset://large-rug',
dimensions: [4, 0.02, 4],
},
})
expect(collectOccupiedFootprints([rug])).toMatchObject([
{
id: 'item_rug',
levelId: null,
aabb: { minX: 1, maxX: 5, minZ: 1, maxZ: 5 },
},
])
const level = LevelNode.parse({ id: 'level_floor' })
const floorRug = ItemNode.parse({ ...rug, parentId: level.id })
expect(collectOccupiedFootprints([level, floorRug])).toEqual([])
},
)

function bedRoom(blocker?: 'large-rug' | 'solid-cabinet' | 'thick-rug' | 'raised-rug') {
const level = LevelNode.parse({ id: 'level_r' })
Expand Down Expand Up @@ -350,51 +350,50 @@ describe('layout-clearance', () => {
return { nodes, catalog }
}

test.each([
undefined,
'large-rug',
] as const)('automatic bed fits against a wall with floor covering %s', (blocker) => {
const { nodes, catalog } = bedRoom(blocker)
const before = structuredClone(nodes)
const outcome = AGENT_OPERATIONS.place_in_room(
nodes,
{ assetId: 'double-bed', zoneId: 'zone_r' },
{ catalog },
)
const after = applySceneChanges(nodes, outcome.changes!)
const bed = after[outcome.result.itemId as string]
expect(nodes).toEqual(before)
expect(outcome.result).toMatchObject({ ok: true })
expect(bed).toMatchObject({ type: 'item', parentId: 'level_r' })
if (bed?.type !== 'item') throw new Error('bed missing')
const footprint = itemNodePlanAabb(bed)!
expect([footprint.minX, footprint.minZ].every((value) => value >= 0)).toBe(true)
expect([footprint.maxX, footprint.maxZ].every((value) => value <= 6)).toBe(true)
expect(
Math.min(footprint.minX, footprint.minZ, 6 - footprint.maxX, 6 - footprint.maxZ),
).toBeLessThanOrEqual(0.2)
expect(bed.position[1]).toBe(0)
if (blocker) {
expect(after.item_underlay).toEqual(before.item_underlay)
expect(aabbsOverlap(footprint, itemNodePlanAabb(after.item_underlay!)!)).toBe(true)
expect(findItemItemCollisions({ nodes: Object.values(after) })).toEqual([])
}
})

test.each([
'solid-cabinet',
'thick-rug',
'raised-rug',
] as const)('automatic bed remains blocked by %s', (blocker) => {
const { nodes, catalog } = bedRoom(blocker)
expect(() =>
AGENT_OPERATIONS.place_in_room(
test.each([undefined, 'large-rug'] as const)(
'automatic bed fits against a wall with floor covering %s',
(blocker) => {
const { nodes, catalog } = bedRoom(blocker)
const before = structuredClone(nodes)
const outcome = AGENT_OPERATIONS.place_in_room(
nodes,
{ assetId: 'double-bed', zoneId: 'zone_r' },
{ catalog },
),
).toThrow(expect.objectContaining({ code: 'no_free_spot' }))
})
)
const after = applySceneChanges(nodes, outcome.changes!)
const bed = after[outcome.result.itemId as string]
expect(nodes).toEqual(before)
expect(outcome.result).toMatchObject({ ok: true })
expect(bed).toMatchObject({ type: 'item', parentId: 'level_r' })
if (bed?.type !== 'item') throw new Error('bed missing')
const footprint = itemNodePlanAabb(bed)!
expect([footprint.minX, footprint.minZ].every((value) => value >= 0)).toBe(true)
expect([footprint.maxX, footprint.maxZ].every((value) => value <= 6)).toBe(true)
expect(
Math.min(footprint.minX, footprint.minZ, 6 - footprint.maxX, 6 - footprint.maxZ),
).toBeLessThanOrEqual(0.2)
expect(bed.position[1]).toBe(0)
if (blocker) {
expect(after.item_underlay).toEqual(before.item_underlay)
expect(aabbsOverlap(footprint, itemNodePlanAabb(after.item_underlay!)!)).toBe(true)
expect(findItemItemCollisions({ nodes: Object.values(after) })).toEqual([])
}
},
)

test.each(['solid-cabinet', 'thick-rug', 'raised-rug'] as const)(
'automatic bed remains blocked by %s',
(blocker) => {
const { nodes, catalog } = bedRoom(blocker)
expect(() =>
AGENT_OPERATIONS.place_in_room(
nodes,
{ assetId: 'double-bed', zoneId: 'zone_r' },
{ catalog },
),
).toThrow(expect.objectContaining({ code: 'no_free_spot' }))
},
)

test('automatic bed over a rug still respects reserved clearance', () => {
const { nodes, catalog } = bedRoom('large-rug')
Expand Down
Loading
Loading