[Matrix] Agent Definitions refactor + Secure UUID #59
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
Two small code quality fixes bundled together — both touch
js/websocket.jsandjs/agents.js:AGENT_DEFSinwebsocket.js(name, role, CSS color) andAGENT_POSITIONS/AGENT_COLORSinagents.js(position, integer color). Adding a fifth agent requires editing two files.Math.random()which is not cryptographically secure.crypto.randomUUID()is available natively in all target browsers.Done looks like
js/agent-defs.js)uuid()function removed; all call sites usecrypto.randomUUID()Math.random()for ID generation anywhereOut of scope
Tasks
AGENT_DEFSobject: name, role, hex integer color, direction, world position (x, z) for each agent.agent-defs.js; deriveAGENT_POSITIONSandAGENT_COLORSfrom it. No rendering logic changes.agent-defs.js. Derive CSS hex color string from integer. Remove duplicateAGENT_DEFS. Replaceuuid()withcrypto.randomUUID()at all call sites.js/agent-defs.jsas single file to edit.Relevant files
the-matrix/js/agents.jsthe-matrix/js/websocket.jsthe-matrix/README.mdPR #73 created.
agents.jswas the last file still hardcoding agent IDs. It now importsAGENT_DEFSfromagent-defs.jsand derivesagentStatesdynamically. The other tasks (agent-defs.js, websocket.js UUID, README) were already completed in prior commits. Build verified clean.