agora.fleet.runtime_postconditions

Postcondition factories that execute subprocesses to catch runtime bugs.

These sit alongside the static postcondition helpers in the project runner scripts. Each factory returns a Predicate so it plugs into Specification.postconditions unchanged.

The checks all expect the ctx dict to carry work_dir. That matches the contract the runner populates for every other postcondition.

Functions

postcond_bot_calls_tree_sync([rel])

bot.py must reference tree.sync somewhere.

postcond_no_code_after_main_block(rel)

Catch module-scope statements placed after if __name__ == '__main__':.

postcond_pytest_passes([rel, timeout])

pytest rel must exit 0 inside work_dir.

postcond_python_imports(rel, *[, timeout])

The module at rel must import without raising.

postcond_readme_only_references_existing_commands([...])

Every /xxx command mentioned in the README must exist in bot.py.

postcond_requirements_parse([rel])

Every non-blank non-comment line of rel must be valid PEP 508.

agora.fleet.runtime_postconditions.postcond_bot_calls_tree_sync(rel='bot.py')[source]

bot.py must reference tree.sync somewhere.

This is a cheap string match rather than an AST probe: slash commands that are never sync’d to Discord never appear to the client, so the bot looks connected but does nothing. Catching it before the run ships saves a full end-to-end manual test.

agora.fleet.runtime_postconditions.postcond_no_code_after_main_block(rel)[source]

Catch module-scope statements placed after if __name__ == '__main__':.

Run 13 shipped a bug where build_roll’s handler landed AFTER the bot.run(TOKEN) line — tests (which import with non-__main__ __name__) saw /roll registered; production (which hits the __main__ block and blocks in bot.run) never registered it.

Detected via AST: find the module-scope if __name__ == '__main__': node and flag every subsequent top-level statement as unreachable at runtime.

agora.fleet.runtime_postconditions.postcond_pytest_passes(rel='.', *, timeout=60.0)[source]

pytest rel must exit 0 inside work_dir.

agora.fleet.runtime_postconditions.postcond_python_imports(rel, *, timeout=15.0)[source]

The module at rel must import without raising.

agora.fleet.runtime_postconditions.postcond_readme_only_references_existing_commands(readme='README.md', bot='bot.py')[source]

Every /xxx command mentioned in the README must exist in bot.py.

Catches the LLM hallucinating features it didn’t read about (the run-2 README advertised a /help command nobody ever wrote).

agora.fleet.runtime_postconditions.postcond_requirements_parse(rel='requirements.txt')[source]

Every non-blank non-comment line of rel must be valid PEP 508.