Skip to content

docs(dev): fix stale structure.md and document drapi client conventions - #879

Open
ajalon1 wants to merge 10 commits into
datarobot-oss:mainfrom
ajalon1:aj/update-agents-and-bugbot-for-workload
Open

docs(dev): fix stale structure.md and document drapi client conventions#879
ajalon1 wants to merge 10 commits into
datarobot-oss:mainfrom
ajalon1:aj/update-agents-and-bugbot-for-workload

Conversation

@ajalon1

@ajalon1 ajalon1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

RATIONALE

workload and auth have absorbed most of the last two months' commit volume, but the dev docs a new contributor actually browses hadn't kept up — structure.md still showed a directory tree and a config.GetAPIKey()/SetAPIKey()/SaveConfig() code sample that no longer exist (and contradicts the correct pattern already documented in configuration.md), and internal/drapi's conventions (timeout clamping, the HTTPError/errors.As contract, origin-safety before attaching credentials to a server-supplied URL) lived only in a package doc comment, unlinked from docs/development/.

This closes that gap with pure documentation — no code changes.

A dedicated internal/workload architecture doc is being drafted separately for the Workload API team to review and own, so this intentionally leaves that package's structure.md subsection as a placeholder pending that PR.

CHANGES

  • docs/development/structure.md: add workload/ and auth/ to the directory trees, fix the auth/ worked example to match the current one-subdirectory-per-verb layout, replace the stale Configuration code sample with the real viperx/UpdateConfigFile pattern.
  • New docs/development/drapi-client.md: verb-function convention, timeout clamping, the HTTPError/errors.As contract (including a known Get() vs Post/Patch/Delete detail asymmetry, flagged not fixed), and the origin-safety check before attaching credentials to a server-supplied URL.
  • Cross-link the new doc from authentication.md, docs/development/README.md's Advanced topics, AGENTS.md's new Auth & API Client Conventions section, and a one-line worked-example pointer in .cursor/bugbot-security.md.

Note

Low Risk
Markdown-only changes to development guides and BugBot rules; no runtime, auth, or API behavior changes.

Overview
Documentation-only update to bring contributor docs and BugBot guidance in line with current auth, workload, and drapi patterns.

Dev docs: Adds docs/development/drapi-client.md (verb functions, timeout clamping, HTTPError/errors.As, origin checks via URLMatchesConfiguredBase, and the known Get() vs other verbs error-detail gap). structure.md now lists cmd/workload, internal/auth, and internal/workload, fixes the auth subcommand layout example, and replaces obsolete GetAPIKey/SaveConfig samples with viperx + UpdateConfigFile. Cross-links land in README.md, authentication.md, and AGENTS.md (new Auth & API Client Conventions section).

BugBot / review rules: Expands several .cursor/bugbot-*.md files with shared-flag registration, sentinel defaults, intentional sibling asymmetry, terminal recovery commands, retry-by-response-shape, drapi extension vs re-implementation, non-platform HTTP clients, duplicated-constant comments, localhost callback provenance, scoped security claims, and heuristic validation that warns instead of hard-blocking.

Reviewed by Cursor Bugbot for commit 2861434. Configure here.

- structure.md: add workload/ and auth/ to the directory trees (both were
  missing despite being two of the largest packages in the repo), fix the
  auth/ worked example to match the current one-subdirectory-per-verb
  layout, and replace the Configuration code sample's nonexistent
  config.GetAPIKey/SetAPIKey/SaveConfig calls with the real viperx/
  UpdateConfigFile pattern already documented in configuration.md.
- Add docs/development/drapi-client.md: the dev-doc mirror of
  internal/drapi/doc.go covering the verb-function convention, timeout
  clamping, the HTTPError/errors.As contract (including the known Get()
  vs Post/Patch/Delete detail asymmetry), and the origin-safety check
  before attaching credentials to a server-supplied URL.
- Cross-link the new doc from authentication.md, docs/development/README.md's
  Advanced topics, AGENTS.md's new Auth & API Client Conventions section,
  and a one-line worked-example pointer in .cursor/bugbot-security.md.

A dedicated internal/workload architecture doc is being drafted separately
for review by the Workload API team, so this change intentionally leaves
that package's structure.md subsection as a placeholder pending that PR.
…erns

- Terminal Errors Must Name the Exact Recovery Command
- Retry Safety Must Be Classified by Response Shape, Not Status Code Alone
- Heuristic Detection Must Degrade, Never Refuse
- Duplicated Constants Need a Canonical-Source Comment
- Document Intentional Asymmetry Between Look-Alike Siblings

Each generalizes a pattern observed in real workload/auth/drapi code during
the docs audit for datarobot-oss#879, kept domain-agnostic per the existing bugbot rule
style.
Today's countflags migration (CFX-7834, datarobot-oss#858/datarobot-oss#859/datarobot-oss#860) is documented in
docs/development/flags.md but had no reviewer-facing rule — a new count-like
flag validated in RunE instead of at parse time would sail through review.
Adds the parse-time-validation rule plus its documented exception (0 as a
"use default" sentinel, per the workload config --port/--replicas precedent).
Broadens "count-like flags validate at parse time" to any flag shape that
recurs across commands or shares a validation requirement wherever it
appears — not just counts. countflags and pollflags are cited as the two
existing precedents (counts, durations); the point is catching a third
command re-implementing the same check by hand instead of reusing one of
these or adding a new shared pflag.Value.
Codifies the pattern already present in the codebase: internal/drapi/filesapi
and internal/workload/apiclient are thin typed wrappers built entirely on
drapi's verb functions, while internal/auth/browserflow.go (local OAuth
handshake) and internal/plugin/remote.go (plugin downloads) correctly build
their own plain http.Client because they aren't DataRobot API calls. Adds
both directions of the boundary so a reviewer catches a wrapper duplicating
drapi's plumbing and an unrelated call wrongly forced through it.
Comment thread docs/development/drapi-client.md Outdated
Comment on lines +15 to +17
Worked example: `docs/development/drapi-client.md` — before attaching a bearer token to
a server-supplied URL (pagination cursor, live endpoint), verify it with
`drapi.URLMatchesConfiguredBase()` first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure I need or want worked examples in the bugbot cursor rules.

Comment thread .cursor/bugbot-cmd.md Outdated
Comment thread .cursor/bugbot-cmd.md Outdated
Comment thread docs/development/structure.md Outdated
ajalon1 and others added 5 commits August 31, 2026 13:15
Prompted by CFX-7754 (datarobot-oss#820, merged today): the auth login callback
listener on localhost:51164 accepted any request during its window,
letting a hidden <img> on any open page plant a forged API key. Adds the
provenance-validation rule for local OAuth-style listeners, plus a rule
against security docs overclaiming what a mitigation blocks (the PR's own
review round caught exactly that in its first docs draft).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ajalon1
ajalon1 marked this pull request as ready for review September 11, 2026 00:28
@ajalon1
ajalon1 requested a review from a team as a code owner September 11, 2026 00:28
@ajalon1

ajalon1 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

/skip-smoke-tests

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.

1 participant