← Back to Pull requests

CXH-3522: set manager, department, location on Ramp account creation #56

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 28, 2026 22:52 UTC
Author

CXH-3522: set manager, department, location on Ramp account creation

Linear: CXH-3522

What was asked

When C1 creates a Ramp account, the connector sent only email, first name, last
name and role — so new Ramp users got no manager, department or location, and
admins filled these in by hand in Ramp after every creation. Location matters
most: in Ramp it decides which entity the user belongs to, so without it users
could not be placed in the right entity at creation time.

This PR lets C1 account creation set the new Ramp user's direct manager,
department, and location — the three optional fields Ramp's
POST /developer/v1/users/deferred accepts as direct_manager_id,
department_id, and location_id (each a Ramp ID, not a name or email).

What changed

The approach: human-facing values flow in as three optional account-creation
profile fields (direct_manager_email, department, location), and the
connector resolves each to a Ramp-validated ID before the create call, so a
value that matches nothing fails creation instead of producing a half-populated
user. Resolution is table-driven in one place (pkg/connector/account_attributes.go),
so the next creation attribute is one table entry, not another hand-rolled block.

  • pkg/client/org.go (new) + pkg/client/models.go — ListDepartments /

  • GetDepartment / ListLocations / GetLocation (one page per call,
    page.next token, page_size=100, ramp-client: error prefix) and their
    model structs, following the existing ListUsers/ListVendors shapes.
  • pkg/connector/account_attributes.go (new) — the resolver: manager by

  • email via the existing FindUserByEmail (nil → clear InvalidArgument);
    department/location by Ramp-ID probe (escaped path; NotFound/InvalidArgument
    falls through to a bounded, ctx-checked, case-insensitive name walk with a
    50-page cap; >1 exact name match → ambiguous-value error listing candidates);
    one unresolvedAttrError helper gives every failure the same shape — field,
    value, what was tried, what to do — at codes.InvalidArgument with the
    ramp-connector: prefix. Upstream 403/5xx propagate with their own gRPC
    codes (a missing scope is never misreported as "no match"), and rate-limit
    metadata from resolution lookups reaches the annotations on success and
    error paths.
  • pkg/connector/users.go — CreateAccount resolves attributes after the

  • unchanged AlreadyExistsResult short-circuit and before CreateUser; the
    userBuilder carries the flag via WithProvisioningAttributes.
  • pkg/client/users.go — CreateUserRequest gains department_id /

  • direct_manager_id / location_id as *string + omitempty: absent
    fields marshal out of the JSON body entirely, so creations without these
    values send a byte-identical request to today's.
  • pkg/config/config.go + regenerated conf.gen.go / config_schema.json —

  • opt-in provisioning-attributes bool field (both auth-method groups,
    default off), WithDisplayName per repo rules.
  • cmd/baton-ramp/main.go — departments:read / locations:read are

  • appended to the OAuth scope request only when the flag is on (the repo's
    own audit-log-events precedent; keeps every existing install's token
    request unchanged — new required scopes would be a breaking change).
  • Metadata — three optional fields added to the account-creation schema;

  • baton_capabilities.json regenerated unchanged.
  • specs/openapi.json + specs/openapi-provenance.json — the six touched

  • operations copied verbatim from the official Ramp developer API spec
    (accessed 2026-10-28) with a provenance table.
  • Docs — README.md (scopes + flag + the three profile keys),

  • docs/connector.mdx (scope tables for both auth methods + account-creation
    attributes section), docs/api-support-matrix.md (the three deferred-create
    rows flipped to Exposed; four GET departments/locations rows added).
  • Tests — pkg/client/org_test.go (pagination through page.next,

  • page_size=100, 404 error paths), resolver table tests (flag-off zero calls,
    page cap, 400-probe fall-through, ambiguity, 403 propagation, non-string
    values), and 8 new CreateAccount integration cases asserting the decoded
    POST body carries the resolved IDs and that every fail-closed path performs
    zero calls to users/deferred.

    Acceptance criteria

    1. An admin can configure account creation to set manager, department and
    location
    — three optional profile fields, documented, plus the opt-in
    provisioning-attributes flag that requests the read scopes. ✅
    2. The new Ramp user is created with those values — resolved Ramp IDs are
    asserted in the decoded POST /developer/v1/users/deferred body. ✅
    3. A value that matches nothing fails creation with a clear error — every
    unresolvable/ambiguous/flag-off-but-set path returns codes.InvalidArgument
    naming field and value, with zero create calls asserted by test. ✅
    4. Accounts created without these values keep working as today — flag
    defaults off, absent fields are omitted from the wire body, zero lookup
    calls, AlreadyExistsResult short-circuit unchanged. ✅
    5. The connector docs describe the new fields and the extra Ramp setup —
    README + connector.mdx + api-support-matrix updated, including the
    departments:read / locations:read scope grant the feature needs. ✅

    How far this is verified

  • The branch passed an editing adversarial review loop (10 reviewer lanes,

  • fix-now items applied as commits, re-reviewed to SHIP) and the connector
    rulebook's mechanical checks are clean.
  • go build / go vet / targeted go test are green on all changed packages

  • (pkg/client, pkg/connector, pkg/config, cmd/baton-ramp); the built
    baton-ramp binary builds and starts (smoke: PASS, partial — the repo
    declares no mock of its own, so the smoke gate did not exercise a sync).
  • A full sync WAS exercised: the connector was replayed end-to-end against a

  • mock of the Ramp API authored from the official docs — sync output identical
    to main (0 lost / 0 gained resources, entitlements, grants), no new static
    findings.
  • connector-eval (advisory): clean — 0 lost/gained objects, 0 new static

  • findings, sync replayed against the batch-authored Ramp mock.
  • CI is green and the repository review bot passed on this head (one fix

  • pass addressed its lint findings and implemented both of its suggestions:
    the account-creation schema fields are now added only when the flag is on,
    and the new scopes have their own documented lead-in).
  • Independent deep review (a fresh environment that had seen none of this

  • work) read the PR cold, raised 1 docs-only nit (README flag ordering), which
    was fixed; its second cold pass found 0 findings and verified the fix. All
    of its review threads are answered and resolved.
  • Acceptance criteria: VERA, testing the PR from a fresh clone of this

  • branch, verdicts all five of the issue's acceptance criteria WORKS —
    including a live probe of account creation against a mock Ramp API (values
    resolved by name and by Ramp ID; a value matching nothing fails creation
    with a clear error and creates no user).
  • Known evidence limit, stated honestly: Ramp's exact 404-vs-400 behavior for

  • a missing department/location ID is taken from the official OpenAPI spec
    (400 on invalid item GETs) rather than a live Ramp response — the resolver
    treats both NotFound and InvalidArgument from the ID probe as "try it as
    a name", so either vendor behavior lands in the same fail-closed path.

    What to look at hardest

  • pkg/connector/account_attributes.go — the resolution contract

  • (flag-off guard, probe-then-name-walk, ambiguity, page cap) is where every
    acceptance criterion lives; the tests assert it path by path.
  • Scope gating in cmd/baton-ramp/main.go — confirm the flag-off path

  • leaves baseRampOAuthScopes untouched.
  • pkg/connector/users.go ordering — AlreadyExistsResult must stay

  • before resolution so a re-run for an existing user never re-resolves
    attributes.
  • specs/openapi.json — copied from docs.ramp.com; confirm the six

  • operations match what Ramp serves today.
  • Dependency note: the branch carries the baton-sdk v0.42.7 uplift already

  • present on the base commit (vendored; no delta introduced by this PR).

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: c1-squire-dev[bot] Review duration: 28335m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #56"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%