[schema] CareEvent: Water carries the amount poured, so watering by feel can be replayed
This commit is contained in:
@@ -5,27 +5,102 @@
|
|||||||
"description": "One act of care, append-only and never edited (CLAUDE.md §6.2). The other event kinds arrive with docs/GAMEPLAY.md.",
|
"description": "One act of care, append-only and never edited (CLAUDE.md §6.2). The other event kinds arrive with docs/GAMEPLAY.md.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": ["kind", "ts", "localDay", "from", "to", "act", "trace", "messageId", "clientVersion"],
|
"required": [
|
||||||
|
"kind",
|
||||||
|
"ts",
|
||||||
|
"localDay",
|
||||||
|
"from",
|
||||||
|
"to",
|
||||||
|
"act",
|
||||||
|
"trace",
|
||||||
|
"messageId",
|
||||||
|
"clientVersion"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"kind": { "const": "care" },
|
"kind": {
|
||||||
"ts": { "description": "Epoch milliseconds. Stays on the device; never part of a trace.", "type": "integer", "minimum": 0 },
|
"const": "care"
|
||||||
|
},
|
||||||
|
"ts": {
|
||||||
|
"description": "Epoch milliseconds. Stays on the device; never part of a trace.",
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0
|
||||||
|
},
|
||||||
"localDay": {
|
"localDay": {
|
||||||
"description": "The player's local day, from engine/src/time/localDay.ts and nowhere else.",
|
"description": "The player's local day, from engine/src/time/localDay.ts and nowhere else.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
||||||
},
|
},
|
||||||
"from": { "$ref": "#/definitions/publicKey" },
|
"from": {
|
||||||
"to": { "$ref": "#/definitions/publicKey" },
|
"$ref": "#/definitions/publicKey"
|
||||||
"act": { "type": "string", "enum": ["water", "shade", "weed", "petals"] },
|
},
|
||||||
"trace": { "type": "string", "pattern": "^petal:[a-z]+(-[a-z]+)*$" },
|
"to": {
|
||||||
|
"$ref": "#/definitions/publicKey"
|
||||||
|
},
|
||||||
|
"act": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"water",
|
||||||
|
"shade",
|
||||||
|
"weed",
|
||||||
|
"petals"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"trace": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^petal:[a-z]+(-[a-z]+)*$"
|
||||||
|
},
|
||||||
"messageId": {
|
"messageId": {
|
||||||
"description": "A hope-library id or null. Never text: the pattern admits no space, so no sentence fits (CLAUDE.md §5.6 rule 1).",
|
"description": "A hope-library id or null. Never text: the pattern admits no space, so no sentence fits (CLAUDE.md §5.6 rule 1).",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{ "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "maxLength": 64 },
|
{
|
||||||
{ "type": "null" }
|
"type": "string",
|
||||||
|
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
|
||||||
|
"maxLength": 64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"clientVersion": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" }
|
"clientVersion": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"description": "How much was poured, 0 to 1 of a full can. Water only: the skill of watering by feel is replayed from it (.agents/features/rose.md R1).",
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"act": {
|
||||||
|
"const": "water"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"amount": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"amount"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"not": {
|
||||||
|
"properties": {
|
||||||
|
"amount": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"amount"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"publicKey": {
|
"publicKey": {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const careEvent = {
|
|||||||
localDay: '2026-10-24',
|
localDay: '2026-10-24',
|
||||||
from: KEY_A,
|
from: KEY_A,
|
||||||
to: KEY_B,
|
to: KEY_B,
|
||||||
act: 'water',
|
act: 'shade',
|
||||||
trace: 'petal:pale-pink',
|
trace: 'petal:pale-pink',
|
||||||
messageId: 'ps-23-4',
|
messageId: 'ps-23-4',
|
||||||
clientVersion: '0.1.0'
|
clientVersion: '0.1.0'
|
||||||
@@ -64,9 +64,19 @@ describe('hope sentence', () => {
|
|||||||
|
|
||||||
describe('care event', () => {
|
describe('care event', () => {
|
||||||
it('accepts every act the rose has', () => {
|
it('accepts every act the rose has', () => {
|
||||||
for (const act of ['water', 'shade', 'weed', 'petals']) {
|
for (const act of ['shade', 'weed', 'petals']) {
|
||||||
expect(validateCareEvent({ ...careEvent, act }), act).toMatchObject({ ok: true });
|
expect(validateCareEvent({ ...careEvent, act }), act).toMatchObject({ ok: true });
|
||||||
}
|
}
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'water', amount: 0.5 })).toMatchObject({ ok: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('water carries how much was poured, 0 to 1; no other act carries it (rose.md R1)', () => {
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'water' }).ok, 'water without amount').toBe(false);
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'water', amount: 0 }).ok).toBe(true);
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'water', amount: 1 }).ok).toBe(true);
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'water', amount: 1.01 }).ok).toBe(false);
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'water', amount: -0.1 }).ok).toBe(false);
|
||||||
|
expect(validateCareEvent({ ...careEvent, act: 'weed', amount: 0.5 }).ok, 'weeds are pulled, not poured').toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects the acts §6.2 used to list by mistake', () => {
|
it('rejects the acts §6.2 used to list by mistake', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user