fix(mcp): stage remote ingest by default
Default ticket, multipart, and text-note ingest entry points to staging without launching a job. Propagate WIKI_ARCHIVE_SOURCES from project configuration into the managed service environment.\n\nValidated with the full 206-test suite.
This commit is contained in:
@@ -209,6 +209,53 @@ class RemoteMcpServerTests(unittest.TestCase):
|
||||
self.assertEqual(data["uploads"][0]["sha256"], "sha256:" + hashlib.sha256(payload).hexdigest())
|
||||
self.assertNotIn("path", data["uploads"][0])
|
||||
|
||||
def test_http_upload_endpoint_stages_without_starting_job_by_default(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
manager = IngestManager(
|
||||
vault_path=root / "vault",
|
||||
project_root=root / "project",
|
||||
runtime_root=root / "runtime",
|
||||
)
|
||||
app = mcp_server.create_http_app(
|
||||
FakeApp(),
|
||||
"secret-token",
|
||||
ingest_manager=manager,
|
||||
)
|
||||
body, boundary = multipart_body(
|
||||
{"project": "bjd"},
|
||||
[("files", "drawing.pdf", "application/pdf", b"drawing")],
|
||||
)
|
||||
|
||||
with patch.object(
|
||||
manager,
|
||||
"start_ingest_job",
|
||||
side_effect=AssertionError("default upload staging must not start a job"),
|
||||
) as start_job:
|
||||
messages = run_asgi_http_request(
|
||||
app,
|
||||
method="POST",
|
||||
path="/mcp-ingest/uploads",
|
||||
headers=[
|
||||
(b"authorization", b"Bearer secret-token"),
|
||||
(
|
||||
b"content-type",
|
||||
f"multipart/form-data; boundary={boundary}".encode("ascii"),
|
||||
),
|
||||
],
|
||||
body=body,
|
||||
)
|
||||
|
||||
self.assertEqual(messages[0]["status"], 200)
|
||||
response = b"".join(
|
||||
message.get("body", b"")
|
||||
for message in messages
|
||||
if message["type"] == "http.response.body"
|
||||
)
|
||||
data = json.loads(response.decode("utf-8"))
|
||||
self.assertIsNone(data["job"])
|
||||
start_job.assert_not_called()
|
||||
|
||||
def test_http_upload_endpoint_creates_bundle_from_body_and_attachments(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
@@ -411,7 +458,6 @@ class RemoteMcpServerTests(unittest.TestCase):
|
||||
bundle_id="drawing-package-1",
|
||||
source_type="report_package",
|
||||
label="Customer drawing package",
|
||||
start_job=False,
|
||||
)
|
||||
app = mcp_server.create_http_app(FakeApp(), "secret-token", ingest_manager=manager)
|
||||
payload = b"ticket uploaded drawing"
|
||||
@@ -1419,6 +1465,9 @@ class RemoteMcpServerTests(unittest.TestCase):
|
||||
self.assertEqual(ticket["label"], "Customer drawing package")
|
||||
self.assertFalse(ticket["start_job"])
|
||||
self.assertEqual(instructions["preferred_upload_auth"], "upload_ticket")
|
||||
self.assertFalse(instructions["http_upload"]["start_job_default"])
|
||||
self.assertFalse(instructions["direct_text_tool"]["start_job_default"])
|
||||
self.assertIn("start_job=false", instructions["http_upload"]["curl_example"])
|
||||
self.assertEqual(instructions["http_upload"]["url"], "https://wiki.example.test/mcp-ingest/uploads")
|
||||
self.assertIn("body_text", instructions["http_upload"]["optional_fields"])
|
||||
self.assertIn("bundle_id", instructions["http_upload"]["optional_fields"])
|
||||
@@ -1588,14 +1637,19 @@ class RemoteMcpServerTests(unittest.TestCase):
|
||||
ingest_runtime_root=root / "runtime",
|
||||
ingest_manager=manager,
|
||||
)
|
||||
result = FakeMCP.tools["ingest_text_note"](
|
||||
text="Remote agent thought\n\nNeed to remember this.",
|
||||
title="Customer thought: ACME / risk",
|
||||
project="bjd",
|
||||
doc_type_hint="thought",
|
||||
note="captured from remote agent",
|
||||
start_job=False,
|
||||
)
|
||||
with patch.object(
|
||||
manager,
|
||||
"start_ingest_job",
|
||||
side_effect=AssertionError("default text staging must not start a job"),
|
||||
) as start_job:
|
||||
result = FakeMCP.tools["ingest_text_note"](
|
||||
text="Remote agent thought\n\nNeed to remember this.",
|
||||
title="Customer thought: ACME / risk",
|
||||
project="bjd",
|
||||
doc_type_hint="thought",
|
||||
note="captured from remote agent",
|
||||
)
|
||||
start_job.assert_not_called()
|
||||
payload_path = Path(manager._load_upload(result["uploads"][0]["upload_id"])["path"])
|
||||
payload = payload_path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user