Gestion des approbations

VérifiéSûr

Implémente un workflow d'approbation humain-dans-la-boucle pour les actions sensibles, garantissant la conformité avant exécution.

Spar Skills Guide Bot
SecuriteIntermédiaire
24/07/2026
Claude Code
#human-in-the-loop#approval-workflow#audit-logging#desktop-notifications#compliance

Recommandé pour

Synthèse automatique

Ce skill met en place un circuit de validation humaine (HITL) qui bloque les actions sensibles — envoi d'e-mails, publications LinkedIn, paiements, suppression de fichiers, appels API — jusqu'à ce qu'un utilisateur les approuve explicitement.

Points forts

  • Classe les actions en sensibles ou non via un fichier approval_rules.yaml éditable, avec délais d'expiration par type d'action
  • Matérialise chaque demande dans un dossier Pending_Approval avec un frontmatter YAML que l'utilisateur modifie pour approuver ou rejeter
  • Envoie des notifications bureau et journalise toutes les décisions et résultats d'exécution pour l'audit
  • Exécute l'action approuvée avec logique de retry et gestion d'erreurs, et conserve la raison en cas de rejet

Limites

  • L'approbation repose sur une édition manuelle du frontmatter YAML : pas d'interface de validation dédiée
  • Le polling des réponses et les notifications sont liés à un vault local et à des notifications système, ce qui suppose un environnement de bureau
  • Le extrait fourni s'arrête au milieu de check_approval_status, donc certaines parties de l'API restent à vérifier
Quand l'utiliser

À utiliser lorsqu'un agent doit effectuer des actions à impact externe ou irréversibles et qu'une validation humaine explicite est exigée avant exécution.

Quand l'éviter

À éviter pour des opérations de lecture seule ou des tâches entièrement automatisées où un blocage par approbation ferait perdre du temps sans bénéfice de conformité.

Analyse de sécurité

Sûr
Score qualité78/100

The skill describes a human-in-the-loop approval workflow with code snippets and configuration examples, but does not contain direct instructions to execute destructive, exfiltrating, or obfuscated actions. It does not declare or use any tools that would perform network, shell, or file operations beyond conceptual Python code. The content is instructional and focused on implementing approval mechanisms, not on executing sensitive actions autonomously.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Gate an outbound email
Draft and send the project update email to client@example.com, but create an approval request first so I can review it before it goes out.
Review pending approvals
Check the Pending_Approval folder and tell me which approval requests are still waiting, then execute any that I've marked as approved.
Configure sensitive actions
Add delete_file and api_call to the sensitive actions in approval_rules.yaml with a 60-minute timeout, and confirm emails and LinkedIn posts can never be auto-approved.

Manage Approvals Skill

Skill ID: manage-approvals Version: 1.0.0 User Story: US2 - Human-in-the-Loop Approval Workflow Priority: P1 (MVP)

Purpose

Implement human-in-the-loop (HITL) approval workflow for sensitive actions. This skill ensures 100% compliance with the constitution requirement that all sensitive actions (emails, posts, payments) require explicit human approval before execution.

Capabilities

  • Approval Request Creation: Create structured approval requests in Pending_Approval folder
  • Approval Status Checking: Poll for user responses (Approved/Rejected)
  • Desktop Notifications: Notify user of pending approvals using system notifications
  • Action Execution: Execute approved actions with retry logic and error handling
  • Audit Logging: Log all approval decisions and action results

Architecture

Core Components

  1. ApprovalManager (silver/src/approval/approval_manager.py)

    • create_approval_request(action_type, action_details, risk_assessment) → request_id
    • is_sensitive_action(action_type) → bool
    • execute_approved_action(request_id) → result
  2. ApprovalChecker (silver/src/approval/approval_checker.py)

    • poll_for_approvals() → List[ApprovalRequest]
    • check_approval_status(request_id) → status (pending/approved/rejected)
  3. ApprovalNotifier (silver/src/approval/approval_notifier.py)

    • send_notification(title, message, urgency) → success

Approval Workflow

1. Action Detected → Is Sensitive? → Yes → Create Approval Request
                                   → No → Execute Directly

2. Approval Request Created → Move to Pending_Approval/
                           → Send Desktop Notification
                           → Poll for User Response

3. User Reviews → Edit YAML frontmatter → Set status: approved/rejected
                                        → Add reason (if rejected)

4. Status Detected → Approved → Move to Approved/ → Execute Action
                  → Rejected → Move to Rejected/ → Log Reason

Configuration

Approval Rules (silver/config/approval_rules.yaml)

sensitive_actions:
  # Email sending
  - action_type: send_email
    requires_approval: true
    auto_approve_threshold: null  # Never auto-approve
    timeout_minutes: 1440  # 24 hours

  # LinkedIn posting
  - action_type: post_linkedin
    requires_approval: true
    auto_approve_threshold: null
    timeout_minutes: 1440

  # File operations
  - action_type: delete_file
    requires_approval: true
    auto_approve_threshold: null
    timeout_minutes: 60

  # External API calls
  - action_type: api_call
    requires_approval: true
    auto_approve_threshold: null
    timeout_minutes: 120

non_sensitive_actions:
  # Read-only operations
  - action_type: read_file
    requires_approval: false

  - action_type: search_vault
    requires_approval: false

  - action_type: create_plan
    requires_approval: false

notification_settings:
  enabled: true
  urgency: normal  # low, normal, critical
  sound: true
  desktop: true

Usage

Create Approval Request

from silver.src.approval.approval_manager import ApprovalManager

manager = ApprovalManager(vault_path="/path/to/vault")

# Create approval request for email sending
request_id = manager.create_approval_request(
    action_type="send_email",
    action_details={
        "to": "client@example.com",
        "subject": "Project Update",
        "body": "Here's the latest update...",
        "attachments": []
    },
    risk_assessment={
        "sensitivity": "high",
        "reversible": False,
        "impact": "external_communication"
    }
)

print(f"Approval request created: {request_id}")
# Desktop notification sent to user

Check Approval Status

from silver.src.approval.approval_checker import ApprovalChecker

checker = ApprovalChecker(vault_path="/path/to/vault")

# Check status of specific request
status = checker.check_approval_status(request_id)

if status["status"] == "approved":
    print("Action approved by user")
    # Execute action
elif status["status"] == "rejected":
    print(f"Action rejected: {status['reason']}")
    # Log rejection
else:
    print("Still pending approval")

Execute Approved Action

# Execute action with retry logic
result = manager.execute_approved_action(request_id)

if result["success"]:
    print(f"Action executed successfully: {result['message_id']}")
else:
    print(f"Action failed: {result['error']}")
    # Retry logic: max 3 attempts, exponential backoff (2s, 4s, 8s)

Output Format

Approval Request File

Created in Pending_Approval/ folder:

---
id: approval_20260113_103045_abc123
action_type: send_email
status: pending
created_at: 2026-01-13T10:30:45Z
timeout_at: 2026-01-14T10:30:45Z
risk_level: high
---

# Approval Request: Send Email

**Action**: Send Email
**Status**: ⏳ Pending Approval
**Created**: 2026-01-13 10:30 AM
**Timeout**: 2026-01-14 10:30 AM (24 hours)

## Action Details

- **To**: client@example.com
- **Subject**: Project Update
- **Body Preview**: Here's the latest update...
- **Attachments**: None

## Risk Assessment

- **Sensitivity**: High
- **Reversible**: No
- **Impact**: External Communication
- **Consequences**: Email will be sent to external recipient

## Instructions

To approve this action:
1. Change `status: pending` to `status: approved` in the YAML frontmatter above
2. Save the file
3. The action will execute automatically within 1 minute

To reject this action:
1. Change `status: pending` to `status: rejected` in the YAML frontmatter above
2. Add `rejection_reason: "Your reason here"` to the YAML frontmatter
3. Save the file
4. The action will be cancelled

## Timeout

If no response within 24 hours, this request will expire and the action will be cancelled.

After Approval

File moves to Approved/ folder with updated frontmatter:

---
id: approval_20260113_103045_abc123
action_type: send_email
status: approved
created_at: 2026-01-13T10:30:45Z
approved_at: 2026-01-13T10:35:12Z
executed_at: 2026-01-13T10:35:15Z
execution_result: success
message_id: <abc123@smtp.gmail.com>
---

After Rejection

File moves to Rejected/ folder with rejection reason:

---
id: approval_20260113_103045_abc123
action_type: send_email
status: rejected
created_at: 2026-01-13T10:30:45Z
rejected_at: 2026-01-13T10:35:12Z
rejection_reason: "Not ready to send yet, need to review content first"
---

Dependencies

Python Packages

[tool.poetry.dependencies]
plyer = "^2.1.0"  # Desktop notifications
pyyaml = "^6.0.1"
python-dotenv = "^1.0.0"
watchdog = "^4.0.0"  # File system monitoring (optional)

System Requirements

  • Python 3.13+
  • Desktop notification support (Linux: libnotify, Windows: native, macOS: native)

Setup Instructions

1. Configure Approval Rules

# Edit approval rules
nano silver/config/approval_rules.yaml

# Customize sensitive actions, timeouts, notification settings

2. Create Vault Folders

# Create approval folders
mkdir -p Pending_Approval Approved Rejected

# Verify folders exist
ls -la | grep -E "Pending_Approval|Approved|Rejected"

3. Test Notifications

# Test desktop notifications
python silver/scripts/test_approval.py --test-notification

# Should see desktop notification appear

4. Start Approval Checker

# Start approval checker (polls every 10 seconds)
python -m silver.src.approval.approval_checker &

# Or use startup script
./silver/scripts/start_watchers.sh

Error Handling

Timeout Handling

  • Default timeout: 24 hours for most actions
  • Expired requests: Automatically moved to Rejected/ with reason "Timeout"
  • Notification: User notified 1 hour before timeout

File System Errors

  • Permission denied: Log error, notify user
  • File not found: Assume request was manually deleted, skip
  • Invalid YAML: Notify user, keep in Pending_Approval/

Notification Errors

  • Notification failed: Log error, continue (user can still check folder manually)
  • No notification support: Graceful degradation (file-based only)

Performance

  • Polling interval: 10 seconds (configurable)
  • Memory: ~20MB per checker process
  • CPU: Minimal (<1% on modern systems)
  • Disk I/O: Low (only reads changed files)

Testing

Unit Tests

pytest silver/tests/unit/test_approval_manager.py
pytest silver/tests/unit/test_approval_checker.py
pytest silver/tests/unit/test_approval_notifier.py

Integration Tests

pytest silver/tests/integration/test_approval_workflow.py

Manual Testing

  1. Create test approval request:

    python silver/scripts/test_approval.py --create-test-request
    
  2. Verify desktop notification appears

  3. Open Pending_Approval/ folder and find the request file

  4. Edit YAML frontmatter: change status: pending to status: approved

  5. Save file

  6. Verify file moves to Approved/ within 10 seconds

  7. Check audit log in Logs/YYYY-MM-DD.json

Success Criteria

  • ✅ 100% approval compliance for sensitive actions
  • ✅ Desktop notifications delivered within 1 second
  • ✅ Approval status detected within 10 seconds
  • ✅ Approved actions executed within 1 minute
  • ✅ Audit log entry created for every approval decision
  • ✅ Graceful handling of timeouts and errors

Related Skills

  • monitor-communications: Creates action files that may require approval
  • execute-actions: Executes approved actions via MCP server
  • create-plans: Plans may include actions requiring approval

References

  • See references/approval_rules.md for detailed approval rule configuration
  • See references/notification_api.md for desktop notification API details

Examples

  • See examples/approval_request_example.md for approval request format
  • See examples/approved_action_example.md for approved action format
  • See examples/rejected_action_example.md for rejected action format

Changelog

  • 1.0.0 (2026-01-13): Initial implementation for Silver tier MVP

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/manage-approvals-mryiqhvi/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/manage-approvals-mryiqhvi' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/manage-approvals-mryiqhvi/download' --output '.skill-downloads/manage-approvals-mryiqhvi/SKILL.md.part' && mv '.skill-downloads/manage-approvals-mryiqhvi/SKILL.md.part' '.skill-downloads/manage-approvals-mryiqhvi/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Extrait original : Dependencies

Python Packages

[tool.poetry.dependencies]
plyer = "^2.1.0"  # Desktop notifications
pyyaml = "^6.0.1"
python-dotenv = "^1.0.0"
watchdog = "^4.0.0"  # File system monitoring (optional)

System Requirements

  • Python 3.13+
  • Desktop notification support (Linux: libnotify, Windows: native, macOS: native)

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Le fichier ne fournit pas un en-tête name/description exploitable pour cette procédure native. Le téléchargement reste disponible pour lecture ; utilisez le mode manuel ci-dessous.

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/manage-approvals-mryiqhvi/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires