Skip to content

refactor(coder/modules/agentapi): decouple boundary logic and improve script sourcing#851

Draft
35C4n0r wants to merge 9 commits intomainfrom
35C4n0r/refactor-agentapi-decouple
Draft

refactor(coder/modules/agentapi): decouple boundary logic and improve script sourcing#851
35C4n0r wants to merge 9 commits intomainfrom
35C4n0r/refactor-agentapi-decouple

Conversation

@35C4n0r
Copy link
Copy Markdown
Collaborator

@35C4n0r 35C4n0r commented Apr 17, 2026

Description

Removes boundary logic and lifecycle hook variables from the agentapi module, and improves script sourcing to use configurable paths instead of hardcoded /tmp/ locations.

Boundary is a general network-isolation primitive not specific to agentapi. This PR strips out the embedded code as a prerequisite for extracting it into a standalone coder/boundary module (#844). Lifecycle hooks (pre_install_script, install_script, post_install_script, start_script) are also removed — consumer modules are now responsible for placing their own start script at $module_path/scripts/agentapi-start.sh.

Changes

Boundary removal:

  • Remove variables: enable_boundary, boundary_config_path, boundary_version, compile_boundary_from_source, use_boundary_directly
  • Delete scripts/boundary.sh
  • Remove coder_env.boundary_config resource
  • Remove boundary section from README.md
  • Remove boundary tests and mock logging

Lifecycle hook removal:

  • Remove variables: pre_install_script, install_script, post_install_script, start_script
  • Remove pre-install, install, and post-install execution blocks from scripts/main.sh
  • Remove pre-post-install-scripts test

Script sourcing improvements:

  • Add module_directory variable (default $HOME/.coder-modules/coder/agentapi)
  • Scripts are written to module_directory instead of /tmp/
  • Lib script path passed via ARG_LIB_SCRIPT_PATH instead of hardcoded /tmp/agentapi-lib.sh
  • Tests write start script directly to the container instead of via Terraform variable

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/agentapi
Breaking change: [x] Yes — removes boundary and lifecycle hook variables

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

Closes #852

🤖 Generated with Coder Agents

@35C4n0r 35C4n0r self-assigned this Apr 17, 2026
@35C4n0r 35C4n0r marked this pull request as draft April 17, 2026 13:36
Jay Kumar and others added 5 commits April 17, 2026 14:03
The coder_script resources write scripts to module_directory
(default $HOME/.coder-modules/coder/agentapi) but never create
the directory first, causing 'No such file or directory' in every
test. Also fix stale chmod targets that still referenced /tmp/.
…tests

- Remove PRE_INSTALL_SCRIPT, INSTALL_SCRIPT, START_SCRIPT,
  POST_INSTALL_SCRIPT from main.sh (variables removed from main.tf
  but still read under set -o nounset).
- Remove pre-install, install, and post-install execution blocks
  from main.sh. Consumer modules are now responsible for placing
  the start script at the expected path.
- Remove pre-post-install-scripts test (tests removed functionality).
- Write test start script directly to container instead of passing
  via Terraform variable.
- Pass ARG_LIB_SCRIPT_PATH in shutdown tests (required after lib
  sourcing was made configurable).
The module_directory default contains $HOME which needs shell
expansion at runtime. Single quotes prevented expansion, causing
'No such file or directory' when sourcing the lib script.
@35C4n0r 35C4n0r changed the title refactor(agentapi): decouple boundary logic and improve script sourcing refactor(coder/modules/agentapi): decouple boundary logic and improve script sourcing Apr 17, 2026
@35C4n0r
Copy link
Copy Markdown
Collaborator Author

35C4n0r commented Apr 18, 2026

wip: do not review

35C4n0r and others added 3 commits April 19, 2026 15:27
…directory rename

- Replace all stale $module_path references in main.sh with
  ${MODULE_DIRECTORY}.
- Update main.test.ts: moduleDirName → moduleDirectory, pass
  module_directory instead of module_dir_name, fix shutdown test
  to use ARG_MODULE_DIRECTORY.
- Remove start_script from agentapi.tftest.hcl (deleted variable).
- Rename module_path → module_directory in testdata/agentapi-start.sh.
…ename

- Replace module_dir_name with module_directory in example snippet.
- Remove deleted variables (pre_install_script, post_install_script,
  start_script, install_script) from example.
- Update state persistence docs to reference module_directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agentapi: remove boundary logic, lifecycle hooks, and hardcoded /tmp/ script paths

1 participant