Skip to content

Commit 75bbc7e

Browse files
authored
Merge pull request #6 from DizzyMii/fix/landlord-maxretries-validation
fix(landlord): validate maxRetries as a positive integer
2 parents b85885a + 3cac220 commit 75bbc7e

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"landlord": patch
3+
---
4+
5+
Validate `maxRetries` on a contract as a positive integer. It was previously an unconstrained `z.number()`, so negative or zero values silently caused a tenant to escalate without ever running, and fractional values produced an unexpected extra attempt in the `attempt < maxRetries` loop. The schema now enforces `int().min(1)`.

packages/landlord/src/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ContractSchema = z.object({
1616
toolsAllowed: z.array(z.string()).optional(),
1717
toolsDenied: z.array(z.string()).optional(),
1818
dependsOn: z.array(z.string()).default([]),
19-
maxRetries: z.number().default(3),
19+
maxRetries: z.number().int().min(1).default(3),
2020
});
2121

2222
export type Checkpoint = z.infer<typeof CheckpointSchema>;

packages/landlord/test/contract.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,19 @@ describe('ContractSchema', () => {
6363
});
6464
expect(result.success).toBe(false);
6565
});
66+
67+
it('rejects non-positive, non-integer, and fractional maxRetries', () => {
68+
const base = {
69+
role: 'r',
70+
objective: 'x',
71+
subPrompt: 'x',
72+
checkpoints: [],
73+
outputSchema: {},
74+
};
75+
for (const maxRetries of [0, -1, 2.5]) {
76+
const result = ContractSchema.safeParse({ ...base, maxRetries });
77+
expect(result.success).toBe(false);
78+
}
79+
expect(ContractSchema.safeParse({ ...base, maxRetries: 1 }).success).toBe(true);
80+
});
6681
});

0 commit comments

Comments
 (0)