Managing policies
Result: a policy set that grants the intended access and nothing more, tested
from a non-root credential, with denials explained by policy evaluations.
Reference
- resources:
policycommand records and update field names. - activities:
policy evaluationsand consensus votes.
Rules
- Write policies against tag ids and secret static properties. Name a user or resource id only where the reference says it is unavoidable.
- A DENY overrides every ALLOW. Never delete a containment DENY to make an activity succeed.
- Consensus must contain a clause the submitter satisfies, or the activity is denied at submission instead of waiting for approval.
- Test from the constrained credential. Root success proves nothing about agent access.
- Keep expressions exactly as written; only the
${UPPER_SNAKE}id variables interpolate.
Instructions
Inputs: the root profile (admin), AGENT_TAG and the other tag ids from
bootstrapping-organization, and the
approval cell. Read policy-language.md
for grammar and policy-patterns.md for
the policy set.
State the change. Before any mutation, write down effect, condition, consensus, and which users the consensus selects. If the request is "make this denied activity work", read the denial first (step 5) and return the smallest change that fits the requested access.
Create a policy. Root. Flags for one policy:
<!-- example: policies.create -->tk --profile admin --message-format json policy create --name agents-export-unilateral --effect allow \ --consensus "approvers.any(user, user.tags.contains('${AGENT_TAG}'))" \ --condition "activity.type == 'ACTIVITY_TYPE_EXPORT_SECRETS' && secret.static_properties['consensus'] == 'unilateral'" \ --notes "allow-always: agents read unilateral secrets alone"Save
data.activity.result.createPolicyResult.policyId. For several policies at once,policy create-batch --input-file ./policies.jsontakes{"policies":[...]}withpolicyName,effect,condition,consensus,notes.Confirm what was stored.
<!-- example: policies.get -->tk --profile admin --message-format json policy get --id POLICY_ID tk --profile admin --message-format json policy listdata.policy.conditionanddata.policy.consensusmust equal the expressions from step 1 character for character.Test from the constrained credential. Run the intended allowed operation and one operation that must be denied as the tagged user. The allowed one returns
status: "completed"or, for allow-once,pending; the denied one fails withunauthorizedand HTTP 403.Explain a denial or a pending vote.
<!-- example: policies.evaluations -->tk --profile admin --message-format json policy evaluations --activity-id ACTIVITY_IDdata.policyEvaluations[]carries one entry per vote withpolicyEvaluations[].policyIdandoutcome. A DENY outcome names the policy to read; no ALLOW outcome means no policy matched. A 403 with no activity id means the request was refused before an activity existed; compare the submitter's tags against the consensus clauses.Update or delete. Root. Updates use
<!-- example: policies.update -->policyIdwith thepolicy-prefixed field names:tk --profile admin --message-format json policy update --input-json '{"policyId":"POLICY_ID","policyNotes":"revised"}' tk --profile admin --message-format json policy delete --id POLICY_IDRe-run step 3 after an update. Deleting an ALLOW removes access immediately; deleting a DENY may widen access, so re-run step 4.
Hand off. Report each policy id with its name, effect, condition, and consensus, and the allowed and denied operations that were tested. Stop.
Verified by
| Examples | Test |
|---|---|
| policies.create, policies.get, policies.evaluations, policies.update | policies::managing_policies_crud_and_evaluations |
| policies.evaluations | policies::quorum_approval_completes_and_rejection_fails_a_consensus_activity |
Troubleshooting
policy createfails withusage_error:--nameneeds--effectand at least one of--conditionor--consensus.policy updatefails withinvalid_inputnaming an unsupported field: updates usepolicyEffect,policyCondition,policyConsensus, andpolicyNotes, not the create names.- The constrained user gets
unauthorizedon an operation the ALLOW covers: checkactivity.typespelling against the table in policy-language.md, and check that the user actually carries the tag withtk --profile admin --message-format json user get --id USER_ID. - The activity is
pendingwhen it should complete: the consensus names a second party. That is allow-once behavior; approve it, or change the consensus if unilateral was intended. - The activity is denied when it should be
pending: no consensus clause is satisfiable by the submitter. Add the submitter's tag clause. - A root user approves and everything passes: the root quorum bypassed the policies. Repeat the test with a non-root approver.
Related Skills
- monitoring-activities: approve, reject, and inspect the activities these policies gate.
- managing-identities: attach or remove the tags the policies select.
- managing-secrets: the property-based export policies in practice.