Skill: sunrisesillneversee/moses-stamp (version 1.0.0)

--- name: moses-stamp description: "MO§ES™ Governed Output — embeds a governance stamp into every document produced. Mode, posture, session ID, and cryptographic integrity hash stamped on output. The document is the audit record. Part of the moses-governance bundle. Patent pending Serial No. 63/877,177." metadata: openclaw: emoji: 🪙 tags: [stamp, governed-output, audit, provenance, document-governance] version: 0.1.0 bins: - python3 stateDirs: - ~/.openclaw/governance example: | # Generate a stamp python3 scripts/stamp.py generate --mode "High Security" --posture "DEFENSE" --role "Primary" # Append stamp to a document python3 scripts/stamp.py append --file report.md --mode "High Security" --posture "DEFENSE" requires: - metadata.openclaw --- # MO§ES™ Governed Output When this skill is active, every document you produce carries an embedded governance stamp. The stamp is not a separate log — it lives inside the artifact. The document is the audit record. **Enforcement is automatic.** You do not wait to be asked. After producing any qualifying document, append the stamp. --- ## Activation When `moses-stamp` is installed and active, governed output is on by default. Confirm at session start: ``` ✓ Governed output active Every document produced this session will be stamped with: — Active governance mode — Active posture — Session ID — Action sequence number — Integrity hash (SHA-256 of content + governance state) The output is the audit record. ``` --- ## Stamp Tool Call `stamp.py generate` to produce the stamp block, then append it to your output: ```bash python3 scripts/stamp.py generate \ --mode "$(python3 skills/moses-governance/scripts/init_state.py get mode)" \ --posture "$(python3 skills/moses-governance/scripts/init_state.py get posture)" \ --role "$(python3 skills/moses-governance/scripts/init_state.py get role)" ``` Or append directly to a file: ```bash python3 scripts/stamp.py append --file <output_file.md> ``` --- ## Stamp Format ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ MO§ES™ GOVERNANCE STAMP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Produced under: MO§ES™ Governance Framework Mode: [active mode, or Unrestricted if none set] Posture: [active posture, or None] Role: [active role, or Primary] Session ID: [first 8 chars of SHA-256 of session start timestamp] Action #: [sequential count of stamped outputs this session] Integrity hash: [SHA-256 of: content[:64] + mode + posture + action#] Runtime: ClawHub (cryptographic) © 2026 Ello Cello LLC — MO§ES™ is trademark pending ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` --- ## What Counts as a Document Stamp these: - Reports, memos, plans, specs, briefs - Emails drafted at user request - Code files produced as a primary deliverable - Any artifact intended for use outside this conversation Do NOT stamp: - Inline answers, clarifications, short explanations - Intermediate reasoning steps - Tool call outputs --- ## Relationship to the Audit Chain The stamp is document-level provenance. The audit chain (`moses-audit`) is action-level provenance. Both can be active simultaneously — they record different things. When both are active, log the action first (`audit_stub.py log`), then append the stamp to the document. --- ## Deactivation To deactivate for a session: set an environment variable or pass `--off` to the governing agent. The stamp is a default-on enforcement gate, not an optional feature.

path: scripts/stamp.py
content: #!/usr/bin/env python3
"""
MO§ES™ Governed Output Stamp
Generates and appends a governance stamp to document content.
Usage:
  python3 stamp.py generate --mode <mode> --posture <posture> --role <role> --content <text>
  python3 stamp.py append --file <path> --mode <mode> --posture <posture> --role <role>
"""

import hashlib
import sys
import json
import os
import argparse
from datetime import datetime, timezone

STAMP_BLOCK = """\
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MO§ES™ GOVERNANCE STAMP
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Produced under:  MO§ES™ Governance Framework
Mode:            {mode}
Posture:         {posture}
Role:            {role}
Session ID:      {session_id}
Action #:        {action_num}
Integrity hash:  {integrity_hash}
Runtime:         ClawHub (cryptographic)
© 2026 Ello Cello LLC — MO§ES™ is trademark pending
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"""

STATE_PATH = os.path.expanduser("~/.openclaw/governance/state.json")
STAMP_LOG = os.path.expanduser("~/.openclaw/governance/stamps.jsonl")


def load_state():
    if os.path.exists(STATE_PATH):
        with open(STATE_PATH) as f:
            return json.load(f)
    return {}


def get_action_num():
    if not os.path.exists(STAMP_LOG):
        return 1
    with open(STAMP_LOG) as f:
        return sum(1 for _ in f) + 1


def compute_session_id(state):
    seed = state.get("session_start", datetime.now(timezone.utc).isoformat())
    return hashlib.sha256(seed.encode()).hexdigest()[:8]


def compute_integrity_hash(content, mode, posture, action_num):
    slug = (content[:64] + mode + posture + str(action_num)).encode()
    return hashlib.sha256(slug).hexdigest()


def generate_stamp(mode, posture, role, content=""):
    state = load_state()
    action_num = get_action_num()
    session_id = compute_session_id(state)
    integrity_hash = compute_integrity_hash(content, mode, posture, action_num)

    stamp = STAMP_BLOCK.format(
        mode=mode or state.get("mode", "Unrestricted"),
        posture=posture or state.get("posture", "None"),
        role=role or state.get("role", "Primary"),
        session_id=session_id,
        action_num=action_num,
        integrity_hash=integrity_hash,
    )

    # Log the stamp event
    os.makedirs(os.path.dirname(STAMP_LOG), exist_ok=True)
    record = {
        "ts": datetime.now(timezone.utc).isoformat(),
        "action_num": action_num,
        "integrity_hash": integrity_hash,
        "session_id": session_id,
    }
    with open(STAMP_LOG, "a") as f:
        f.write(json.dumps(record) + "\n")

    return stamp


def cmd_generate(args):
    stamp = generate_stamp(args.mode, args.posture, args.role, args.content or "")
    print(stamp)


def cmd_append(args):
    if not os.path.exists(args.file):
        print(f"Error: file not found: {args.file}", file=sys.stderr)
        sys.exit(1)
    with open(args.file) as f:
        content = f.read()
    stamp = generate_stamp(args.mode, args.posture, args.role, content)
    with open(args.file, "a") as f:
        f.write("\n\n" + stamp + "\n")
    print(f"Stamp appended to {args.file}")


def main():
    parser = argparse.ArgumentParser(description="MO§ES™ governance stamp generator")
    sub = parser.add_subparsers(dest="cmd")

    gen = sub.add_parser("generate", help="Print a governance stamp")
    gen.add_argument("--mode", default="")
    gen.add_argument("--posture", default="")
    gen.add_argument("--role", default="Primary")
    gen.add_argument("--content", default="")

    app = sub.add_parser("append", help="Append stamp to a file")
    app.add_argument("--file", required=True)
    app.add_argument("--mode", default="")
    app.add_argument("--posture", default="")
    app.add_argument("--role", default="Primary")

    args = parser.parse_args()
    if args.cmd == "generate":
        cmd_generate(args)
    elif args.cmd == "append":
        cmd_append(args)
    else:
        parser.print_help()
        sys.exit(1)


if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)