feat(api): link_job_to_org agent tool (#375 follow-up) #379
No reviewers
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol!379
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "link-job-to-org-tool"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The agent tool follow-up from #375. An "earned" domain write tool (ADR-0030) mirroring
link_person_to_org, so the built-in agent (and MCP clients) can point a Job/Contract's employer at a tracked Organization.What's in it
link_job_to_org(safe_update, entityTypejob): input{ job_id, organization_id }. A job's employer is a column on the row (not a junction), so this is a scoped update — it setsorganization_idand snapshots the org's live name intocompany. Works for both jobs and contracts (same table).resolveJobOrganizationLinkresolver — a cross-user/missing org id is a 404 (don't leak existence) at both propose and apply; the job ownership check rejects another user's job the same way.create_job/update_jobtools still don't exposeorganizationId, so this dedicated, validated tool is the only agent path to link.Verification
typecheck✓ ·lint✓ ·openapi:check✓ (no REST change — agent tools aren't in the spec) ·api-client check✓ · semgrep ✓ 0 findings.testagainst both engines (ephemeral Postgres): 1268 passed, 0 skipped — incl. a dual-engine test (link snapshots the org name + resolves the live name on read; cross-user org id and cross-user job both → 404), and the existing registry/MCPtools/listtests still pass with the tool added.Known limitation (worth a follow-up)
Undoing a
link_job_to_orgfrom the activity screen is currently partial: the undo system's generic inverse isupdate_<entityType>=update_job, whose schema doesn't includeorganizationId, so the inverse restorescompanybut not the link (the job stays linked, showing the live org name). The clean fix is to add a validatedorganizationIdtoupdate_job/update_contract(which would also make the link first-class CRUD and fully undoable). I scoped that out to keep this focused; happy to file/take it.Part of #375.
🤖 Generated with Claude Code
📊 Test coverage
Patch coverage: no testable lines changed.
Overall (
app/,lib/,db/, excluding UI per ADR-0019):Soft thresholds per ADR-0019. Coverage is informational and does not block merge.