Ethical contract Ten principles, programmatically enforced. Not advisory.

digger ships with a codified ethical contract — digger.ethics.contract exposes ten Principle records and a set of assertion helpers that raise EthicsViolation when violated. These are not docstrings. State-modifying features call the assertions on the way in; the test suite has 19 load-bearing tests in tests/test_ethics.py that fail if a principle's enforcement is removed.

The contract intentionally mirrors and inverts every offensive capability digger detects against. See Decepticon countermeasures for the contrast table that drove the principle list.

The ten principles

Engagement scope (pre-engagement attestation)

Before the first artifact is touched, an EngagementScope is recorded into the chain of custody. The scope answers four questions in writing:

Field groupCaptured
WHOinvestigator name, role, contact, organization
WHYlegal authority + written consent reference (ticket / contract clause / email msg-id)
WHATtarget hosts + data categories opted in + cross_host_allowed flag
WHENwindow start, expected end, retention days, deconfliction notes

EngagementScope.validate() raises EthicsViolation for obvious gaps: empty investigator name, multi-host scope without cross_host_allowed=True, unrecognized data categories, retention > 10 years.

Remediation gating

Every remediation command emitted by a detector (e.g., the firewall auditor's "run this to add default-deny inbound") routes through redact_dangerous_command(cmd) first. The function recognizes destructive operations — rm -rf, dd of=, chmod 777, iptables -F with no preservation, pfctl -d, etc. — and annotates them as destructive in the output.

digger never applies remediation itself. The firewall audit CLI prints commands with a [DESTRUCTIVE] marker on the flagged ones; the operator runs them by hand.

Where the contract is wired in

Why it's load-bearing

The 19 tests in tests/test_ethics.py include:

A pull request that removes any guardrail breaks the suite, with a test name pointing at the principle.