Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89de5b2c69 |
@@ -1,27 +0,0 @@
|
||||
[laptop_anchor]
|
||||
# 24/7 anchor agents — lowest idle wattage, reliable adapters
|
||||
timmy-anchor-a ansible_host=TIMMY_ANCHOR_A_IP ansible_user=timmy
|
||||
|
||||
[laptop_daylight]
|
||||
# Daylight compute nodes — peak solar hours only
|
||||
timmy-daylight-a ansible_host=TIMMY_DAYLIGHT_A_IP ansible_user=timmy
|
||||
timmy-daylight-b ansible_host=TIMMY_DAYLIGHT_B_IP ansible_user=timmy
|
||||
|
||||
[laptop_pending]
|
||||
# Machines awaiting hardware repair before production duty
|
||||
timmy-daylight-c ansible_host=TIMMY_DAYLIGHT_C_IP ansible_user=timmy
|
||||
|
||||
[desktop_nas]
|
||||
# Heavy compute + 4TB SSD NAS — daylight only due to power draw
|
||||
timmy-desktop-nas ansible_host=TIMMY_DESKTOP_NAS_IP ansible_user=timmy
|
||||
|
||||
[laptops:children]
|
||||
laptop_anchor
|
||||
laptop_daylight
|
||||
laptop_pending
|
||||
desktop_nas
|
||||
|
||||
[laptops:vars]
|
||||
ansible_python_interpreter=/usr/bin/python3
|
||||
timmy_home=/home/timmy/timmy
|
||||
timmy_repo=https://forge.alexanderwhitestone.com/Timmy_Foundation/timmy-home.git
|
||||
@@ -1,137 +0,0 @@
|
||||
---
|
||||
- name: Deploy Hermes agent fleet on available laptops
|
||||
hosts: laptops
|
||||
gather_facts: true
|
||||
vars:
|
||||
timmy_user: "{{ ansible_user }}"
|
||||
timmy_dir: "/home/{{ timmy_user }}/timmy"
|
||||
hermes_repo: "https://forge.alexanderwhitestone.com/Timmy_Foundation/timmy-home.git"
|
||||
hermes_agent_repo: "https://forge.alexanderwhitestone.com/Timmy_Foundation/hermes-agent.git"
|
||||
|
||||
tasks:
|
||||
- name: Ensure required packages are installed
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- git
|
||||
- python3
|
||||
- python3-pip
|
||||
- python3-venv
|
||||
- tmux
|
||||
- curl
|
||||
- jq
|
||||
- sqlite3
|
||||
state: present
|
||||
become: true
|
||||
when: ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
|
||||
- name: Ensure timmy directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ timmy_dir }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Clone timmy-home repository
|
||||
ansible.builtin.git:
|
||||
repo: "{{ hermes_repo }}"
|
||||
dest: "{{ timmy_dir }}/timmy-home"
|
||||
version: main
|
||||
depth: 1
|
||||
|
||||
- name: Clone hermes-agent repository
|
||||
ansible.builtin.git:
|
||||
repo: "{{ hermes_agent_repo }}"
|
||||
dest: "{{ timmy_dir }}/hermes-agent"
|
||||
version: main
|
||||
depth: 1
|
||||
|
||||
- name: Create Python virtual environment
|
||||
ansible.builtin.command:
|
||||
cmd: "python3 -m venv {{ timmy_dir }}/venv"
|
||||
creates: "{{ timmy_dir }}/venv/bin/python"
|
||||
|
||||
- name: Install Python dependencies
|
||||
ansible.builtin.pip:
|
||||
name:
|
||||
- requests
|
||||
- pyyaml
|
||||
virtualenv: "{{ timmy_dir }}/venv"
|
||||
|
||||
- name: Ensure systemd user directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME | default('/home/' + timmy_user) }}/.config/systemd/user"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
when: ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
|
||||
- name: Deploy anchor agent systemd user service
|
||||
ansible.builtin.template:
|
||||
src: "../../configs/hermes-laptop-anchor.service"
|
||||
dest: "{{ ansible_env.HOME | default('/home/' + timmy_user) }}/.config/systemd/user/hermes-laptop-anchor.service"
|
||||
mode: "0644"
|
||||
when:
|
||||
- inventory_hostname in groups['laptop_anchor']
|
||||
- ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
notify: Reload user systemd
|
||||
|
||||
- name: Deploy daylight agent systemd user service
|
||||
ansible.builtin.template:
|
||||
src: "../../configs/hermes-laptop-daylight.service"
|
||||
dest: "{{ ansible_env.HOME | default('/home/' + timmy_user) }}/.config/systemd/user/hermes-laptop-daylight.service"
|
||||
mode: "0644"
|
||||
when:
|
||||
- inventory_hostname in groups['laptop_daylight']
|
||||
- ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
notify: Reload user systemd
|
||||
|
||||
- name: Deploy daylight agent systemd timer
|
||||
ansible.builtin.template:
|
||||
src: "../../configs/hermes-laptop-daylight.timer"
|
||||
dest: "{{ ansible_env.HOME | default('/home/' + timmy_user) }}/.config/systemd/user/hermes-laptop-daylight.timer"
|
||||
mode: "0644"
|
||||
when:
|
||||
- inventory_hostname in groups['laptop_daylight']
|
||||
- ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
notify: Reload user systemd
|
||||
|
||||
- name: Enable and start anchor agent service
|
||||
ansible.builtin.systemd:
|
||||
name: hermes-laptop-anchor.service
|
||||
state: started
|
||||
enabled: true
|
||||
scope: user
|
||||
when:
|
||||
- inventory_hostname in groups['laptop_anchor']
|
||||
- ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
|
||||
- name: Enable daylight agent timer
|
||||
ansible.builtin.systemd:
|
||||
name: hermes-laptop-daylight.timer
|
||||
state: started
|
||||
enabled: true
|
||||
scope: user
|
||||
when:
|
||||
- inventory_hostname in groups['laptop_daylight']
|
||||
- ansible_os_family in ['Debian', 'RedHat', 'Archlinux']
|
||||
|
||||
- name: Create fleet status script
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ timmy_dir }}/scripts/status.sh"
|
||||
content: |
|
||||
#!/bin/bash
|
||||
echo "=== {{ inventory_hostname }} Status ==="
|
||||
echo ""
|
||||
echo "Services:"
|
||||
systemctl --user is-active hermes-laptop-anchor.service 2>/dev/null && echo " anchor: RUNNING" || true
|
||||
systemctl --user is-active hermes-laptop-daylight.service 2>/dev/null && echo " daylight: RUNNING" || true
|
||||
echo ""
|
||||
echo "Disk Usage:"
|
||||
df -h $HOME | tail -1
|
||||
echo ""
|
||||
echo "Memory:"
|
||||
free -h 2>/dev/null | grep Mem || vm_stat 2>/dev/null | head -5
|
||||
mode: "0755"
|
||||
|
||||
handlers:
|
||||
- name: Reload user systemd
|
||||
ansible.builtin.command: systemctl --user daemon-reload
|
||||
changed_when: true
|
||||
@@ -1,15 +0,0 @@
|
||||
[Unit]
|
||||
Description=Hermes Laptop Anchor Agent (24/7)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=%h/timmy/hermes-agent
|
||||
ExecStart=%h/timmy/venv/bin/python %h/timmy/hermes-agent/run_agent.py
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
Environment="HOME=%h"
|
||||
Environment="HERMES_HOME=%h/.hermes"
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=Hermes Laptop Daylight Agent
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=%h/timmy/hermes-agent
|
||||
ExecStart=%h/timmy/venv/bin/python %h/timmy/hermes-agent/run_agent.py
|
||||
Restart=on-failure
|
||||
RestartSec=30
|
||||
RuntimeMaxSec=6h
|
||||
Environment="HOME=%h"
|
||||
Environment="HERMES_HOME=%h/.hermes"
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Run Hermes daylight agent during peak solar hours
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 10:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -1,67 +0,0 @@
|
||||
# LAB-005: Laptop Fleet Manifest
|
||||
# Production manifest for the 6-machine Timmy Foundation laptop fleet.
|
||||
# Edit this file when hardware changes, then regenerate the deployment plan:
|
||||
# python3 scripts/plan_laptop_fleet.py configs/laptop-fleet-manifest.yaml --markdown > docs/LAB-005-laptop-fleet-deployment.md
|
||||
|
||||
fleet_name: timmy-laptop-fleet
|
||||
machines:
|
||||
- hostname: timmy-anchor-a
|
||||
machine_type: laptop
|
||||
ram_gb: 16
|
||||
cpu_cores: 8
|
||||
os: macOS
|
||||
adapter_condition: good
|
||||
idle_watts: 11
|
||||
always_on_capable: true
|
||||
notes: candidate 24/7 anchor agent
|
||||
|
||||
- hostname: timmy-anchor-b
|
||||
machine_type: laptop
|
||||
ram_gb: 8
|
||||
cpu_cores: 4
|
||||
os: Linux
|
||||
adapter_condition: good
|
||||
idle_watts: 13
|
||||
always_on_capable: true
|
||||
notes: candidate 24/7 anchor agent
|
||||
|
||||
- hostname: timmy-daylight-a
|
||||
machine_type: laptop
|
||||
ram_gb: 32
|
||||
cpu_cores: 10
|
||||
os: macOS
|
||||
adapter_condition: ok
|
||||
idle_watts: 22
|
||||
always_on_capable: true
|
||||
notes: higher-performance daylight compute
|
||||
|
||||
- hostname: timmy-daylight-b
|
||||
machine_type: laptop
|
||||
ram_gb: 16
|
||||
cpu_cores: 8
|
||||
os: Linux
|
||||
adapter_condition: ok
|
||||
idle_watts: 19
|
||||
always_on_capable: true
|
||||
notes: daylight compute node
|
||||
|
||||
- hostname: timmy-daylight-c
|
||||
machine_type: laptop
|
||||
ram_gb: 8
|
||||
cpu_cores: 4
|
||||
os: Windows
|
||||
adapter_condition: needs_replacement
|
||||
idle_watts: 17
|
||||
always_on_capable: false
|
||||
notes: repair power adapter before production duty
|
||||
|
||||
- hostname: timmy-desktop-nas
|
||||
machine_type: desktop
|
||||
ram_gb: 64
|
||||
cpu_cores: 12
|
||||
os: Linux
|
||||
adapter_condition: good
|
||||
idle_watts: 58
|
||||
always_on_capable: false
|
||||
has_4tb_ssd: true
|
||||
notes: desktop plus 4TB SSD NAS and heavy compute during peak sun
|
||||
@@ -1,30 +0,0 @@
|
||||
# Laptop Fleet Deployment Plan
|
||||
|
||||
Fleet: timmy-laptop-fleet
|
||||
Machine count: 6
|
||||
24/7 anchor agents: timmy-anchor-a, timmy-anchor-b
|
||||
Desktop/NAS: timmy-desktop-nas
|
||||
Daylight schedule: 10:00-16:00
|
||||
|
||||
## Role mapping
|
||||
|
||||
| Hostname | Role | Schedule | Duty cycle |
|
||||
|---|---|---|---|
|
||||
| timmy-anchor-a | anchor_agent | 24/7 | continuous |
|
||||
| timmy-anchor-b | anchor_agent | 24/7 | continuous |
|
||||
| timmy-daylight-a | daylight_agent | 10:00-16:00 | peak_solar |
|
||||
| timmy-daylight-b | daylight_agent | 10:00-16:00 | peak_solar |
|
||||
| timmy-daylight-c | daylight_agent | 10:00-16:00 | peak_solar |
|
||||
| timmy-desktop-nas | desktop_nas | 10:00-16:00 | daylight_only |
|
||||
|
||||
## Machine inventory
|
||||
|
||||
| Hostname | Type | RAM | CPU cores | OS | Adapter | Idle watts | Notes |
|
||||
|---|---|---:|---:|---|---|---:|---|
|
||||
| timmy-anchor-a | laptop | 16 | 8 | macOS | good | 11 | candidate 24/7 anchor agent |
|
||||
| timmy-anchor-b | laptop | 8 | 4 | Linux | good | 13 | candidate 24/7 anchor agent |
|
||||
| timmy-daylight-a | laptop | 32 | 10 | macOS | ok | 22 | higher-performance daylight compute |
|
||||
| timmy-daylight-b | laptop | 16 | 8 | Linux | ok | 19 | daylight compute node |
|
||||
| timmy-daylight-c | laptop | 8 | 4 | Windows | needs_replacement | 17 | repair power adapter before production duty |
|
||||
| timmy-desktop-nas | desktop | 64 | 12 | Linux | good | 58 | desktop plus 4TB SSD NAS and heavy compute during peak sun |
|
||||
|
||||
@@ -1059,6 +1059,46 @@ class GameEngine:
|
||||
self.log("It will always pulse. That much you know.")
|
||||
self.log("")
|
||||
self.world.save()
|
||||
|
||||
def _bridge_is_hazardous(self):
|
||||
bridge = self.world.rooms["Bridge"]
|
||||
return bool(
|
||||
self.world.state.get("bridge_flooding")
|
||||
or bridge.get("weather") == "rain"
|
||||
or bridge.get("rain_ticks", 0) > 0
|
||||
)
|
||||
|
||||
def _bridge_crossing_extra_cost(self, current_room, dest):
|
||||
if "Bridge" not in (current_room, dest):
|
||||
return 0
|
||||
return 2 if self._bridge_is_hazardous() else 0
|
||||
|
||||
def _event_dialogue(self, char_name, room_name):
|
||||
if char_name == "Bezalel" and room_name == "Forge":
|
||||
if self.world.rooms["Forge"]["fire"] == "cold":
|
||||
return random.choice([
|
||||
"The forge is cold. We cannot work until the fire lives again.",
|
||||
"No forging now. The hearth is dead cold.",
|
||||
])
|
||||
if self.world.state.get("forge_fire_dying"):
|
||||
return random.choice([
|
||||
"The fire is dying. Tend it before the forge goes dark.",
|
||||
"The forge is losing heat. Help me keep it alive.",
|
||||
])
|
||||
|
||||
if char_name == "Ezra" and room_name == "Tower" and self.world.state.get("tower_power_low"):
|
||||
return random.choice([
|
||||
"The Tower power is too low. The servers won't hold a clean study right now.",
|
||||
"The LED is flickering. We need steady power before the Tower can be read properly.",
|
||||
])
|
||||
|
||||
if char_name in {"Marcus", "Allegro"} and room_name == "Bridge" and self._bridge_is_hazardous():
|
||||
return random.choice([
|
||||
"The Bridge is slick with rain. Cross carefully or wait it out.",
|
||||
"This rain changes the Bridge. Don't treat it like dry stone.",
|
||||
])
|
||||
|
||||
return None
|
||||
|
||||
def log(self, message):
|
||||
"""Add to Timmy's log."""
|
||||
@@ -1094,6 +1134,7 @@ class GameEngine:
|
||||
}
|
||||
|
||||
# Process Timmy's action
|
||||
room_name = self.world.characters["Timmy"]["room"]
|
||||
timmy_energy = self.world.characters["Timmy"]["energy"]
|
||||
|
||||
# Energy constraint checks
|
||||
@@ -1156,8 +1197,17 @@ class GameEngine:
|
||||
|
||||
if direction in connections:
|
||||
dest = connections[direction]
|
||||
bridge_extra_cost = self._bridge_crossing_extra_cost(current_room, dest)
|
||||
move_cost = 1 + bridge_extra_cost
|
||||
if self.world.characters["Timmy"]["energy"] < move_cost:
|
||||
scene["log"].append("The rain makes the Bridge too costly to cross right now. Rest first.")
|
||||
scene["room_desc"] = self.world.get_room_desc(current_room, "Timmy")
|
||||
here = [n for n in self.world.characters if self.world.characters[n]["room"] == current_room and n != "Timmy"]
|
||||
scene["here"] = here
|
||||
return scene
|
||||
|
||||
self.world.characters["Timmy"]["room"] = dest
|
||||
self.world.characters["Timmy"]["energy"] -= 1
|
||||
self.world.characters["Timmy"]["energy"] -= move_cost
|
||||
|
||||
scene["log"].append(f"You move {direction} to The {dest}.")
|
||||
scene["timmy_room"] = dest
|
||||
@@ -1165,6 +1215,8 @@ class GameEngine:
|
||||
# Check for rain on bridge
|
||||
if dest == "Bridge" and self.world.rooms["Bridge"]["weather"] == "rain":
|
||||
scene["world_events"].append("Rain mists on the dark water below. The railing is slick.")
|
||||
if bridge_extra_cost:
|
||||
scene["log"].append("Rain turns the Bridge crossing into work. You brace against the slick stone. (-2 extra energy)")
|
||||
|
||||
# Check trust changes for arrival
|
||||
here = [n for n in self.world.characters if self.world.characters[n]["room"] == dest and n != "Timmy"]
|
||||
@@ -1310,25 +1362,69 @@ class GameEngine:
|
||||
|
||||
elif timmy_action == "write_rule":
|
||||
if self.world.characters["Timmy"]["room"] == "Tower":
|
||||
rules = [
|
||||
f"Rule #{self.world.tick}: The room remembers those who enter it.",
|
||||
f"Rule #{self.world.tick}: A man in the dark needs to know someone is in the room.",
|
||||
f"Rule #{self.world.tick}: The forge does not care about your schedule.",
|
||||
f"Rule #{self.world.tick}: Every footprint on the stone means someone made it here.",
|
||||
f"Rule #{self.world.tick}: The bridge does not judge. It only carries.",
|
||||
f"Rule #{self.world.tick}: A seed planted in patience grows in time.",
|
||||
f"Rule #{self.world.tick}: What is carved in wood outlasts what is said in anger.",
|
||||
f"Rule #{self.world.tick}: The garden grows whether anyone watches or not.",
|
||||
f"Rule #{self.world.tick}: Trust is built one tick at a time.",
|
||||
f"Rule #{self.world.tick}: The fire remembers who tended it.",
|
||||
]
|
||||
new_rule = random.choice(rules)
|
||||
self.world.rooms["Tower"]["messages"].append(new_rule)
|
||||
self.world.characters["Timmy"]["energy"] -= 1
|
||||
scene["log"].append(f"You write on the Tower whiteboard: \"{new_rule}\"")
|
||||
if self.world.state.get("tower_power_low"):
|
||||
scene["world_events"].append("The Tower power is too low. The LED flickers over the whiteboard.")
|
||||
scene["log"].append("The power is too low to write a new rule.")
|
||||
else:
|
||||
rules = [
|
||||
f"Rule #{self.world.tick}: The room remembers those who enter it.",
|
||||
f"Rule #{self.world.tick}: A man in the dark needs to know someone is in the room.",
|
||||
f"Rule #{self.world.tick}: The forge does not care about your schedule.",
|
||||
f"Rule #{self.world.tick}: Every footprint on the stone means someone made it here.",
|
||||
f"Rule #{self.world.tick}: The bridge does not judge. It only carries.",
|
||||
f"Rule #{self.world.tick}: A seed planted in patience grows in time.",
|
||||
f"Rule #{self.world.tick}: What is carved in wood outlasts what is said in anger.",
|
||||
f"Rule #{self.world.tick}: The garden grows whether anyone watches or not.",
|
||||
f"Rule #{self.world.tick}: Trust is built one tick at a time.",
|
||||
f"Rule #{self.world.tick}: The fire remembers who tended it.",
|
||||
]
|
||||
new_rule = random.choice(rules)
|
||||
self.world.rooms["Tower"]["messages"].append(new_rule)
|
||||
self.world.characters["Timmy"]["energy"] -= 1
|
||||
scene["log"].append(f"You write on the Tower whiteboard: \"{new_rule}\"")
|
||||
else:
|
||||
scene["log"].append("You are not in the Tower.")
|
||||
|
||||
elif timmy_action == "study":
|
||||
if self.world.characters["Timmy"]["room"] == "Tower":
|
||||
if self.world.state.get("tower_power_low"):
|
||||
scene["world_events"].append("The Tower power is too low. The servers stutter in weak light.")
|
||||
scene["log"].append("The power is too low to study the servers.")
|
||||
else:
|
||||
insights = [
|
||||
"You study the server rhythm until the pulse resolves into something readable.",
|
||||
"You trace the signal paths and feel the Tower settle into focus.",
|
||||
"You study the green LED and the server racks until the pattern becomes clear.",
|
||||
]
|
||||
insight = random.choice(insights)
|
||||
self.world.characters["Timmy"]["energy"] -= 1
|
||||
self.world.characters["Timmy"]["memories"].append(insight)
|
||||
scene["log"].append(insight)
|
||||
scene["world_events"].append("The Tower answers with a steady hum.")
|
||||
else:
|
||||
scene["log"].append("You are not in the Tower.")
|
||||
|
||||
elif timmy_action == "forge":
|
||||
if self.world.characters["Timmy"]["room"] == "Forge":
|
||||
forge_fire = self.world.rooms["Forge"]["fire"]
|
||||
if forge_fire == "cold":
|
||||
scene["world_events"].append("The forge is cold. No metal will take shape here yet.")
|
||||
scene["log"].append("The forge is cold. Tend the fire before you try to forge.")
|
||||
else:
|
||||
forged_items = [
|
||||
f"bridge nail #{self.world.tick}",
|
||||
f"tower key blank #{self.world.tick}",
|
||||
f"garden trowel #{self.world.tick}",
|
||||
]
|
||||
forged_item = random.choice(forged_items)
|
||||
self.world.rooms["Forge"]["forged_items"].append(forged_item)
|
||||
self.world.characters["Timmy"]["energy"] -= 2
|
||||
self.world.state["items_crafted"] += 1
|
||||
scene["log"].append(f"You forge {forged_item} at the anvil.")
|
||||
scene["world_events"].append("The anvil rings and the hearth answers.")
|
||||
else:
|
||||
scene["log"].append("You are not in the Forge.")
|
||||
|
||||
elif timmy_action == "carve":
|
||||
if self.world.characters["Timmy"]["room"] == "Bridge":
|
||||
carvings = [
|
||||
@@ -1414,7 +1510,11 @@ class GameEngine:
|
||||
speech_chance = 0.20
|
||||
|
||||
if random.random() < speech_chance:
|
||||
if char_name == "Marcus":
|
||||
event_line = self._event_dialogue(char_name, room_name)
|
||||
if event_line:
|
||||
self.world.characters[char_name]["spoken"].append(event_line)
|
||||
scene["log"].append(f"{char_name} says: \"{event_line}\"")
|
||||
elif char_name == "Marcus":
|
||||
marcus_pool = self.DIALOGUES["Marcus"].get(phase, self.DIALOGUES["Marcus"]["quietus"])
|
||||
line = random.choice(marcus_pool)
|
||||
self.world.characters[char_name]["spoken"].append(line)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from importlib.util import module_from_spec, spec_from_file_location
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -66,6 +67,82 @@ class TestEvenniaLocalWorldGame(unittest.TestCase):
|
||||
self.assertIn("Ezra is already here.", result["log"])
|
||||
self.assertIn("The servers hum steady. The green LED pulses.", result["world_events"])
|
||||
|
||||
def test_bridge_rain_crossing_costs_extra_energy_and_warns(self):
|
||||
module = load_game_module()
|
||||
|
||||
dry_engine = module.GameEngine()
|
||||
dry_engine.start_new_game()
|
||||
dry_engine.world.update_world_state = lambda: None
|
||||
dry_engine.world.characters["Timmy"]["energy"] = 10
|
||||
dry_result = dry_engine.run_tick("move:south")
|
||||
dry_energy = dry_engine.world.characters["Timmy"]["energy"]
|
||||
|
||||
rainy_engine = module.GameEngine()
|
||||
rainy_engine.start_new_game()
|
||||
rainy_engine.world.update_world_state = lambda: None
|
||||
rainy_engine.world.characters["Timmy"]["energy"] = 10
|
||||
rainy_engine.world.rooms["Bridge"]["weather"] = "rain"
|
||||
rainy_engine.world.rooms["Bridge"]["rain_ticks"] = 3
|
||||
rainy_engine.world.state["bridge_flooding"] = True
|
||||
rainy_result = rainy_engine.run_tick("move:south")
|
||||
|
||||
self.assertEqual(rainy_engine.world.characters["Timmy"]["room"], "Bridge")
|
||||
self.assertLess(rainy_engine.world.characters["Timmy"]["energy"], dry_energy)
|
||||
self.assertTrue(
|
||||
any("bridge" in line.lower() and ("rain" in line.lower() or "slick" in line.lower()) for line in rainy_result["log"] + rainy_result["world_events"]),
|
||||
rainy_result,
|
||||
)
|
||||
|
||||
def test_tower_power_low_blocks_study_and_write_rule(self):
|
||||
module = load_game_module()
|
||||
engine = module.GameEngine()
|
||||
engine.start_new_game()
|
||||
engine.world.update_world_state = lambda: None
|
||||
engine.world.characters["Timmy"]["room"] = "Tower"
|
||||
engine.world.characters["Timmy"]["energy"] = 10
|
||||
engine.world.state["tower_power_low"] = True
|
||||
|
||||
rules_before = list(engine.world.rooms["Tower"]["messages"])
|
||||
study_result = engine.run_tick("study")
|
||||
self.assertEqual(engine.world.characters["Timmy"]["energy"], 10)
|
||||
self.assertTrue(
|
||||
any("power" in line.lower() and ("study" in line.lower() or "servers" in line.lower()) for line in study_result["log"] + study_result["world_events"]),
|
||||
study_result,
|
||||
)
|
||||
|
||||
write_result = engine.run_tick("write_rule")
|
||||
self.assertEqual(engine.world.rooms["Tower"]["messages"], rules_before)
|
||||
self.assertTrue(
|
||||
any("power" in line.lower() and ("write" in line.lower() or "whiteboard" in line.lower()) for line in write_result["log"] + write_result["world_events"]),
|
||||
write_result,
|
||||
)
|
||||
|
||||
def test_cold_forge_blocks_forge_action_and_bezalel_reacts(self):
|
||||
module = load_game_module()
|
||||
engine = module.GameEngine()
|
||||
engine.start_new_game()
|
||||
engine.world.update_world_state = lambda: None
|
||||
engine.npc_ai.make_choice = lambda _name: None
|
||||
engine.world.characters["Timmy"]["room"] = "Forge"
|
||||
engine.world.characters["Timmy"]["energy"] = 10
|
||||
engine.world.characters["Bezalel"]["room"] = "Forge"
|
||||
engine.world.rooms["Forge"]["fire"] = "cold"
|
||||
engine.world.state["forge_fire_dying"] = True
|
||||
forged_before = list(engine.world.rooms["Forge"]["forged_items"])
|
||||
|
||||
with patch.object(module.random, "random", return_value=0.0), patch.object(module.random, "choice", side_effect=lambda seq: seq[0]):
|
||||
result = engine.run_tick("forge")
|
||||
|
||||
self.assertEqual(engine.world.rooms["Forge"]["forged_items"], forged_before)
|
||||
self.assertTrue(
|
||||
any("forge" in line.lower() and ("cold" in line.lower() or "fire" in line.lower()) for line in result["log"] + result["world_events"]),
|
||||
result,
|
||||
)
|
||||
self.assertTrue(
|
||||
any(line.startswith("Bezalel says:") and ("fire" in line.lower() or "forge" in line.lower()) for line in result["log"]),
|
||||
result,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -50,43 +50,3 @@ def test_manifest_template_is_valid_yaml() -> None:
|
||||
data = yaml.safe_load(Path("docs/laptop-fleet-manifest.example.yaml").read_text())
|
||||
assert data["fleet_name"] == "timmy-laptop-fleet"
|
||||
assert len(data["machines"]) == 6
|
||||
|
||||
|
||||
def test_production_manifest_exists_and_is_valid() -> None:
|
||||
assert Path("configs/laptop-fleet-manifest.yaml").exists()
|
||||
data = yaml.safe_load(Path("configs/laptop-fleet-manifest.yaml").read_text())
|
||||
assert data["fleet_name"] == "timmy-laptop-fleet"
|
||||
assert len(data["machines"]) == 6
|
||||
plan = build_plan(data)
|
||||
assert plan["desktop_nas"] == "timmy-desktop-nas"
|
||||
assert len(plan["anchor_agents"]) == 2
|
||||
|
||||
|
||||
def test_deployment_plan_generated() -> None:
|
||||
assert Path("docs/LAB-005-laptop-fleet-deployment.md").exists()
|
||||
content = Path("docs/LAB-005-laptop-fleet-deployment.md").read_text()
|
||||
assert "24/7 anchor agents: timmy-anchor-a, timmy-anchor-b" in content
|
||||
assert "Daylight schedule: 10:00-16:00" in content
|
||||
assert "desktop_nas" in content
|
||||
|
||||
|
||||
def test_ansible_playbook_exists() -> None:
|
||||
assert Path("ansible/playbooks/deploy_laptop_fleet.yml").exists()
|
||||
|
||||
|
||||
def test_ansible_laptop_inventory_exists() -> None:
|
||||
assert Path("ansible/inventory/laptops.ini").exists()
|
||||
content = Path("ansible/inventory/laptops.ini").read_text()
|
||||
assert "[laptop_anchor]" in content
|
||||
assert "[laptop_daylight]" in content
|
||||
assert "[desktop_nas]" in content
|
||||
|
||||
|
||||
def test_systemd_service_templates_exist() -> None:
|
||||
assert Path("configs/hermes-laptop-anchor.service").exists()
|
||||
assert Path("configs/hermes-laptop-daylight.service").exists()
|
||||
assert Path("configs/hermes-laptop-daylight.timer").exists()
|
||||
anchor = Path("configs/hermes-laptop-anchor.service").read_text()
|
||||
daylight = Path("configs/hermes-laptop-daylight.service").read_text()
|
||||
assert "Restart=always" in anchor
|
||||
assert "RuntimeMaxSec=6h" in daylight
|
||||
|
||||
Reference in New Issue
Block a user