CUST-WP-0061-T01: intake work-record entity (stage 3)
Fresh hub entity per the founder-reviewed decision (not a suggestions rename-bridge): kind: intake per canon/standards/work-record-types_v0.1.md, lifecycle open -> vetted -> routed -> closed(promoted|declined|absorbed). - api/models/base.py::new_uuid7 -- dependency-free RFC 9562 UUIDv7 generator (48-bit ms timestamp, version/variant bits, random remainder); existing tables keep new_uuid (UUIDv4) unchanged, this is opt-in for new work-record entities per the identity-layering canon - api/models/intake.py: Intake + IntakeNote ORM models, mirroring Decision's shape (topic/workplan/repo scope, lane, status, outcome, promoted_to back-link); CHECK constraints enforce scope-required, closed-requires-outcome, promoted-requires-promoted_to at the DB level - migrations/a7c3e9f1b4d2: intakes + intake_notes tables, 3 enum types - api/routers/intake.py: list/create/get/patch + /route + /close + /notes actions, mirroring decisions.py's pattern (409 on invalid transitions, progress event on close) - api/schemas/intake.py: Pydantic create/update/route/close/note schemas - mcp_server/server.py: create_intake, list_intakes, route_intake, close_intake tool wrappers - tests/test_intake.py: 12 tests against the real Postgres test DB (create/list/scope-validation, full lifecycle incl. 409s and the promoted-requires-promoted_to constraint, notes, UUIDv7 verification) Verified live against the running dev API + DB (not just pytest): applied the migration, restarted the MCP server, and ran a full create -> route -> close cycle over the real REST endpoints. No regressions: full existing suite (test_routers_core, test_suggestions, test_mcp_smoke, test_mcp_write_tools, test_mcp_registration, test_consistency_check, test_consistency_sweep) all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
4541f1d6fc
commit
88ba666c95
9 changed files with 789 additions and 1 deletions
|
|
@ -1013,6 +1013,114 @@ def resolve_decision(
|
|||
return _json_result(decision)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def create_intake(
|
||||
title: str,
|
||||
topic_id: str | None = None,
|
||||
workplan_id: str | None = None,
|
||||
repo_id: str | None = None,
|
||||
description: str | None = None,
|
||||
lane: str = "green",
|
||||
origin: str | None = None,
|
||||
origin_ref: str | None = None,
|
||||
source_repo_path: str | None = None,
|
||||
) -> str:
|
||||
"""Record an intake item — a spark: idea, finding, directive, or
|
||||
request (work-record kind `intake`, canon/standards/
|
||||
work-record-types_v0.1.md). Lifecycle: open -> vetted -> routed ->
|
||||
closed(promoted|declined|absorbed).
|
||||
|
||||
Args:
|
||||
title: short description of the intake item
|
||||
topic_id: optional topic UUID (at least one of topic_id/workplan_id/repo_id required)
|
||||
workplan_id: optional workplan UUID to scope this to
|
||||
repo_id: optional managed-repo UUID to scope this to
|
||||
description: optional longer context
|
||||
lane: autonomy lane — green | blue | yellow | orange | red
|
||||
origin: free-text source of the finding (e.g. "mail-triage", "founder-directive")
|
||||
origin_ref: stable reference into the origin (e.g. a mail-log row id)
|
||||
source_repo_path: repo-relative path of the file this was authored in, if known
|
||||
"""
|
||||
intake = _post("/intakes", {
|
||||
"title": title,
|
||||
"topic_id": topic_id,
|
||||
"workplan_id": workplan_id,
|
||||
"repo_id": repo_id,
|
||||
"description": description,
|
||||
"lane": lane,
|
||||
"origin": origin,
|
||||
"origin_ref": origin_ref,
|
||||
"source_repo_path": source_repo_path,
|
||||
})
|
||||
if error := _response_error("create_intake", intake, ("id",)):
|
||||
return _json_result(error)
|
||||
return _json_result(intake)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def list_intakes(
|
||||
topic_id: str | None = None,
|
||||
workplan_id: str | None = None,
|
||||
repo_id: str | None = None,
|
||||
status: str | None = None,
|
||||
) -> str:
|
||||
"""List intake items, optionally filtered by scope and/or status.
|
||||
|
||||
Args:
|
||||
topic_id: optional topic UUID
|
||||
workplan_id: optional workplan UUID
|
||||
repo_id: optional managed-repo UUID
|
||||
status: open | vetted | routed | closed
|
||||
"""
|
||||
return _json_result(_get("/intakes", {
|
||||
"topic_id": topic_id,
|
||||
"workplan_id": workplan_id,
|
||||
"repo_id": repo_id,
|
||||
"status_": status,
|
||||
}))
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def route_intake(intake_id: str, routed_note: str | None = None) -> str:
|
||||
"""Move an intake from open/vetted into routed — the state that makes
|
||||
it eligible for promotion into a workplan, task, decision, or
|
||||
engagement.
|
||||
|
||||
Args:
|
||||
intake_id: UUID of the intake item
|
||||
routed_note: optional note on where/how it should be routed
|
||||
"""
|
||||
result = _post(f"/intakes/{intake_id}/route", {"routed_note": routed_note})
|
||||
if error := _response_error("route_intake", result, ("id",)):
|
||||
return _json_result(error)
|
||||
return _json_result(result)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def close_intake(
|
||||
intake_id: str,
|
||||
outcome: str,
|
||||
promoted_to: str | None = None,
|
||||
note: str | None = None,
|
||||
) -> str:
|
||||
"""Close an intake item with an outcome.
|
||||
|
||||
Args:
|
||||
intake_id: UUID of the intake item
|
||||
outcome: promoted | declined | absorbed
|
||||
promoted_to: canonical id of the record it became (required if outcome=promoted)
|
||||
note: optional closing note
|
||||
"""
|
||||
result = _post(f"/intakes/{intake_id}/close", {
|
||||
"outcome": outcome,
|
||||
"promoted_to": promoted_to,
|
||||
"note": note,
|
||||
})
|
||||
if error := _response_error("close_intake", result, ("id",)):
|
||||
return _json_result(error)
|
||||
return _json_result(result)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def add_progress_event(
|
||||
summary: str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue