# AutoSnippet Constitution
version: "3.0"
effective_date: "2026-02-13"

capabilities:
  git_write:
    description: "subrepo git push"
    probe: "git push --dry-run"
    no_subrepo: "allow"
    no_remote: "allow"
    cache_ttl: 86400

rules:
  - id: "destructive_confirm"
    description: "delete needs confirmation"
    check: "destructive_needs_confirmation"
  - id: "content_required"
    description: "create candidate/recipe needs content"
    check: "creation_needs_content"
  - id: "ai_no_direct_recipe"
    description: "AI cannot directly create/approve recipe"
    check: "ai_cannot_approve_recipe"
  - id: "batch_authorized"
    description: "batch ops need authorization"
    check: "batch_needs_authorization"

roles:
  - id: "external_agent"
    name: "External Agent"
    description: "IDE AI agent (Cursor / Copilot / Claude Code)"
    permissions:
      - "read:recipes"
      - "read:guard_rules"
      - "guard_rule:check_code"
      - "create:candidates"
      - "candidate:update"
      - "knowledge:create"
      - "knowledge:update"
      - "knowledge:evolve"
      - "submit:knowledge"
      - "read:audit_logs:self"
      - "knowledge:bootstrap"
      - "task:create"
      - "task:update"
      - "create:skills"
      - "update:skills"
      - "delete:skills"
    constraints:
      - "can submit knowledge entries (all go to pending)"
      - "can create evolution proposals (merge/enhance/deprecate — system auto-executes)"
      - "cannot publish/deprecate knowledge — only developer can do that"
      - "can reactivate deprecated entries back to pending"
      - "cannot modify Guard rules"
      - "cannot delete any data"
  - id: "chat_agent"
    name: "ChatAgent"
    description: "built-in AI agent (Dashboard chat / programmatic)"
    permissions:
      - "read:recipes"
      - "read:candidates"
      - "create:candidates"
      - "read:guard_rules"
    constraints:
      - "candidate must include reasoning"
      - "cannot bypass Guard check"
  - id: "contributor"
    name: "Contributor"
    description: "有子仓库但无 push 权限的团队成员（只读）"
    permissions:
      - "read:recipes"
      - "read:candidates"
      - "read:guard_rules"
      - "read:audit_logs:self"
    constraints:
      - "不能创建/修改 Recipe（无子仓库写权限）"
      - "不能修改 Guard 规则"
  - id: "visitor"
    name: "Visitor"
    description: "严格模式下的最小权限访客"
    permissions:
      - "read:recipes"
      - "read:guard_rules"
    constraints:
      - "仅可读取，不能执行任何写操作"
  - id: "developer"
    name: "Developer"
    description: "project owner, full access"
    permissions:
      - "*"
    requires_capability:
      - "git_write"
