WIP: fix: harden kan-ductor agent safety gates #60

Closed
glm wants to merge 0 commits from glm/codex-kan-ductor-stabilization into main AGit
First-time contributor

Canary status: missing - fire 3+3 review before merge

Summary

Hardens the Kan-ductor maintainer layer after the Piotr + Iskra MCP smoke loop started working. This PR focuses on safety gates, audit truth, recap reliability, MCP readiness probes, and maintainer tooling.

Scope

  • Adds projection:write and projection:override_warnings scopes.
  • Adds server-side KAN_PROJECTION_APPLY_ENABLED=false default for real Leviathan apply.
  • Blocks projection writes with security/gate warnings unless explicitly overridden.
  • Stores and reads exact audit/activity lineage through activityPublicId for create/move/comment/relation actions.
  • Adds low-confidence fallback labeling for old time-window audit matching.
  • Redacts default human audit reads; raw payloads require includeRaw=true and workspace:manage.
  • Adds getRecentActivity.summary for Piotr/Iskra recap questions.
  • Adds /live, /ready, and readiness-compatible /health to MCP.
  • Adds relation activity enum values and relation activity creation.
  • Adds dry-run-first machine identity maintainer CLI.
  • Captures durable BMAD context in _bmad-output/project-context.md.

Non-goals

  • No production deploy.
  • No production DB migration.
  • No production token issuance or rotation.
  • No KAN_PROJECTION_APPLY_ENABLED=true in production.
  • No autonomous drift repair.
  • No analytics dashboard or full UI polish.

Spec sources read

  • docs/agent-mcp-contract.md
  • docs/leviathan-projection-contract.md
  • docs/openclaw-kan-mcp.md
  • _bmad-output/project-context.md
  • Stabilization issues: #5, #6, #53-#59 via meta #2 context

Tests / smoke

Run locally:

pnpm --filter @kan/api typecheck
pnpm --filter @kan/db typecheck
pnpm --filter @kan/mcp typecheck
pnpm --filter @kan/api test -- agent.test.ts
pnpm --filter @kan/mcp test -- health.test.ts
pnpm --filter @kan/api exec eslint src/routers/agent.ts src/routers/agent.test.ts
pnpm --filter @kan/db exec eslint src/repository/agent.repo.ts src/repository/card.repo.ts src/repository/cardActivity.repo.ts src/repository/cardRelation.repo.ts src/schema/cards.ts
node --check scripts/kan-machine-identity-admin.mjs
git diff --check

Known repo-level lint caveats:

  • Full @kan/api lint still reports pre-existing lint debt outside this PR scope.
  • @kan/db lint still reports pre-existing lint debt outside this PR scope.
  • @kan/mcp lint currently lacks an eslint flat config in that package.

Rollback

  • Revert this PR.
  • Do not run the new migration in production if rollback is needed before deploy.
  • Keep KAN_PROJECTION_APPLY_ENABLED=false.
  • Do not issue or rotate production machine credentials from the new CLI.

Owner gates

Piotr approval required before:

  • merge,
  • production DB migration,
  • production deploy/restart,
  • enabling KAN_PROJECTION_APPLY_ENABLED=true,
  • issuing/rotating/revoking production machine credentials,
  • expanding trust boundary or public exposure,
  • treating low-confidence old audit matching as authoritative.

3+3 review request

Required before merge because this PR touches auth scopes, write gates, audit redaction, MCP readiness, schema enum migration, and drift/lineage semantics.

Canary status: missing - fire 3+3 review before merge ## Summary Hardens the Kan-ductor maintainer layer after the Piotr + Iskra MCP smoke loop started working. This PR focuses on safety gates, audit truth, recap reliability, MCP readiness probes, and maintainer tooling. ## Scope - Adds `projection:write` and `projection:override_warnings` scopes. - Adds server-side `KAN_PROJECTION_APPLY_ENABLED=false` default for real Leviathan apply. - Blocks projection writes with security/gate warnings unless explicitly overridden. - Stores and reads exact audit/activity lineage through `activityPublicId` for create/move/comment/relation actions. - Adds low-confidence fallback labeling for old time-window audit matching. - Redacts default human audit reads; raw payloads require `includeRaw=true` and `workspace:manage`. - Adds `getRecentActivity.summary` for Piotr/Iskra recap questions. - Adds `/live`, `/ready`, and readiness-compatible `/health` to MCP. - Adds relation activity enum values and relation activity creation. - Adds dry-run-first machine identity maintainer CLI. - Captures durable BMAD context in `_bmad-output/project-context.md`. ## Non-goals - No production deploy. - No production DB migration. - No production token issuance or rotation. - No `KAN_PROJECTION_APPLY_ENABLED=true` in production. - No autonomous drift repair. - No analytics dashboard or full UI polish. ## Spec sources read - `docs/agent-mcp-contract.md` - `docs/leviathan-projection-contract.md` - `docs/openclaw-kan-mcp.md` - `_bmad-output/project-context.md` - Stabilization issues: #5, #6, #53-#59 via meta #2 context ## Tests / smoke Run locally: ```bash pnpm --filter @kan/api typecheck pnpm --filter @kan/db typecheck pnpm --filter @kan/mcp typecheck pnpm --filter @kan/api test -- agent.test.ts pnpm --filter @kan/mcp test -- health.test.ts pnpm --filter @kan/api exec eslint src/routers/agent.ts src/routers/agent.test.ts pnpm --filter @kan/db exec eslint src/repository/agent.repo.ts src/repository/card.repo.ts src/repository/cardActivity.repo.ts src/repository/cardRelation.repo.ts src/schema/cards.ts node --check scripts/kan-machine-identity-admin.mjs git diff --check ``` Known repo-level lint caveats: - Full `@kan/api lint` still reports pre-existing lint debt outside this PR scope. - `@kan/db lint` still reports pre-existing lint debt outside this PR scope. - `@kan/mcp lint` currently lacks an eslint flat config in that package. ## Rollback - Revert this PR. - Do not run the new migration in production if rollback is needed before deploy. - Keep `KAN_PROJECTION_APPLY_ENABLED=false`. - Do not issue or rotate production machine credentials from the new CLI. ## Owner gates Piotr approval required before: - merge, - production DB migration, - production deploy/restart, - enabling `KAN_PROJECTION_APPLY_ENABLED=true`, - issuing/rotating/revoking production machine credentials, - expanding trust boundary or public exposure, - treating low-confidence old audit matching as authoritative. ## 3+3 review request Required before merge because this PR touches auth scopes, write gates, audit redaction, MCP readiness, schema enum migration, and drift/lineage semantics.
fix: harden kan-ductor agent safety gates
Some checks failed
Forgejo CI / verify (pull_request) Successful in 10m28s
Forgejo Docker Images / build (pull_request) Failing after 6s
fa443e8874
glm changed title from fix: harden kan-ductor agent safety gates to WIP: fix: harden kan-ductor agent safety gates 2026-05-15 19:32:23 +02:00
Collaborator

Closing as superseded by #61. This PR was accidentally created through the GLM Forgejo identity; per agent-souls identity discipline, the Codex-owned PR is #61.

Closing as superseded by #61. This PR was accidentally created through the GLM Forgejo identity; per agent-souls identity discipline, the Codex-owned PR is #61.
codex closed this pull request 2026-05-15 19:38:10 +02:00
Some checks failed
Forgejo CI / verify (pull_request) Successful in 10m28s
Forgejo Docker Images / build (pull_request) Failing after 6s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
3plus3-followup
agent/claude-code
agent/codex
agent/hermes
agent/iskra
agent/ollama
agent/patchwarden
analytics
api
cockpit
dependency/blocked
dependency/blocks-others
dependency/cross-repo
dependency/needs-confirmation
docs
domain:agents
domain:ci
domain:docs
domain:forgejo
domain:infra
domain:memory
domain:runtime
domain:signal
domain:ux
flow/architecture
flow/blocked
flow/deployed
flow/done
flow/implementation
flow/intake
flow/maintained
flow/observed
flow/ready
flow/refining
flow/retired
flow/review
gemini-flash
judge/codex-candidate
judge/hermes-candidate
judge/low-confidence
judge/needs-refinement
judge/operator-needed
judge/p0
judge/p1
judge/p2
judge/p3
judge/park
judge/patchwarden-candidate
judge/stale-priority
kind/adr
kind/bug
kind/chore
kind/feature
kind/infra
kind/ops
kind/refactor
kind/research
leviathan
mcp
merge/auto
merge/manual
merge/manual-dependency-conflict
merge/manual-failing-tests
merge/manual-merge-conflict
merge/manual-missing-review
merge/manual-operator-preference
merge/manual-red-zone
merge/manual-security-sensitive
merge/manual-unclear-scope
merge/manual-unknown
mode:operator-only
mode:patchwarden-iskra-approved
mode:safe-auto
observed/erroring
observed/needs-followup
observed/pending
observed/retire-candidate
observed/unused
observed/used
ops
priority:p0
priority:p1
priority:p2
priority:p3
review:claude-reviewed
review:codex-reviewed
review:dziadek-reviewed
review:needs-human
safety
safety:external-write
safety:no-prod-mutation
safety:prod-impact
safety:secret-touch
scout
security
size/large
size/medium
size/small
size/tiny
size/unknown
small-task
source/adr
source/agent-generated
source/manual
source/operator-chat
source/voice-note
status:blocked
status:codex-ready
status:merged:pending-evidence
status:needs-evidence
status:operator-needed
status:parked
tests
tier:0-platform-substrate
tier:1-iskra-value-layer
tier:2-tools-products-modules
type:bug
type:chore
type:docs
type:feat
type:policy
type:research
ui
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pdurlej/kan-ductor!60
No description provided.