Preserve no-AST adapter bindings
This commit is contained in:
parent
bb13258861
commit
6c05607b14
7 changed files with 209 additions and 13 deletions
|
|
@ -366,6 +366,7 @@ class AdapterContractTests(unittest.TestCase):
|
|||
self.assertTrue(visual_logic["available"])
|
||||
self.assertEqual("entry", visual_logic["root"])
|
||||
self.assertEqual("return", visual_logic["edges"][0]["relation"])
|
||||
|
||||
loader.extract_calls.clear()
|
||||
cache_path = root / ".cache" / "incremental" / "extractions.json"
|
||||
cache_modified = cache_path.stat().st_mtime_ns
|
||||
|
|
@ -403,6 +404,20 @@ class AdapterContractTests(unittest.TestCase):
|
|||
index.get_node("guide.workflow")["node"]["source_path"],
|
||||
)
|
||||
|
||||
def test_no_ast_index_policy_rejects_logic_publication(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
project = AdapterProject(
|
||||
IncrementalLoader(root),
|
||||
cache_root=root / ".cache" / "no-ast",
|
||||
)
|
||||
|
||||
with self.assertRaises(DocForgeError) as captured:
|
||||
ProjectIndex(project, allow_logic=False).build()
|
||||
|
||||
self.assertEqual("adapter_policy_forbids_logic", captured.exception.code)
|
||||
self.assertFalse(project.descriptor.index_path.exists())
|
||||
|
||||
def test_fast_incremental_reads_reverify_a_changed_index_file(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
|
|
|
|||
|
|
@ -78,6 +78,44 @@ class DocForgeMcpTests(unittest.IsolatedAsyncioTestCase):
|
|||
)
|
||||
)
|
||||
|
||||
async def test_no_ast_binding_preserves_adapter_and_blocks_logic(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = self.copy_fixture("alpha", Path(directory))
|
||||
ProjectIndex(Project.open(root)).build()
|
||||
async with create_connected_server_and_client_session(
|
||||
create_server(root, no_ast=True), raise_exceptions=True
|
||||
) as session:
|
||||
bootstrap = await session.call_tool("docforge_bootstrap", {})
|
||||
contract = await session.call_tool("docforge_get_contract", {})
|
||||
logic = await session.call_tool(
|
||||
"docforge_get_logic", {"owner_node_id": "guide.workflow"}
|
||||
)
|
||||
|
||||
policy = bootstrap.structuredContent["adapter_policy"]
|
||||
self.assertEqual("preserve-no-ast", policy["mode"])
|
||||
self.assertEqual("forbidden", policy["ast_analysis"])
|
||||
self.assertEqual("forbidden", policy["logic_projection"])
|
||||
self.assertEqual("allowed", policy["incremental_extraction"])
|
||||
self.assertEqual(["docforge_get_logic"], policy["blocked_tools"])
|
||||
self.assertEqual(
|
||||
policy,
|
||||
bootstrap.structuredContent["binding"]["adapter_policy"],
|
||||
)
|
||||
self.assertIn(
|
||||
"preserve the current adapter",
|
||||
bootstrap.structuredContent["recommended_workflow"][1],
|
||||
)
|
||||
self.assertEqual(policy, contract.structuredContent["adapter_policy"])
|
||||
self.assertIn(
|
||||
"adapter_ast_upgrade",
|
||||
contract.structuredContent["excluded_operations"],
|
||||
)
|
||||
self.assertEqual("error", logic.structuredContent["status"])
|
||||
self.assertEqual(
|
||||
"adapter_policy_forbids_logic",
|
||||
logic.structuredContent["error"]["code"],
|
||||
)
|
||||
|
||||
async def test_every_read_tool_returns_scoped_structured_results(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = self.copy_fixture("alpha", Path(directory))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue