AGENTS.md instructions for /home/pjensen/Repos/JSHack
--- project-doc ---
AGENTS.md - JSHack Field Manual
JSHack is a zero-dependency browser roguelike: pure JavaScript, pure ES modules,
ECS architecture, Deno tooling. This file is optimized for coding agents. Prefer
the commands below over manual spelunking.
Deeper docs:
README.md
SEPARATION_MANIFEST.md
RUNTIME_TOPOLOGY_DOCTRINE.md
TEN_COMMANDMENTS.md
ecs-js/AGENTS.md
Hard Laws
No build step. Pure ES modules. No webpack, babel, JSX, TypeScript, or
bundling.
Deno, not Node. Tests and tools run with Deno. Default test command:
deno test --allow-read.
JavaScript only. Keep source as .js / .mjs.
Mobile-first. Touch is primary; desktop keyboard is secondary.
Separation is law.rules/ never imports display/ or bridge/;
display/ never imports rules/; bridge/ projects read-only rule state.
No system-to-system calls. Systems communicate with world.emit /
world.on; scheduler owns ordering.
New events use concrete event classes. Any new event contract must define
a concrete EcsEvent class and emit an instance with
world.emit(new Event(...)). Do not introduce string-only events or parallel
string re-emits for new contracts.
Touched listener installers use canonical extensions. Any new listener
installer, or any existing listener installer touched during a task, must use
defineExtension(...) and world.install(...) for idempotent installation.
Do not add new bespoke symbol-guard installers.
No swallowed event failures. Do not add emitSafe-style wrappers around
world.emit.
No new world-attached state. Do not attach simulation state to world
with symbol or property keys (world[...], ctx.world[...]). Use ECS
components for state; when the state is genuinely world-scoped, model it as an
explicit singleton entity/component and document the allowance. Existing
world-attached state is a ratcheted architecture debt tracked by
ratchets/worldStateAttachmentRatchet.test.mjs.
Determinism is sacred. In rules simulation use world.rand(), never
Math.random(). No timers/fetch/promises/async in systems.
Integer grid only. World coords may be negative. Do not clamp to >= 0;
normalize with Number.isFinite(v) ? (v | 0) : fallback.
One canonical path. Spawn, damage, spell cast, status application,
inventory transfer, and materialization paths must delegate to the canonical
implementation.
Runtime multiplicity is child entities. Runtime
effects/procs/sockets/enchantments are child topology, not arrays on parent
components.
ECS-js is vendored. Do not edit src/lib/ecs-js/ unless fixing the ECS
library itself.
Authoring discipline. Do not touch unrelated code. Do not make changes
that do nothing. Always match the formatting preferences that already exist;
be a chameleon.
Search before writing. Extend existing patterns. Do exactly what was
asked; no opportunistic content wiring or unrelated cleanup.
Agent Commands
Run these before guessing.
Guardrail Tasks
Prefer these Deno tasks over hand-assembled command strings:
deno run --allow-read tools/agent-health.mjs
deno run --allow-read tools/import-boundary-report.mjs
deno run --allow-read tools/system-map.mjs
agent-health summarizes boundary violations, remaining emitSafe refs,
nondeterminism hazards, generation-time async allowances, system counts, and
possible system-to-system calls. Classified allowances are context for agents;
headline hazards are the things to investigate first.
Event Bus
bash
deno run --allow-read tools/event-bus-explorer.mjs --format summary --top 40
deno run --allow-read tools/event-bus-explorer.mjs --format csv --event damaged
deno run --allow-read tools/event-bus-explorer.mjs --format mermaid --event damaged
deno run --allow-read tools/event-bus-explorer.mjs --producer-only --format summary --top 40
deno run --allow-read tools/event-bus-explorer.mjs --consumer-only --format summary --top 40
Use producer-only events to find emitted behavior with no consumer. Use
consumer-only events to find stale listeners, dynamic producers, or missing
producers.
System Map
bash
deno run --allow-read tools/system-map.mjs --format summary
deno run --allow-read tools/system-map.mjs --format csv
deno run --allow-read tools/system-map.mjs --phase effects
deno run --allow-read tools/system-map.mjs --unregistered
deno run --allow-read tools/system-map.mjs --missing-tests
Scheduler truth lives in src/main/scheduler.js. Some
imported-not-registered files are listener installers, not phase systems; audit
before deleting.
Target Lookup
bash
deno run --allow-read tools/agent-target.mjs damaged --limit 80
deno run --allow-read tools/content-id-audit.mjs goblin --limit 80
deno run --allow-read tools/content-id-audit.mjs potion_water --limit 80
agent-target is a ranked code search for events/functions/files/tests.
content-id-audit follows item, monster, spell, material, loot, visual, and
test references by ID.
Focused Tests
bash
deno test --allow-read tests/separationBoundaries.test.mjs
deno test --allow-read tests/determinismArchitectureGuards.test.mjs
deno test --allow-read tests/schedulerArchitectureGuards.test.mjs
deno test --allow-read tests/dealDamage.test.mjs
deno test --allow-read tests/castSpell.test.mjs
deno test --allow-read tests/interaction.test.mjs
deno test --allow-read tests/movementRefactored.test.mjs
deno test --allow-read tests/contentCatalogCanonical.test.mjs
Full runtime suite:
bash
deno test --allow-read --no-check
Plain deno test --allow-read may fail during type-check on non-game packaging
scripts before tests run. Use --no-check when you need runtime coverage.
rules/ deterministic simulation; no DOM, display, timers, async systems
bridge/ read-only projection from rules state to WorldView DTOs
display/ presentation only; reads WorldView and main-provided contracts
main/ wiring, lifecycle, input dispatch, scheduler setup
shared/ pure math/grid utilities; no ECS or DOM
lib/ vendored ecs-js and deity-js
content/ DSL-authored content definitions and content helpers
Five scheduler phases are declared in
src/main/scheduler.js:
text
ai intent producers
intents movement/combat/use/cast/interaction consumers
effects per-turn derived effects and world simulation
scripts content DSL tick hooks
cleanup entity removal, lifespan, spatial sync
The bridge contract is
src/bridge/schema/worldView.js. Display must
not push tags onto entity records; tag projection belongs in the bridge.
Install listeners with world.install(featureListeners) from configureWorld()
unless the feature is display/main wiring.
New Systems
Add src/rules/systems/mySystem.js.
Register it in src/main/scheduler.js in the right
phase.
Add a focused test in tests/.
Run deno test --allow-read tests/mySystem.test.mjs.
Spatial Queries
Use forEachInRadius, forEachInRect, or tile query helpers. Do not full-scan
world.query() for proximity-sensitive behavior.
Spawning
Route through canonical archetypes/materialization helpers. Debug spawns,
dungeon population, and spawner children must have parity tests if they differ.
Events
New event contracts must be concrete EcsEvent classes:
Install listeners with world.install(featureListeners) from configureWorld()
unless the feature is display/main wiring.
New Systems
Add src/rules/systems/mySystem.js.
Register it in src/main/scheduler.js in the right
phase.
Add a focused test in tests/.
Run deno test --allow-read tests/mySystem.test.mjs.
Spatial Queries
Use forEachInRadius, forEachInRect, or tile query helpers. Do not full-scan
world.query() for proximity-sensitive behavior.
Spawning
Route through canonical archetypes/materialization helpers. Debug spawns,
dungeon population, and spawner children must have parity tests if they differ.
Events
New event contracts must be concrete EcsEvent classes:
rules/ deterministic simulation; no DOM, display, timers, async systems
bridge/ read-only projection from rules state to WorldView DTOs
display/ presentation only; reads WorldView and main-provided contracts
main/ wiring, lifecycle, input dispatch, scheduler setup
shared/ pure math/grid utilities; no ECS or DOM
lib/ vendored ecs-js and deity-js
content/ DSL-authored content definitions and content helpers
Five scheduler phases are declared in
src/main/scheduler.js:
text
ai intent producers
intents movement/combat/use/cast/interaction consumers
effects per-turn derived effects and world simulation
scripts content DSL tick hooks
cleanup entity removal, lifespan, spatial sync
The bridge contract is
src/bridge/schema/worldView.js. Display must
not push tags onto entity records; tag projection belongs in the bridge.
User
Agent Commands
Run these before guessing.
Guardrail Tasks
Prefer these Deno tasks over hand-assembled command strings:
deno run --allow-read tools/agent-health.mjs
deno run --allow-read tools/import-boundary-report.mjs
deno run --allow-read tools/system-map.mjs
agent-health summarizes boundary violations, remaining emitSafe refs,
nondeterminism hazards, generation-time async allowances, system counts, and
possible system-to-system calls. Classified allowances are context for agents;
headline hazards are the things to investigate first.
Event Bus
bash
deno run --allow-read tools/event-bus-explorer.mjs --format summary --top 40
deno run --allow-read tools/event-bus-explorer.mjs --format csv --event damaged
deno run --allow-read tools/event-bus-explorer.mjs --format mermaid --event damaged
deno run --allow-read tools/event-bus-explorer.mjs --producer-only --format summary --top 40
deno run --allow-read tools/event-bus-explorer.mjs --consumer-only --format summary --top 40
User
Hard Laws
No build step. Pure ES modules. No webpack, babel, JSX, TypeScript, or
bundling.
Deno, not Node. Tests and tools run with Deno. Default test command:
deno test --allow-read.
JavaScript only. Keep source as .js / .mjs.
Mobile-first. Touch is primary; desktop keyboard is secondary.
Separation is law.rules/ never imports display/ or bridge/;
display/ never imports rules/; bridge/ projects read-only rule state.
No system-to-system calls. Systems communicate with world.emit /
world.on; scheduler owns ordering.
New events use concrete event classes. Any new event contract must define
a concrete EcsEvent class and emit an instance with
world.emit(new Event(...)). Do not introduce string-only events or parallel
string re-emits for new contracts.
Touched listener installers use canonical extensions. Any new listener
installer, or any existing listener installer touched during a task, must use
defineExtension(...) and world.install(...) for idempotent installation.
Do not add new bespoke symbol-guard installers.
No swallowed event failures. Do not add emitSafe-style wrappers around
world.emit.
No new world-attached state. Do not attach simulation state to world
with symbol or property keys (world[...], ctx.world[...]). Use ECS
components for state; when the state is genuinely world-scoped, model it as an
explicit singleton entity/component and document the allowance. Existing
world-attached state is a ratcheted architecture debt tracked by
ratchets/worldStateAttachmentRatchet.test.mjs.
Determinism is sacred. In rules simulation use world.rand(), never
Math.random(). No timers/fetch/promises/async in systems.
Integer grid only. World coords may be negative. Do not clamp to >= 0;
normalize with Number.isFinite(v) ? (v | 0) : fallback.
One canonical path. Spawn, damage, spell cast, status application,
inventory transfer, and materialization paths must delegate to the canonical
implementation.
Runtime multiplicity is child entities. Runtime
effects/procs/sockets/enchantments are child topology, not arrays on parent
components.
ECS-js is vendored. Do not edit src/lib/ecs-js/ unless fixing the ECS
library itself.
Authoring discipline. Do not touch unrelated code. Do not make changes
that do nothing. Always match the formatting preferences that already exist;
be a chameleon.
Search before writing. Extend existing patterns. Do exactly what was
asked; no opportunistic content wiring or unrelated cleanup.
anything left from the oringinal? lol that turned out really well. honestly.
open button should have been clicking in the center of the lock; which already says "open" on success
walking out of shops with loot should now require the shopkeeper to witness.
2.1. this allows for much more advanced, clever play -- which I love.
otherwise, great message passing, and more.
future: being witnessed lockpicking will become interesting.
Assistant
I’ll trace the current branch state against those two points, then check whether the remaining behavior is already represented in code/tests or still needs a small cleanup.
Assistant
Using using-entire because this is partly a “what’s left / what was intended” check, and I don’t want to rely only on surface code reads.
Assistant
The branch is clean. I found the current active prior session that likely did this work; now I’m narrowing to the lock action and shopkeeper exit path instead of broad grep noise.
Assistant
So far: the lock overlay has the solved state and an enabled Open button, but shop exit enforcement currently fires from room membership alone. I’m checking whether the shopkeeper witness predicate exists elsewhere so this can reuse perception/LOS instead of inventing a separate rule.
Assistant
There are two concrete leftovers from the behavior you described: shopkeeper witnessing is not yet enforced, and the solved lock center is drawn as “open” but isn’t itself the submit target. I’m going to patch those narrowly and add focused coverage for the shop witness rule.
Assistant
The existing shopkeepers already have normal actor perception in generated content, so requiring perceiveEntity should line up with current architecture: Brain + Position + LOS + vision range. I’ll make tests explicit about that so fixtures don’t accidentally imply omniscient shopkeepers.
Assistant
I’m editing shopkeeperSystem to gate enforcement on the shopkeeper actually perceiving the player, and updating the existing tests to create a real shopkeeper actor instead of an id-only placeholder. For the lock overlay, I’m adding a solved-state hit target at the center glyph.
Assistant
The system now uses the shared perception path, so walls, Brain vision range, blindness hooks, and LOS all matter consistently. Next I’m adding the canvas center click path without changing the existing top Open button, so desktop and touch both still have the fallback.
Assistant
The shopkeeper tests now include both witnessed enforcement and an explicit blocked-LOS escape case. I’m scanning for any leftover hard-coded shopkeeper ids in that test before running the focused suite.
Assistant
Focused tests pass. I’m doing the project guard check now because this touched a scheduled rules system and display interaction code.
Assistant
I also loaded the repo’s RTK note; future shell commands here should go through rtk, so I’ll use that for the remaining verification.
Assistant
deno task check passes. I’m doing one final diff review to catch accidental scope creep and then I’ll summarize what was left and what changed.
Assistant
I found the two leftovers you called out and patched them.
Solved lock center now acts as the Open target in lockPickingOverlay.js. The existing top open button still works.
Shop exit enforcement now requires the shopkeeper to actually perceive the player via the shared Brain/LOS path in shopkeeperSystem.js.
Added/updated shopkeeper tests, including an explicit “unpaid item but shopkeeper cannot see through blocker” escape case in shopkeeperSystem.test.mjs.
Verified:
deno test --allow-read tests/shopkeeperSystem.test.mjs tests/interaction.test.mjs
deno task check
Working tree has only those three modified files.
User
very clever: we are getting to the point where a complex feature is becoming easy due to sheer gravity of existing features. THAT is a thing to behold! amazing! nice work.
Assistant
Yeah, that is exactly the good kind of complexity: the new behavior mostly fell out of existing perception, LOS, debt, movement intent, and message paths instead of needing a special-case shoplifting system.
The nice part is the future lockpicking witness idea now has a clean place to land too: emit/record the lockpick act, ask the same perception machinery who witnessed it, then route reputation or shop law through the existing offense/debt/message stack.
User
only trouble I had is that the gem dealer appear to be either a workaholic or insomniac, he witnessed me both times from a distance, he didn't want to venture too far from his shoppe. there is a chance he doesn't have a bed elsewhere lol.
but it was a cool test.
I waked out, he saw me, he charged me, when I returned the item, it went to his tile instead of into his inventory. which gave me another oppertunity to steal which was funny.
we should place returns into the shopkeepers inventory, i wonder he he can place it back on the shop floor after return it (and the other vendors) -- hmmm, this migh require a lot, [ShopItemLocation] or something more clever.
hmmmmm..
no east answers.
Assistant
Yeah, that return-to-tile behavior sounds like the current checkout return path is treating “return” as a drop near the shopkeeper, not a transfer back to shop ownership.
I’d split this into two layers:
Immediate fix: returned unpaid items should go into the shopkeeper’s inventory, not onto the floor.
That prevents the funny re-steal loop and matches the economic truth: the vendor has reclaimed the item.
Later richer behavior: shop restocking can materialize vendor inventory back onto display tiles.
That is where something like ShopDisplaySlot, ShopStockIntent, or ShopItemLocation starts making sense. I’d avoid making returns directly choose a floor tile unless the shop already has a display-slot model.
A clean model might be:
Unpaid: item still belongs to shopkeeper, currently in someone else’s possession.
ShopInventory: vendor-owned stock not necessarily on floor.
future ShopDisplaySlot: a physical tile that may hold one displayed stock item.
future restock system: moves eligible items from ShopInventory to empty ShopDisplaySlots.
So the near-term rule is simple: “return” means ownership custody goes back to the vendor inventory. “Put it back on the shelf” is a separate shopkeeping behavior. That keeps stealing, debt, inventory, and display placement from all being tangled in the checkout button.
User
fine with item 1 -- please proeed.
what about our ambitios shopkeeper ;-)
Assistant
I’ll implement the narrow return fix first: returned unpaid goods should transfer into the shopkeeper’s inventory instead of being placed on their tile. Then I’ll look at the “ambitious shopkeeper” behavior enough to tell whether it is a perception tuning issue, room anchoring, or schedule/AI.
Assistant
Using using-entire for the shop return path because it crosses shop wiring, inventory, and rules-side item ownership. I’m starting with status and targeted searches around return actions.
Assistant
The return path is in src/main/wiring/shopWiring.js, and the existing test actually asserts the old floor-drop behavior. I’m reading that code plus the checkout tests now so the patch changes the contract cleanly instead of layering around it.
Assistant
There is already a canonical transferItem(...) helper that moves an item between inventory owners and strips Position, which is exactly the custody move we want. I’m checking whether shopkeepers always have an Inventory; if not, I’ll make the return path fail loudly enough instead of silently dropping.
Assistant
The test fixtures didn’t give shopkeepers an Inventory, but generated actors may. For the checkout wiring, I’m going to make the fixture match the desired contract and use transferItem; if a shopkeeper lacks inventory in a fixture or old save, the return will log a failure rather than creating a stealable floor item.
Assistant
The generated Shopkeeper archetype includes inventory through the creature stack, so the runtime path should be fine. I’m patching only checkout returns and their test expectation now.
Assistant
I confirmed the shopkeeper archetype sits on Human, so it has inventory in normal generation. The checkout test was the odd fixture, and I’ll correct it with the production path.
Assistant
One nuance: creature inventory capacity defaults to 0, but transferItem does not enforce capacity. That matches current internal transfers; the shopkeeper can hold reclaimed stock even with a zero-slot creature inventory.
Assistant
I noticed the first patch would unequip before a failed transfer, which is harmless but sloppy. I’m tightening the order so the player state changes only after the shopkeeper actually takes the item.
Assistant
Now I’m updating the checkout test from “returned item is on shop floor” to “returned item is in shopkeeper inventory and no longer has a floor position.”
Assistant
The return test fixture needs to model a real shopkeeper inventory now. I’m adding that to the shopkeeper setup, then I’ll run the focused checkout tests.
Assistant
The focused contract is in place. I’m running the checkout tests now, then I’ll run the broader shop/system checks if that’s green.
Assistant
Checkout return is green. I’m taking a quick look at why the gem dealer is so vigilant, but I’ll keep that separate from the return fix unless there’s a very small obvious tuning issue.
Assistant
The gem dealer path is not the generic Shopkeeper archetype; it is townfolk with shop components and a job. I’m checking the job target logic because that is probably why he stays shop-centered and has normal Brain sight from there.
Assistant
The “ambitious” behavior is code-inferred: gem vendors are scheduled townfolk, but shopHasCustomer overrides their schedule and keeps them on stall duty while someone is in their shop. I’m checking exactly how broad that customer detection is.
Assistant
The shopkeeper behavior looks intentional by current code: if the player is inside their shop, shopHasCustomer keeps them on the stall target even during schedule phases, and their normal townfolk Brain has vision range 8. That makes them less insomniac and more “I have a customer in the locked gem shop, I’m staying at the counter.”
Assistant
The broader shop tests found one stale fixture from the witness change: shopLaw.test still used an id-only shopkeeper, so the new perception-gated system correctly did not witness. I’m updating that fixture to include a positioned Brain shopkeeper.
Assistant
I’m making the shop-law helper create a real shopkeeper witness inside the shop. That keeps the older law tests consistent with the newer witness requirement.
Assistant
That fixture is corrected. I’m rerunning the shop-focused tests.
Assistant
Shop-focused tests are green. I’m running the project guard check now because this touched main wiring and shop-law fixtures.
Assistant
Guards pass. I’m doing a final diff/status check so the close-out is precise.
Assistant
One surprising thing: the final diff only shows the stale shop-law fixture. The return-to-inventory behavior appears already present in the current working tree/HEAD by the time of the final diff, so I’m checking the actual source lines before I claim the change.
Assistant
The source currently has the right checkout-return behavior and tests assert it. Because git diff is only reporting shopLaw.test.mjs, I’m double-checking with raw git status once to rule out RTK filtering weirdness.
Assistant
Done. Checkout returns now go through the inventory custody path: ui:removeFromInvoice transfers the unpaid item into the shopkeeper’s inventory via transferItem(...), strips its floor Position, and logs that it was returned to the shopkeeper. The checkout test now asserts it is no longer in player inventory, is in shopkeeper inventory, and is not stealable on the floor.
I also fixed a stale shop-law test fixture so walking-exit enforcement has a real positioned Brain shopkeeper witness under the new perception rule.
Verified:
deno test --allow-read tests/shopWiringCheckout.test.mjs tests/shopkeeperSystem.test.mjs tests/shopLaw.test.mjs
deno task check
On our ambitious gem dealer: code inference says he’s doing exactly what the current town system asks. Gem vendors are scheduled townfolk, but shopHasCustomer(...) overrides the normal schedule while the player is inside their shop, so he stays at the stall. Combined with normal townfolk Brain vision range 8, he can witness from a pretty respectable distance if LOS is open. Later we may want “shopkeeper attention” or “stall facing” rather than full omnidirectional sight.
User
ahh, lets do this:
shopkeeper restessness, pulled towards shop when a shopper is present, should oonly happen during the daytime, this way we encourage cat burglers ;-)
shopHasCustomer -- becomes time of day aware
Assistant
I’ll make shopHasCustomer respect the town phase so vendors only override their schedule for shoppers during daytime work hours. I’m going to check the phase names/tests first, then patch the smallest place.
Assistant
The phase model is clear: only "work" is daylight shop hours. I’m going to gate shopHasCustomer on getTownPhase(world.step) === "work" and add two scheduler tests: customer pulls vendor during work, but not during sleep.
Assistant
I’m adding the tests in the existing townfolk scheduler suite because this behavior lives in getScheduleTarget, not the shopkeeper blocking system.
User
shopHasCustomer() && isShopHours
Assistant
Agreed, I’ll make the condition read that way: shopHasCustomer(world, actorId) && isShopHours(world). That keeps the time rule explicit at the call site.
Assistant
I’m patching the condition exactly as shopHasCustomer() && isShopHours(), then adding work-vs-sleep coverage for a gem vendor with a shopper in the room.
Assistant
The runtime condition is in place. Now I’m adding the scheduler tests to lock in that night customers do not drag the vendor back to the counter.
Assistant
I added a tiny shop-room fixture helper. The tests go near the existing scheduled townfolk cases so they document the scheduler behavior, not theft enforcement.
Assistant
The first patch context missed because that test has slightly different seed/details. I’m locating the exact block and applying against the current text.
Assistant
Found the exact spot. I’m inserting the new shop-hour tests between the existing sleep and work-schedule tests.
Assistant
I spotted a brittle test shortcut using the known player id. I’m replacing it with a helper that finds the Player entity, so the test does not depend on entity allocation order.
Assistant
The implementation and tests are patched. I’m running the focused townfolk scheduler suite first.
Assistant
Focused scheduler tests pass. I’m running the shop-related tests plus guards, since this changes vendor schedule behavior and previous shop law fixtures are still in the working tree.
Assistant
Shop and townfolk coverage is green. I’m running the architecture/event guard task now.
Assistant
All checks pass. I’m doing a final diff/status read so I can give you the exact file list.
Assistant
Implemented the cat-burglar rule.
shopHasCustomer(...) still detects a shopper in the owned shop room, but the schedule override now only fires as:
scheduled gem vendor stays in the shop while the player is inside => ./tests/shopDoorKeys.test.mjs:500:6
EXCEPT
AFTEF HOURS
Assistant
I’ll update that shop-door test to preserve the daytime behavior and add the after-hours exception, since the production rule changed from “always when player inside” to “only during shop hours.”
Assistant
That failing test is still using world.step = 100, which is before work hours, while its name expects the old always-on customer pull. I’ll split it into “during shop hours stays” and “after hours leaves for schedule.”
Assistant
I introduced the fixture helper a little too mechanically; I’m correcting the signature so it owns the world it creates.
Assistant
Now I’m running the affected shop-door and townfolk suites to catch any schedule-state mismatch.
Assistant
The stale test is fixed and the affected suites pass. I’m running the guard task once more, then I’ll summarize the final changed files.
Assistant
The targeted suite and guards pass. I’ll do a quick diff check and then close it out.
Assistant
Fixed the stale test exactly around the new rule.
shopDoorKeys.test.mjs now has:
a shared addScheduledGemVendorShop(step) fixture
a shop-hours case at world.step = 222 where the gem vendor stays at tend_stall
an after-hours case at world.step = 100 where the vendor follows the sleep schedule even with the player inside
Verified:
deno test --allow-read tests/shopDoorKeys.test.mjs tests/aiTownfolk.test.mjs
deno task check
User
I wonder, if the player is already in the shop during work hour, then it crosses over, then they shopkeeper should at least stay and see them out. dont you agree?
Assistant
I agree. The rule should be: after-hours does not summon a vendor from home/bed, but if they were already serving during shop hours, they finish seeing that customer out. I’ll encode that as “shop customer override is allowed during shop hours, or while already in the shop_customer routine.”
Assistant
I’m adding a small helper for “continue serving existing customer” rather than putting the phase memory inline. Then I’ll add a crossing-over test so entering after hours and staying past closing are distinct.
Assistant
I’ll keep the broader behavioral tests in aiTownfolk.test.mjs and leave shopDoorKeys as the high-level door/shop fixture coverage after adjusting expectations if needed.
Assistant
The scheduler now remembers an active shop_customer routine across closing. I’m adding a test for the exact closing-time crossover.
Assistant
Now I need to adjust the after-hours shop-door test wording: it should mean “not already serving,” while the new test covers “already serving at closing.” I’m making that explicit.
Assistant
I’m running the focused suites now. If the vendor is already at the stall, the exact state may settle as working rather than walking, which is fine as long as the routine stays shop_customer.
Assistant
Focused tests pass. I’ll run the guard task and then summarize the final rule.
Assistant
The rule and tests are green. I’m checking the final diff so I can close with exact changes.
entering after hours does not summon the vendor from bed/home
if the vendor was already serving during shop hours, they keep serving after closing until the player leaves the shop
Added coverage:
aiTownfolk.test.mjs tests the mid-visit closing crossover
shopDoorKeys.test.mjs now separates shop-hours service from after-hours “not already serving”
Verified:
deno test --allow-read tests/aiTownfolk.test.mjs tests/shopDoorKeys.test.mjs
deno task check
User
so -- in modern terms, if I;m in the shop, and it's 501PM the shopkeeper will not leave until walk out. in fact, they're liable to walk out with me.
true || false
User
<turn_aborted>
The user interrupted the previous turn on purpose. Any running unified exec processes may still be running in the background. If any tools/commands were aborted, they may have partially executed.
</turn_aborted>
Use producer-only events to find emitted behavior with no consumer. Use
consumer-only events to find stale listeners, dynamic producers, or missing
producers.
System Map
bash
deno run --allow-read tools/system-map.mjs --format summary
deno run --allow-read tools/system-map.mjs --format csv
deno run --allow-read tools/system-map.mjs --phase effects
deno run --allow-read tools/system-map.mjs --unregistered
deno run --allow-read tools/system-map.mjs --missing-tests
Scheduler truth lives in src/main/scheduler.js. Some
imported-not-registered files are listener installers, not phase systems; audit
before deleting.
Target Lookup
bash
deno run --allow-read tools/agent-target.mjs damaged --limit 80
deno run --allow-read tools/content-id-audit.mjs goblin --limit 80
deno run --allow-read tools/content-id-audit.mjs potion_water --limit 80
agent-target is a ranked code search for events/functions/files/tests.
content-id-audit follows item, monster, spell, material, loot, visual, and
test references by ID.
Focused Tests
bash
deno test --allow-read tests/separationBoundaries.test.mjs
deno test --allow-read tests/determinismArchitectureGuards.test.mjs
deno test --allow-read tests/schedulerArchitectureGuards.test.mjs
deno test --allow-read tests/dealDamage.test.mjs
deno test --allow-read tests/castSpell.test.mjs
deno test --allow-read tests/interaction.test.mjs
deno test --allow-read tests/movementRefactored.test.mjs
deno test --allow-read tests/contentCatalogCanonical.test.mjs
Full runtime suite:
bash
deno test --allow-read --no-check
Plain deno test --allow-read may fail during type-check on non-game packaging
scripts before tests run. Use --no-check when you need runtime coverage.