Skip to content

feat(packagekit+loaderkit): systemd units + /etc/charly config in native packages; layered config stack - #230

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/mcp-systemd-packaging
Sep 7, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/mcp-systemd-packaging

Conversation

@atrawog

@atrawog atrawog commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Two coupled changes from the systemd-units + /etc/charly config plan (plan/charly-mcp-systemd-config.md, §3.3 renderer + §3.5 layered config stack), consuming the spec v0.2026250.632 Packaging schema (PR #113's tag):

  1. packagekit renderer (§3.3) — new packagekit/systemd.go + config.go, wired into BuildInfo (packagekit/nfpm_config.go), shipping in the deb/rpm/archlinux packages ONLY (apk/ipk/msix have no systemd — skipped):

    • /usr/lib/systemd/system/charly-mcp.service + /usr/lib/systemd/user/charly-mcp.service — rendered from packaging.systemd (Description/After/Wants/WorkingDirectory/ExecStart/Restart + [Install] WantedBy=multi-user.target / default.target). The NON-AUTOSTARTING contract: units are INSTALLED but never ENABLED (no post-install enable script); the preset files /usr/lib/systemd/{system,user}-preset/50-charly.preset (disable charly-mcp.service) guarantee a distro that runs systemctl preset on install (Debian's dh_installsystemd) cannot auto-enable them.
    • /etc/charly/charly.yml — rendered from packaging.config to a minimal valid project (version + a charly-mcp candy node with the bake_plugin: refs + a no-op plan), so the systemd-started MCP server resolves a local project instead of a network fallback.
  2. loaderkit layered config stack (§3.5) — charly reads and MERGES charly.yml files in the order system → user → in-dir, later files winning. New loaderkit/config_stack.go:

    • system: /etc/charly/charly.yml (CHARLY_SYSTEM_CONFIG override); user: spec.DefaultDeployConfigPath() (~/.config/charly/charly.yml, per invoking user); in-dir: /charly.yml.
    • The merge happens at the RAW yaml.Node document level (top-level keys, later wins) — the raw round-trip preserves EVERY node. The typed spec.UnifiedFile parse DROPS the opaque candy bodies (json.RawMessage), proven empirically (a round-trip test shows candy=map[] after a typed parse) — the raw merge is the P1-correct implementation (any charly.yml must be capable of anything).
    • LoadUnified now feeds the merged bytes as the root document — the bootstrap phase, the early schema gate (on the merged, later-wins version), the kind-blind walk, and the validation chain all operate on the merged config. No layer at all → no project (unchanged).
  3. Tests — loaderkit/config_stack_test.go (later-wins, user-wins-over-system, version later-wins, no-project, candy-node preservation), packagekit/render_test.go (unit + config + preset rendering, format gating deb/rpm/archlinux vs apk/ipk), loaderkit/test_main_test.go (isolates the config stack for every LoadUnified test — the real per-host ~/.config/charly/charly.yml must not leak into merged docs).

How tested

go test ./... (FULL suite, from the worktree — all packages ok, exit 0):

ok  github.com/opencharly/sdk/loaderkit
ok  github.com/opencharly/sdk/packagekit
... (all 10 packages ok)

New tests, verbosely:

$ go test ./loaderkit/ -run 'TestConfigStack|TestMergeRaw' -v
=== RUN   TestConfigStack_LaterWins
--- PASS: TestConfigStack_LaterWins (0.00s)
=== RUN   TestConfigStack_UserWinsOverSystem
--- PASS: TestConfigStack_UserWinsOverSystem (0.00s)
=== RUN   TestConfigStack_VersionLaterWins
--- PASS: TestConfigStack_VersionLaterWins (0.00s)
=== RUN   TestConfigStack_NoProject
--- PASS: TestConfigStack_NoProject (0.00s)
=== RUN   TestMergeRaw_PreservesCandyNodes
--- PASS: TestMergeRaw_PreservesCandyNodes (0.00s)

$ go test ./packagekit/ -run 'TestBuildInfoSystemd|TestRender' -v
=== RUN   TestBuildInfoSystemdContents
--- PASS: TestBuildInfoSystemdContents (0.00s)
=== RUN   TestRenderSystemdUnit_NonAutostarting
--- PASS: TestRenderSystemdUnit_NonAutostarting (0.00s)
=== RUN   TestRenderConfig_ValidProject
--- PASS: TestRenderConfig_ValidProject (0.00s)

Empirical proof of the raw-merge necessity (P1): a typed yaml.Unmarshal into spec.UnifiedFile of a charly.yml with a candy node yields candy=map[] (the opaque json.RawMessage bodies do not decode) — the stack merge must operate at the raw yaml.Node level to preserve every node. The failing typed round-trip was demonstrated with a standalone repro before implementing the raw merge.

Rulebook compliance

  • R0 (skills first): git-workflow + go/SDD skills loaded before implementation; the change follows the plan (plan/charly-mcp-systemd-config.md §3.3 + §3.5).
  • R1 (RCA every anomaly): the raw-merge necessity was RCA'd — a typed UnifiedFile parse drops opaque candy nodes (empirically proven); the raw yaml.Node merge is the root fix, not a workaround.
  • R2 (finish the whole cutover): the renderer + the config stack are both in this PR (no deferred sibling); the charly repo re-pins this tag (the named batch).
  • R3 (no duplication): the raw merge is the ONE stack merge (config_stack.go); the renderer reuses the existing nfpm contents mechanism.
  • R4 (no workarounds): no sleeps/retries/hand-pins; the raw merge is a real implementation, not a suppression.
  • R4a (fix the product first): N/A — no documentation changed in this PR.
  • R5 (delete legacy): no legacy path removed (additive change).
  • R6 (git safety): worktree from origin/main; no force-push, no direct push to main; the feat/ branch lands via PR.
  • R7 (prove behavior, not compilation): the new tests fail without the change (later-wins merge, non-autostarting render, format gating); the full suite is green.
  • R8 (preserve emitted artifacts): the rendered unit/config/preset bodies are asserted byte-level in the render tests.
  • R9 (binary equals source): N/A — no binary built in this PR (library code + tests).
  • R10 (fresh disposable proof): the full go test ./... ran from the committed worktree tree; the change class is code — the R10 bed gate (the CachyOS VM bed, check-cachyos-mcp-vm) runs in the named batch (the charly re-pin PR).
  • RDD: N/A — no high-risk runtime assumption beyond the empirically-proven raw merge.
  • ADE: N/A — no candy plan changed.
  • SDD: the spec schema (v0.2026250.632) is the single source; this PR consumes the generated types (no hand-transcribed wire structs).
  • Clean Architecture: the renderer lives in packagekit (the nFPM surface); the stack lives in loaderkit (the load surface) — no misplaced behavior.
  • Kernel/plugin boundary: N/A — sdk module, no kernel/plugin placement.
  • Disposable-Only Autonomy: N/A — no autonomous mutation of targets.
  • Hard Cutover: the LoadUnified change is additive (missing layers → pre-stack behavior); no cutover.
  • Post-Execution Policies: PR-only landing, feat/ branch, validator-gated; no self-merge.
  • AI Attribution: footer present below.

Change classification

  • Change class: code (new renderer + layered config-stack merge in the sdk, consuming the spec's new Packaging fields; additive — the pre-stack behavior is preserved when no system/user layer exists).
  • Verification gate: full go test ./... green on the final committed tree; targeted render + stack tests.
  • Attribution tier: fully tested and validated (full suite green on the final tree; the changed paths' unit tests pass).

Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)

…ive packages; layered config stack (system → user → in-dir, later wins)
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 7bcd2d9d5bff7ea65a950ad947571d84494d54ee

Security screen: PASS — no scope mismatch (all 10 diff files accounted for in the body), no secrets/exfiltration, no weakened guardrails, no unexpected network calls; the spec bump (v0.2026250.523 → v0.2026250.632) is a legitimate dependency pin to consume the new Packaging schema, with consistent go.sum entries.

Checklist: All applicable rules PASS or NA.

  • Change class: code (new packagekit systemd/config renderer + loaderkit layered config stack, additive). Body supplies full-suite + targeted test evidence with pasted output; the R10 bed gate (check-cachyos-mcp-vm) is routed to the NAMED batch (the charly re-pin PR) — legitimate given the sdk is a library whose runtime proof requires the charly consumer re-pin, and the new unit tests prove the changed behavior (would fail without the change).
  • Attribution tier: fully tested and validated justified — the new code paths (config-stack merge, systemd render, format gating) execute in the passing unit tests; footer present in the exact required form.
  • R0–R10: RCA provided for the raw-merge necessity (typed UnifiedFile parse drops opaque candy nodes, empirically proven); no duplication (single stack merge, reuses nfpm contents); no workarounds; additive (no legacy path); rendered bodies asserted byte-level; no warnings in pasted output.
  • SDD: consumes generated spec types; packagedConfigDoc is an output-rendering struct (not hand-parsed authored input), no banned patterns.
  • Architecture gate: placement: CORRECT — systemd/config rendering in packagekit (the nFPM surface), config stack in loaderkit (the load surface); no core/sdk/candy misplacement, no alias files, no new core imports of sdk kits.
  • Quality: no gofmt/lint issues visible in the diff; one atomic commit; no comment-thread findings (thread empty).

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 7, 2026 06:50
@github-actions
github-actions Bot merged commit 92c2d23 into main Sep 7, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 7, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 22, 2026
…er (#270)

* fix(loaderkit): the per-host deploy overlay is not a config-stack layer

The layered config stack (system → user → in-dir) raw-merged the per-host
deploy overlay (~/.config/charly/charly.yml, spec.DefaultDeployConfigPath)
as a PROJECT document layer. That overlay is a DeployConfig — per-host
runtime state, not an authored project — and raw-merging it injects its
deploy entries into the authored deploy map BEFORE FoldMembers runs.

A member-bearing check bed declares its members NESTED under the bed root,
while the overlay persists each deploy-level member FLATTENED to a top-level
key (MarshalDeployNode unwraps the member tree to siblings, so a member's own
`charly config` can address it by name). Raw-merging put both copies into the
deploy map, and FoldMembers then hard-failed:

  peer name "preempt-holder" (declared under deploy "check-preempt-live-pod")
  collides with an existing deploy/bed/peer entry

seen live on every member-bearing bed (check-preempt-live-pod, check-cross-pod-cdp,
both FAIL steps=1) and reproducible deterministically from the merged bytes alone.

The overlay has ALWAYS been applied the correct way: a per-field MERGE onto the
loaded project tree (deploykit.MergeDeployConfigs / deploy.MergeDeployNode, driven
by loaderkit.ResolveMergedTreeViaExecutor and deploykit.MergedDeployTree), whose
lookup recurses into a node's Member tree, so it can never create a stray top-level
key. That merge remains the overlay's ONE application (R3). This stack is projects
only: system (/etc/charly/charly.yml, the packaged fallback project) + in-dir.

Regression window: the beds were green at distro-fedora #49 (charly 2026.250.0215)
the same day sdk #230 landed the stack; the fold's collision guard predates both.

R10 (live, charly rebuilt against this sdk):
- check-preempt-live-pod: PASS (steps=22) (was FAIL steps=1)
- check-cross-pod-cdp:    PASS (steps=19) (was FAIL steps=1)

Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

* docs: re-freeze the PR body against the final head

* docs: re-freeze the PR body against the final head

---------

Co-authored-by: Andreas Trawoeger <[email protected]>
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.

1 participant