Skip to content

Reconcile external_directory and pass every declaration to the reconciler - #326

Merged
chubes4 merged 1 commit into
mainfrom
fix/316-reconcile-external-directory
Aug 3, 2026
Merged

Reconcile external_directory and pass every declaration to the reconciler#326
chubes4 merged 1 commit into
mainfrom
fix/316-reconcile-external-directory

Conversation

@chubes4

@chubes4 chubes4 commented Aug 3, 2026

Copy link
Copy Markdown
Member

Closes #316.

Fresh installs go through runtime_generate_config. Every existing install goes through _runtime_repair_opencode_json_additive instead — and that path only reconciled permission.edit. So the upgrade path silently diverged from a fresh install in two ways:

1. Stale workspace grant. An engineering→managed upgrade kept "/var/lib/datamachine/workspace/**": "allow" — a grant to a directory that is empty by design on managed. That is exactly the drift #314 set out to eliminate; I removed it by hand on h44 at the time rather than fixing the cause.

2. New declarations never arrived. --managed-writable and --log-path were added to the Python helper's argparse but never passed from bash. Applying the first real log grant to h44 produced:

--- external_directory ---
                              ← empty
--- edit ---
  wp-admin/**: deny
  ...                         ← no /var/log entries either

The flags were accepted, recorded as options, reflected in AGENTS.md, and had no effect on the permission set.

Fix

expected_external_directory owns the managed grants the same way expected_edit_permission owns the edit rules:

  • absolute and ~ paths are wp-coding-agents' to write and remove
  • relative entries are operator-added and preserved
  • the workspace dir arrives via --workspace-dir, so the reconciler adds it under engineering and drops it under managed

And the bash callers now pass --managed-writable, --log-path, and --workspace-dir alongside --managed-source.

Tests

tests/posture.sh covers the reconcile path specifically — stale workspace grant dropped, operator-added grant preserved, and a log path naming a file granted as a literal rather than only as a subtree.

That last one matters: /var/log/php8.5-fpm.log/** matches nothing, which is why #325 emits both forms.

Full suite: no new failures (same 7 pre-existing environment failures as main).

…conciler (#316)

Fresh installs go through runtime_generate_config; every existing install goes
through the additive reconciler instead. The reconciler owned permission.edit
only, so the upgrade path silently diverged from a fresh install in two ways:

- an engineering->managed upgrade kept the stale DMC workspace grant, which is
  the drift #314 existed to eliminate (removed by hand on h44 at the time)
- --managed-writable and --log-path were never passed to it at all, so on the
  first real log grant the declarations landed in neither external_directory
  nor edit

expected_external_directory now owns the managed grants the same way
expected_edit_permission owns the edit rules: absolute and ~ paths are
wp-coding-agents' to write and remove, relative entries are the operator's and
are preserved. The workspace dir arrives via --workspace-dir so the reconciler
can add it under engineering and drop it under managed.

Verified against the upgrade path, not just generation, since that is the one
every real install takes.
@chubes4
chubes4 merged commit 0b80391 into main Aug 3, 2026
18 checks passed
@chubes4
chubes4 deleted the fix/316-reconcile-external-directory branch August 3, 2026 13:12
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.

opencode.json reconciler ignores external_directory, so an engineering→managed upgrade keeps the stale workspace grant

1 participant