Skip to content

Registry + securityContext hardening hygiene (post-archetype consolidation) - #16

Merged
pdettori merged 7 commits into
mainfrom
chore/registry-hardening
Jun 29, 2026
Merged

pdettori merged 7 commits into
mainfrom
chore/registry-hardening

Conversation

@pdettori

Copy link
Copy Markdown
Member

Summary

Post-archetype consolidation/hardening bundle (no runtime behavior change to runLeaf, the gate, the contract, the queue, or KEDA scaling).

  1. Registry (docs/specs/README.md): a new "Leaf-Session Backend (BUILT)" section recording the work that shipped but was unregistered — MVP contract (Task 6: gated Kind smoke for the leaf-session contract + live-path fixes #10/Gate 7: resumable leaf sessions (crash mid-run → resume → verdict) #11), async (feat: async leaf completion (KEDA ScaledJob + Redis Streams work queue) #12), cron (feat: scheduled leaf dispatch (Archetype C cron trigger on-ramp) #13), human-gate (Add human-gate (gate-while-idle, Archetype B) to the leaf-session backend #14).
  2. server.ts entrypoint idiom: replaced the fragile process.argv[1].includes("knative-server") guard with the exact process.argv[1] === fileURLToPath(import.meta.url) (matches cron-dispatch.ts). No auto-start regression (server suite green).
  3. securityContext hardening on the leaf-worker ScaledJob + the Knative service (both previously ran as root with default caps): pod-level runAsNonRoot/runAsUser 65532/fsGroup 65532/seccomp RuntimeDefault; container-level allowPrivilegeEscalation:false/readOnlyRootFilesystem:true/drop ["ALL"]; HOME=/tmp + writable /tmp emptyDir; kubernetes.podspec-securitycontext feature flag in setup-kind.sh.

Live-verification finding (documented): a non-root harness (uid 65532) can't write a /work results dir created by a root orchestrator (fsGroup doesn't cover cross-writer dirs). Since the orchestrator owns /work (charter G3), it must provision result dirs writable by the harness uid; the smoke models this with chmod 0777 on its run dir, and the spec records the production contract (group-write under shared fsGroup 65532).

Verification

  • Unit: @sh/harness 119 passed (2 skipped), @sh/knative-server 29 passed.
  • Live gate (leaf-gate-smoke.sh) all 6 claims PASS under a confirmed hardened pod (runAsUser=65532, fsGroup=65532, readOnlyRootFilesystem=true, drop ALL), including kubectl exec into sandbox-0 and the full pause/scale-to-zero/approve/idempotent/reject-with-re-gate/abort flow. readOnlyRootFilesystem: true held on both pods (no fallback needed).

Deferred follow-up (non-blocking)

Operator-runbook entry for non-root deployments (production guidance: group-write under fsGroup 65532, not chmod 0777). Reclaimer-churn tuning remains deferred (no observed symptom).

Assisted-By: Claude Code

Paolo Dettori added 7 commits June 28, 2026 19:13
Post-archetype consolidation bundle: (1) register the built
leaf-session backend track (MVP + 3 archetypes) in the milestone
registry; (2) align server.ts isMainModule to the exact fileURLToPath
idiom; (3) apply the cron-dispatch securityContext baseline (non-root,
runAsUser 65532, seccomp, no-priv-esc, drop caps, readOnlyRootFilesystem
attempted) to the leaf-worker ScaledJob + Knative service, decided
empirically via the live gate smoke. Defers reclaimer-churn tuning.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
…asks)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
…rop caps, read-only rootfs)

Signed-off-by: Paolo Dettori <[email protected]>
With the leaf-worker hardened to uid 65532, runLeaf hit EACCES writing
the gate marker into a results dir the smoke's orchestrator pod created
as root. fsGroup makes the harness's own writes group-owned but does not
make a root-created dir group-writable. The orchestrator owns /work
(charter G3), so it must provision result dirs writable by the harness
uid; the smoke models this with chmod 0777 on the run dir. Documented
the operational contract in the spec. Agent ran cleanly under the
hardened context; only cross-writer /work ownership needed coordination.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Final-review nit: leaf-job.ts calls main() unconditionally (script-only,
never imported), so only cron-dispatch.ts shares the fileURLToPath idiom.
Comment-only; no runtime change.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review (automated) — Clean consolidation/hardening bundle. The three changes are independent and well-scoped:

  1. Registry docs for the built leaf-session backend track (MVP + 3 archetypes) — previously shipped but unregistered.
  2. server.ts entrypoint guard aligned to the canonical fileURLToPath(import.meta.url) pattern (matches cron-dispatch.ts).
  3. securityContext hardening on both the leaf-worker ScaledJob and Knative service — non-root (uid 65532), seccomp RuntimeDefault, drop ALL caps, read-only rootfs, fsGroup 65532.

All 7 commits DCO-signed. Live gate smoke confirms 6/6 claims pass under the hardened context. The chmod 0777 in the smoke is an acknowledged stopgap (production contract: group-write under shared fsGroup).

Reviewed: TypeScript, K8s/YAML, Shell, Docs. No security, convention, or correctness issues found.

Verdict: would APPROVE if not own PR.

@pdettori
pdettori merged commit de7a817 into main Jun 29, 2026
1 check passed
@pdettori
pdettori deleted the chore/registry-hardening branch June 29, 2026 02:17
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