Skip to content

docs: add working with controls tutorial - #154

Merged
pbeckham merged 25 commits into
mainfrom
claude/friendly-wilson
Jun 17, 2026
Merged

pbeckham merged 25 commits into
mainfrom
claude/friendly-wilson

Conversation

@pbeckham

@pbeckham pbeckham commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

ℹ️ Controls is now a real feature in Kosli, in beta.
This tutorial originally documented a proposed feature ahead of development. It has since been updated to match the shipped implementation in kosli-dev/server and uses real screenshots from staging. The feature is rolled out per organization while in beta — the UI, CLI flags, and policy YAML schema may still change.

Summary

  • Adds tutorials/working_with_controls.mdx — a tutorial covering how to define controls in Kosli, record decisions against them with kosli attest decision, require controls in environment policies via for_control, enforce them with kosli assert artifact --environment, and review a control's decisions and version history.
  • Updates config/navigation.json to include the new page under a new "Controls" group in the Tutorials section.

Aligned with the shipped implementation

  • Controls are created/edited via the app UI and the controls API (POST /api/v2/controls/{org}) — there is no kosli create control/kosli list controls CLI.
  • Environment policies require controls via attestations: rules with type: decision and for_control: (not a top-level controls: key).
  • Control detail view documents the real Decisions and Versions tabs (no Coverage/Deployments views).
  • Tags are added from a control's detail page after creation; only org admins can create/edit controls.
  • kosli evaluate examples use --no-assert (it asserts on deny by default); --compliant is shown as a boolean flag (--compliant=true).
  • Real staging screenshots replace the original proposal mockups.

Closes kosli-dev/server#5355

@pbeckham
pbeckham requested a review from a team as a code owner April 16, 2026 09:58
@mintlify

mintlify Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
kosli 🟢 Ready View Preview Apr 16, 2026, 9:58 AM

Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread images/tutorials/controls-list.png
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread images/tutorials/controls-compliance-coverage.png Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
@mbevc1

mbevc1 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Was this released yet? I cannot see this in Kosli 🤔

@pbeckham

Copy link
Copy Markdown
Contributor Author

Was this released yet? I cannot see this in Kosli 🤔

No this is a proposed feature. We are making this documentation ahead of development to facilitate discussions and get early feedback before we build it.

@mbevc1

mbevc1 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Okay, I assume we're not releasing this to docs yet then? I think it might confuse our customers.

Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread images/tutorials/controls-compliance-coverage.png Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Comment thread tutorials/working_with_controls.mdx Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pbeckham and others added 2 commits June 15, 2026 14:09
Update the working-with-controls tutorial to match what is actually
built in the server and cli repos, replacing proposal-era guesses:

- Mark the feature as beta (available) rather than in development.
- Remove the non-existent `kosli create control` / `kosli list controls`
  CLI commands; document the New control form (identifier, name,
  description, links, tags) and the controls API instead.
- Drop the unbuilt Active/Stale/No-decisions status table.
- Fix `--compliant=true` (boolean flag) and add `--no-assert` to the
  `kosli evaluate` examples, which assert on deny by default.
- Replace the imaginary top-level `controls:` policy key with the real
  `attestations:` rules using `type: decision` and `for_control:`.
- Replace Decisions/Deployments/Coverage tabs with the real
  Decisions/Versions tabs and correct the decisions table columns.
- Fix broken /reference/controls link.
- Swap proposal mockups for real staging screenshots; add a decision
  detail screenshot; remove the now-orphaned coverage/deployments images.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Correct details surfaced by the controls project handovers, and switch
to US spelling throughout:

- Tags are not a create-time field — they are added later from the
  control detail page and do not version the control; note admin-only
  writes.
- Clarify the validation asymmetry: recording a decision does not
  require the control to exist, but a policy referencing an unknown
  control identifier is rejected.
- Note that multiple decisions can be recorded for a control on a trail
  and the most recent is used for enforcement.
- Match the decision detail description to the shipped UI: evaluation
  result and params live in user-data; the Rego policy is the attached
  evidence file.
- State that the feature is rolled out per organization (beta).
- organisation -> organization, judgement -> judgment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @pbeckham's task in 2m 45s —— View job


Review: docs: add working with controls tutorial

  • Read CLAUDE.md and doc-review skill
  • Read changed files (tutorial, navigation config, images)
  • Check navigation.json for new page entry
  • Review content quality, links, and conventions
  • Post review findings

Summary

The tutorial is well-structured and thorough after its many rounds of review. It covers the full controls lifecycle (create → decide → assert → review) with clear CLI examples, a useful Mermaid sequence diagram, and real staging screenshots. No critical issues found.

Findings

Critical

None.

Compliance checks (all pass)

  • Navigation: tutorials/working_with_controls is correctly added to config/navigation.json under a "Controls" group
  • Frontmatter: Title and description present
  • Links: All 9 internal links resolve to existing files — no broken links
  • No relative links: All links use root-relative paths
  • Images: All 3 screenshots exist and render correctly
  • Writing style: Active voice, imperative mood, American spelling, correct Kosli terminology ("attest", "audit trail")
  • Heading case: All headings use sentence case

Improvement (2)

  1. --no-assert flag undocumented (working_with_controls.mdx:123-127): The kosli evaluate trail CLI reference doesn't list --no-assert — a reader cross-referencing will find no matching flag. Covered by the beta callout, but worth noting for when reference pages are regenerated. (inline comment)

  2. Schema URL inconsistency (working_with_controls.mdx:216): Uses docs.kosli.com/schemas/policy/v1 while the actual schema file's $id and every other docs page use kosli.mintlify.app/schemas/policy/v1. Already discussed — @pbeckham's decision to treat docs.kosli.com as canonical is sound, but the schema file itself (schemas/policy/v1.json:3) still has "$id": "https://kosli.mintlify.app/schemas/policy/v1". The site-wide migration should include updating that $id.

Suggestion (2)

  1. jq '.allow' shape assumption (working_with_controls.mdx:130): The JSON extraction assumes a top-level allow field from kosli evaluate --output json. The evaluate trails with OPA tutorial shows a different output structure. If the beta evaluate output differs from GA, a brief note on the expected JSON shape would help. (inline comment)

  2. Next-steps links as cards (working_with_controls.mdx:259-264): The closing "From here" section uses a plain bullet list. Other parts of the site use <CardGroup> / <Card> for navigation links — switching would give readers visual targets. Minor polish. (inline comment)

Overall assessment

The tutorial is in good shape for a beta feature. Content is accurate against the shipped implementation, the PDP/PEP separation is clearly explained, and the evidence-attachment workflow with kosli evaluate is a strong practical example. The main gaps are all acknowledged as beta-scope items (missing CLI reference page for attest decision, undocumented --no-assert flag, screenshot/prose identifier mismatch). No changes needed before merge — the items above are for future cleanup.


Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
@pbeckham
pbeckham marked this pull request as ready for review June 15, 2026 14:50
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx
Comment thread tutorials/working_with_controls.mdx Outdated
…xist

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pbeckham
pbeckham merged commit 3aeba71 into main Jun 17, 2026
5 of 6 checks passed
@pbeckham
pbeckham deleted the claude/friendly-wilson branch June 17, 2026 12:56
Comment on lines +123 to +127
kosli evaluate trail "$TRAIL_NAME" \
--policy supply-chain-policy.rego \
--flow "$FLOW_NAME" \
--no-assert \
--output json > eval-report.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement: The --no-assert flag used here is not listed in the kosli evaluate trail CLI reference — that page documents --attestations, --flow, --output, --params, --policy, and --show-input, but no --no-assert. A reader following this example who checks the reference will find no matching flag.

Since the beta callout at the top already sets expectations for undocumented CLI behavior, this isn't blocking — but worth noting for when the reference pages are regenerated.

--output json > eval-report.json

# Read the allow/deny result from the report
is_compliant=$(jq -r '.allow' eval-report.json)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The jq -r '.allow' extraction assumes the --output json format from kosli evaluate trail includes a top-level allow field. The evaluate trails with OPA tutorial shows a different JSON output structure (result, violations). If the beta version of kosli evaluate has a different output shape than the GA version, a brief comment or note clarifying the expected JSON structure would help readers who cross-reference the two tutorials.

Comment on lines +259 to +264
From here you can:

- Learn more about [controls](/understand_kosli/controls)
- Learn more about [environment policies](/getting_started/policies)
- Learn more about [attestations](/getting_started/attestations)
- [Evaluate trails with Rego policies](/tutorials/evaluate_trails_with_opa) to automate decision-making

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion (minor): Other tutorials in this site use <CardGroup> / <Card> components for "next steps" navigation (e.g., the Labs landing page). Replacing this bullet list with cards would give the reader visual targets and be consistent with the rest of the site — though this is polish, not critical.

dangrondahl added a commit that referenced this pull request Sep 3, 2026
Reviewed the last 20 non-bot PRs (14 touched docs) against what
`doc-write` and `doc-review` actually ask for, then fixed what the
record showed was wrong. No site content changes — this is all agent
tooling.

## Why

`doc-review` produced **0 Critical, 5 Improvement and ~20 Suggestion**
findings across those 14 PRs. Its genuinely valuable catches were all
cross-file consistency checks the skill never asked for:

- a changelog entry documenting `kosli update attestation-type`, a
command with no reference page (#371)
- `template-reference/flow_template.md` out of sync with the schema the
same PR regenerated (#296)
- the one file an approvals-removal sweep missed,
`understand_kosli/how_kosli_works.md:22` (#345)

Its weakest findings were prose polish, some already fixed at branch
head. Meanwhile its written checklist was dominated by things that
always pass or are already enforced by `vale-spellcheck`.

Two structural gaps the PR record made obvious:

- **Placement was never questioned.** In #305 a pure reference page was
authored into `integrations/`, and a human reviewer had to ask for the
move — commit `9e7a121 docs: move GitHub Action reference into the
Reference section`. That question should come from the review.
- **Generated pages were handled inconsistently.** #375 got it right and
said so. #374 wrote *"the durable fix is in the `kosli-dev/cli`
generator — a hand-edit here is overwritten by the next release"* and
then emitted a `Fix this` link scoped to `repo=kosli-dev/docs` telling
an agent to edit the generated file anyway, plus 4 inline comments on
regenerated files.

## What changed

**`doc-review`** — promoted the three accidental wins to named checks,
each carrying its precedent. Added placement, redirects and anchor
stability. Added an explicit *what not to report* bar and an 8-finding
cap. Stopped hand-checking spelling. Dropped the "what looks good"
recital that the sticky comment re-renders on every push.

**Generated pages** — split into three categories rather than one
blanket ban: deterministically regenerated (edit is deleted),
agent-synced (edit survives but drifts), and hand-authored despite the
directory (`client_reference/overview.md`, `output_and_verbosity.md`).
Includes the filename→source mapping, verified upstream:
`kosli_attest_sonar.md` ← `cmd/kosli/attestSonar.go`.

Also records that **`^` is the CLI's backtick convention** in Go long
descriptions, substituted by `kosli docs`. That makes the `^jq^` defect
#374 found a generator escaping bug in the Accordion-title path, not a
typo in the Go string — so a reviewer can point at the right fix. Worth
filing upstream separately.

**`doc-write`** — added a Diátaxis→tab placement table so #305 can't
recur, plus redirects, anchor stability, and the generated-paths table.

**New `doc-structure` skill + monthly workflow** — audits navigation
shape and changelog coverage, which per-PR review structurally cannot
see, and files issues. Read-only against docs; issues are its only
write. Capped at 8 issues, deduplicating against open issues first — its
headline check reproduces the `/getting_started/attestations` summary
gap, which is already open as #364.

**New `scripts/audit_navigation.py` + 22 tests** — the audit's
mechanical checks, extracted from an inline heredoc. Three payoffs:

1. `pr-quality.yml` already runs `pytest tests/`, so **CLAUDE.md core
rule 2 is now enforced deterministically** — a page file with no
`navigation` entry fails the build. No new job needed.
2. `doc-structure.yml` can allow `Bash(python3
scripts/audit_navigation.py:*)` instead of `Bash(python3:*)`, which was
arbitrary code execution.
3. Determinism. The inline version had already shipped a bug: `sed
's|\.mdx\?$||'` is a no-op on BSD sed, so every page looked orphaned on
macOS. That case is now a regression test.

Integrity findings (orphans, dangling entries) are separated from shape
findings (single-child groups, deep nesting, Title Case labels,
oversized groups, inconsistent icons). Only integrity can fail a build —
the script cannot tell a group that should be merged from one
deliberately kept separate.

`Reference ▸ CLI Reference` is exempt from shape checks:
`update-cli-nav.py` generates it from the CLI's command tree, so a
single-child `kosli allow` group is upstream truth. Without that
exemption the audit reported 54 findings, 21 of them proposing to
reshape generated navigation — the same mistake being fixed in
`doc-review`. It now reports 33, all hand-maintained.

**New `docs-restructure` issue template** — Markdown, not a YAML form:
`gh issue create --body` doesn't apply templates mechanically and YAML
forms can't be filled from the CLI, so a form would help humans and do
nothing for the job. Its URL-impact section encodes the distinction that
decides whether a restructure is safe — a group rename changes no URLs,
a moved page file needs a `config/redirects.json` entry. `config.yml`
keeps blank issues enabled.

**`CLAUDE.md`** — documented the six automated PR checks, the
generated-page source map, the audit script, and the three skills.
Removed the pointer to a `changelog-creator` skill that doesn't exist in
this repo.

## Anti-rot pass

Swept all three skills for dated claims. Counts ("three of the last
fourteen PRs") and current-state assertions ("link-rot reports skipping
on most PRs") became durable rules. The link-rot guidance now routes
through `gh pr checks` so it self-heals if Mintlify starts running it
reliably. Past-tense `Precedent:` items were kept — they're what make
the checks concrete.

## Verification

- `python3 -m pytest tests/` — 44 passed (22 pre-existing + 22 new)
- `python3 scripts/audit_navigation.py --check` — exit 0, integrity
clean
- `mint broken-links` — no new broken links
- Both workflows parse; triggers and permissions confirmed

## Follow-ups, not in this PR

- `tutorials/working_with_controls.mdx:24` links to
`/getting_started/service-accounts`, which has never existed — the page
is `/administration/authentication/service_accounts`. Broken on `main`
since #154; `link-rot` reports `skipping`, which is why it went unseen.
- The `mintlify-docs` plugin in `kosli-plugins` still ships
near-duplicate `doc-writer`/`doc-reviewer` agents that say "update
`docs.json` navigation" — the pre-`config/` layout. Needs its own PR
there.
- The reviews twice asked for `python3` in `doc-review.yml`'s
`--allowedTools` to validate JSON payloads and fence balance. Left alone
— `Bash(python3:*)` is a security-surface call worth making
deliberately.
gsavage pushed a commit that referenced this pull request Sep 7, 2026
Reviewed the last 20 non-bot PRs (14 touched docs) against what
`doc-write` and `doc-review` actually ask for, then fixed what the
record showed was wrong. No site content changes — this is all agent
tooling.

## Why

`doc-review` produced **0 Critical, 5 Improvement and ~20 Suggestion**
findings across those 14 PRs. Its genuinely valuable catches were all
cross-file consistency checks the skill never asked for:

- a changelog entry documenting `kosli update attestation-type`, a
command with no reference page (#371)
- `template-reference/flow_template.md` out of sync with the schema the
same PR regenerated (#296)
- the one file an approvals-removal sweep missed,
`understand_kosli/how_kosli_works.md:22` (#345)

Its weakest findings were prose polish, some already fixed at branch
head. Meanwhile its written checklist was dominated by things that
always pass or are already enforced by `vale-spellcheck`.

Two structural gaps the PR record made obvious:

- **Placement was never questioned.** In #305 a pure reference page was
authored into `integrations/`, and a human reviewer had to ask for the
move — commit `9e7a121 docs: move GitHub Action reference into the
Reference section`. That question should come from the review.
- **Generated pages were handled inconsistently.** #375 got it right and
said so. #374 wrote *"the durable fix is in the `kosli-dev/cli`
generator — a hand-edit here is overwritten by the next release"* and
then emitted a `Fix this` link scoped to `repo=kosli-dev/docs` telling
an agent to edit the generated file anyway, plus 4 inline comments on
regenerated files.

## What changed

**`doc-review`** — promoted the three accidental wins to named checks,
each carrying its precedent. Added placement, redirects and anchor
stability. Added an explicit *what not to report* bar and an 8-finding
cap. Stopped hand-checking spelling. Dropped the "what looks good"
recital that the sticky comment re-renders on every push.

**Generated pages** — split into three categories rather than one
blanket ban: deterministically regenerated (edit is deleted),
agent-synced (edit survives but drifts), and hand-authored despite the
directory (`client_reference/overview.md`, `output_and_verbosity.md`).
Includes the filename→source mapping, verified upstream:
`kosli_attest_sonar.md` ← `cmd/kosli/attestSonar.go`.

Also records that **`^` is the CLI's backtick convention** in Go long
descriptions, substituted by `kosli docs`. That makes the `^jq^` defect
#374 found a generator escaping bug in the Accordion-title path, not a
typo in the Go string — so a reviewer can point at the right fix. Worth
filing upstream separately.

**`doc-write`** — added a Diátaxis→tab placement table so #305 can't
recur, plus redirects, anchor stability, and the generated-paths table.

**New `doc-structure` skill + monthly workflow** — audits navigation
shape and changelog coverage, which per-PR review structurally cannot
see, and files issues. Read-only against docs; issues are its only
write. Capped at 8 issues, deduplicating against open issues first — its
headline check reproduces the `/getting_started/attestations` summary
gap, which is already open as #364.

**New `scripts/audit_navigation.py` + 22 tests** — the audit's
mechanical checks, extracted from an inline heredoc. Three payoffs:

1. `pr-quality.yml` already runs `pytest tests/`, so **CLAUDE.md core
rule 2 is now enforced deterministically** — a page file with no
`navigation` entry fails the build. No new job needed.
2. `doc-structure.yml` can allow `Bash(python3
scripts/audit_navigation.py:*)` instead of `Bash(python3:*)`, which was
arbitrary code execution.
3. Determinism. The inline version had already shipped a bug: `sed
's|\.mdx\?$||'` is a no-op on BSD sed, so every page looked orphaned on
macOS. That case is now a regression test.

Integrity findings (orphans, dangling entries) are separated from shape
findings (single-child groups, deep nesting, Title Case labels,
oversized groups, inconsistent icons). Only integrity can fail a build —
the script cannot tell a group that should be merged from one
deliberately kept separate.

`Reference ▸ CLI Reference` is exempt from shape checks:
`update-cli-nav.py` generates it from the CLI's command tree, so a
single-child `kosli allow` group is upstream truth. Without that
exemption the audit reported 54 findings, 21 of them proposing to
reshape generated navigation — the same mistake being fixed in
`doc-review`. It now reports 33, all hand-maintained.

**New `docs-restructure` issue template** — Markdown, not a YAML form:
`gh issue create --body` doesn't apply templates mechanically and YAML
forms can't be filled from the CLI, so a form would help humans and do
nothing for the job. Its URL-impact section encodes the distinction that
decides whether a restructure is safe — a group rename changes no URLs,
a moved page file needs a `config/redirects.json` entry. `config.yml`
keeps blank issues enabled.

**`CLAUDE.md`** — documented the six automated PR checks, the
generated-page source map, the audit script, and the three skills.
Removed the pointer to a `changelog-creator` skill that doesn't exist in
this repo.

## Anti-rot pass

Swept all three skills for dated claims. Counts ("three of the last
fourteen PRs") and current-state assertions ("link-rot reports skipping
on most PRs") became durable rules. The link-rot guidance now routes
through `gh pr checks` so it self-heals if Mintlify starts running it
reliably. Past-tense `Precedent:` items were kept — they're what make
the checks concrete.

## Verification

- `python3 -m pytest tests/` — 44 passed (22 pre-existing + 22 new)
- `python3 scripts/audit_navigation.py --check` — exit 0, integrity
clean
- `mint broken-links` — no new broken links
- Both workflows parse; triggers and permissions confirmed

## Follow-ups, not in this PR

- `tutorials/working_with_controls.mdx:24` links to
`/getting_started/service-accounts`, which has never existed — the page
is `/administration/authentication/service_accounts`. Broken on `main`
since #154; `link-rot` reports `skipping`, which is why it went unseen.
- The `mintlify-docs` plugin in `kosli-plugins` still ships
near-duplicate `doc-writer`/`doc-reviewer` agents that say "update
`docs.json` navigation" — the pre-`config/` layout. Needs its own PR
there.
- The reviews twice asked for `python3` in `doc-review.yml`'s
`--allowedTools` to validate JSON payloads and fence balance. Left alone
— `Bash(python3:*)` is a security-surface call worth making
deliberately.

This branch was successfully deployed

1 active deployment
staging — 6df12d6f Deployed Jun 17, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants