seer-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/LICENSE +176 -0
- package/README.md +272 -0
- package/README_dev.md +199 -0
- package/dist/bundle/ci.d.ts +47 -0
- package/dist/bundle/ci.d.ts.map +1 -0
- package/dist/bundle/ci.js +113 -0
- package/dist/bundle/ci.js.map +1 -0
- package/dist/bundle/contract.d.ts +111 -0
- package/dist/bundle/contract.d.ts.map +1 -0
- package/dist/bundle/contract.js +352 -0
- package/dist/bundle/contract.js.map +1 -0
- package/dist/bundle/export.d.ts +36 -0
- package/dist/bundle/export.d.ts.map +1 -0
- package/dist/bundle/export.js +152 -0
- package/dist/bundle/export.js.map +1 -0
- package/dist/bundle/external.d.ts +66 -0
- package/dist/bundle/external.d.ts.map +1 -0
- package/dist/bundle/external.js +238 -0
- package/dist/bundle/external.js.map +1 -0
- package/dist/bundle/format.d.ts +94 -0
- package/dist/bundle/format.d.ts.map +1 -0
- package/dist/bundle/format.js +42 -0
- package/dist/bundle/format.js.map +1 -0
- package/dist/bundle/import.d.ts +49 -0
- package/dist/bundle/import.d.ts.map +1 -0
- package/dist/bundle/import.js +116 -0
- package/dist/bundle/import.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +1402 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +48 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +284 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/db/schema.d.ts +3 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +616 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/store.d.ts +1011 -0
- package/dist/db/store.d.ts.map +1 -0
- package/dist/db/store.js +3888 -0
- package/dist/db/store.js.map +1 -0
- package/dist/graph/pagerank.d.ts +9 -0
- package/dist/graph/pagerank.d.ts.map +1 -0
- package/dist/graph/pagerank.js +47 -0
- package/dist/graph/pagerank.js.map +1 -0
- package/dist/indexer/architecture.d.ts +72 -0
- package/dist/indexer/architecture.d.ts.map +1 -0
- package/dist/indexer/architecture.js +112 -0
- package/dist/indexer/architecture.js.map +1 -0
- package/dist/indexer/behavior.d.ts +75 -0
- package/dist/indexer/behavior.d.ts.map +1 -0
- package/dist/indexer/behavior.js +395 -0
- package/dist/indexer/behavior.js.map +1 -0
- package/dist/indexer/boundaries.d.ts +60 -0
- package/dist/indexer/boundaries.d.ts.map +1 -0
- package/dist/indexer/boundaries.js +366 -0
- package/dist/indexer/boundaries.js.map +1 -0
- package/dist/indexer/churn.d.ts +15 -0
- package/dist/indexer/churn.d.ts.map +1 -0
- package/dist/indexer/churn.js +49 -0
- package/dist/indexer/churn.js.map +1 -0
- package/dist/indexer/classify.d.ts +9 -0
- package/dist/indexer/classify.d.ts.map +1 -0
- package/dist/indexer/classify.js +90 -0
- package/dist/indexer/classify.js.map +1 -0
- package/dist/indexer/context.d.ts +176 -0
- package/dist/indexer/context.d.ts.map +1 -0
- package/dist/indexer/context.js +193 -0
- package/dist/indexer/context.js.map +1 -0
- package/dist/indexer/continuity.d.ts +67 -0
- package/dist/indexer/continuity.d.ts.map +1 -0
- package/dist/indexer/continuity.js +288 -0
- package/dist/indexer/continuity.js.map +1 -0
- package/dist/indexer/detectchanges.d.ts +32 -0
- package/dist/indexer/detectchanges.d.ts.map +1 -0
- package/dist/indexer/detectchanges.js +74 -0
- package/dist/indexer/detectchanges.js.map +1 -0
- package/dist/indexer/discovery.d.ts +37 -0
- package/dist/indexer/discovery.d.ts.map +1 -0
- package/dist/indexer/discovery.js +136 -0
- package/dist/indexer/discovery.js.map +1 -0
- package/dist/indexer/externaldeps.d.ts +18 -0
- package/dist/indexer/externaldeps.d.ts.map +1 -0
- package/dist/indexer/externaldeps.js +288 -0
- package/dist/indexer/externaldeps.js.map +1 -0
- package/dist/indexer/freshness.d.ts +48 -0
- package/dist/indexer/freshness.d.ts.map +1 -0
- package/dist/indexer/freshness.js +128 -0
- package/dist/indexer/freshness.js.map +1 -0
- package/dist/indexer/git.d.ts +144 -0
- package/dist/indexer/git.d.ts.map +1 -0
- package/dist/indexer/git.js +444 -0
- package/dist/indexer/git.js.map +1 -0
- package/dist/indexer/index.d.ts +145 -0
- package/dist/indexer/index.d.ts.map +1 -0
- package/dist/indexer/index.js +930 -0
- package/dist/indexer/index.js.map +1 -0
- package/dist/indexer/modules.d.ts +62 -0
- package/dist/indexer/modules.d.ts.map +1 -0
- package/dist/indexer/modules.js +293 -0
- package/dist/indexer/modules.js.map +1 -0
- package/dist/indexer/preflight.d.ts +154 -0
- package/dist/indexer/preflight.d.ts.map +1 -0
- package/dist/indexer/preflight.js +399 -0
- package/dist/indexer/preflight.js.map +1 -0
- package/dist/indexer/protoScanner.d.ts +34 -0
- package/dist/indexer/protoScanner.d.ts.map +1 -0
- package/dist/indexer/protoScanner.js +133 -0
- package/dist/indexer/protoScanner.js.map +1 -0
- package/dist/indexer/risk.d.ts +115 -0
- package/dist/indexer/risk.d.ts.map +1 -0
- package/dist/indexer/risk.js +194 -0
- package/dist/indexer/risk.js.map +1 -0
- package/dist/indexer/serviceHostScanner.d.ts +25 -0
- package/dist/indexer/serviceHostScanner.d.ts.map +1 -0
- package/dist/indexer/serviceHostScanner.js +95 -0
- package/dist/indexer/serviceHostScanner.js.map +1 -0
- package/dist/indexer/serviceLinks.d.ts +105 -0
- package/dist/indexer/serviceLinks.d.ts.map +1 -0
- package/dist/indexer/serviceLinks.js +509 -0
- package/dist/indexer/serviceLinks.js.map +1 -0
- package/dist/indexer/shapehash.d.ts +98 -0
- package/dist/indexer/shapehash.d.ts.map +1 -0
- package/dist/indexer/shapehash.js +354 -0
- package/dist/indexer/shapehash.js.map +1 -0
- package/dist/indexer/skeleton.d.ts +15 -0
- package/dist/indexer/skeleton.d.ts.map +1 -0
- package/dist/indexer/skeleton.js +136 -0
- package/dist/indexer/skeleton.js.map +1 -0
- package/dist/indexer/symbolhistory.d.ts +41 -0
- package/dist/indexer/symbolhistory.d.ts.map +1 -0
- package/dist/indexer/symbolhistory.js +124 -0
- package/dist/indexer/symbolhistory.js.map +1 -0
- package/dist/indexer/watcher.d.ts +68 -0
- package/dist/indexer/watcher.d.ts.map +1 -0
- package/dist/indexer/watcher.js +179 -0
- package/dist/indexer/watcher.js.map +1 -0
- package/dist/mcp/server.d.ts +80 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +1610 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/parser/index.d.ts +8 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +33 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/languages/cpp.d.ts +3 -0
- package/dist/parser/languages/cpp.d.ts.map +1 -0
- package/dist/parser/languages/cpp.js +350 -0
- package/dist/parser/languages/cpp.js.map +1 -0
- package/dist/parser/languages/csharp.d.ts +3 -0
- package/dist/parser/languages/csharp.d.ts.map +1 -0
- package/dist/parser/languages/csharp.js +239 -0
- package/dist/parser/languages/csharp.js.map +1 -0
- package/dist/parser/languages/go.d.ts +3 -0
- package/dist/parser/languages/go.d.ts.map +1 -0
- package/dist/parser/languages/go.js +259 -0
- package/dist/parser/languages/go.js.map +1 -0
- package/dist/parser/languages/java.d.ts +3 -0
- package/dist/parser/languages/java.d.ts.map +1 -0
- package/dist/parser/languages/java.js +391 -0
- package/dist/parser/languages/java.js.map +1 -0
- package/dist/parser/languages/python.d.ts +3 -0
- package/dist/parser/languages/python.d.ts.map +1 -0
- package/dist/parser/languages/python.js +396 -0
- package/dist/parser/languages/python.js.map +1 -0
- package/dist/parser/languages/rust.d.ts +3 -0
- package/dist/parser/languages/rust.d.ts.map +1 -0
- package/dist/parser/languages/rust.js +159 -0
- package/dist/parser/languages/rust.js.map +1 -0
- package/dist/parser/languages/typescript.d.ts +3 -0
- package/dist/parser/languages/typescript.d.ts.map +1 -0
- package/dist/parser/languages/typescript.js +1442 -0
- package/dist/parser/languages/typescript.js.map +1 -0
- package/dist/parser/parserContext.d.ts +77 -0
- package/dist/parser/parserContext.d.ts.map +1 -0
- package/dist/parser/parserContext.js +354 -0
- package/dist/parser/parserContext.js.map +1 -0
- package/dist/parser/walker.d.ts +81 -0
- package/dist/parser/walker.d.ts.map +1 -0
- package/dist/parser/walker.js +217 -0
- package/dist/parser/walker.js.map +1 -0
- package/dist/parser/worker.d.ts +66 -0
- package/dist/parser/worker.d.ts.map +1 -0
- package/dist/parser/worker.js +129 -0
- package/dist/parser/worker.js.map +1 -0
- package/dist/parser/workerpool.d.ts +107 -0
- package/dist/parser/workerpool.d.ts.map +1 -0
- package/dist/parser/workerpool.js +383 -0
- package/dist/parser/workerpool.js.map +1 -0
- package/dist/scip/format.d.ts +87 -0
- package/dist/scip/format.d.ts.map +1 -0
- package/dist/scip/format.js +31 -0
- package/dist/scip/format.js.map +1 -0
- package/dist/scip/import.d.ts +37 -0
- package/dist/scip/import.d.ts.map +1 -0
- package/dist/scip/import.js +180 -0
- package/dist/scip/import.js.map +1 -0
- package/dist/types.d.ts +392 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/docs/architecture.md +105 -0
- package/docs/benchmarks/methodology.md +134 -0
- package/docs/benchmarks/raw-results.md +71 -0
- package/docs/benchmarks.md +74 -0
- package/docs/cli.md +148 -0
- package/docs/examples/behavior-tests.md +70 -0
- package/docs/examples/change-history.md +85 -0
- package/docs/examples/pre-edit-context.md +81 -0
- package/docs/examples/service-links.md +88 -0
- package/docs/examples.md +80 -0
- package/docs/faq.md +70 -0
- package/docs/internals.md +104 -0
- package/docs/languages.md +70 -0
- package/docs/limits.md +52 -0
- package/docs/mcp.md +199 -0
- package/docs/quickstart.md +119 -0
- package/docs/testing.md +123 -0
- package/docs/tools.md +115 -0
- package/package.json +52 -0
- package/research-codebase.md +578 -0
- package/seer-cli-docs.md +326 -0
- package/seer-master-guide.md +246 -0
- package/src/bundle/ci.ts +141 -0
- package/src/bundle/contract.ts +387 -0
- package/src/bundle/export.ts +175 -0
- package/src/bundle/external.ts +285 -0
- package/src/bundle/format.ts +92 -0
- package/src/bundle/import.ts +157 -0
- package/src/cli/index.ts +1249 -0
- package/src/cli/init.ts +389 -0
- package/src/db/schema.ts +614 -0
- package/src/db/store.ts +4306 -0
- package/src/graph/pagerank.ts +53 -0
- package/src/indexer/architecture.ts +148 -0
- package/src/indexer/behavior.ts +466 -0
- package/src/indexer/boundaries.ts +374 -0
- package/src/indexer/churn.ts +58 -0
- package/src/indexer/classify.ts +96 -0
- package/src/indexer/context.ts +340 -0
- package/src/indexer/continuity.ts +322 -0
- package/src/indexer/detectchanges.ts +94 -0
- package/src/indexer/discovery.ts +176 -0
- package/src/indexer/externaldeps.ts +243 -0
- package/src/indexer/freshness.ts +166 -0
- package/src/indexer/git.ts +453 -0
- package/src/indexer/index.ts +1092 -0
- package/src/indexer/modules.ts +358 -0
- package/src/indexer/preflight.ts +548 -0
- package/src/indexer/protoScanner.ts +147 -0
- package/src/indexer/risk.ts +304 -0
- package/src/indexer/serviceHostScanner.ts +92 -0
- package/src/indexer/serviceLinks.ts +543 -0
- package/src/indexer/shapehash.ts +370 -0
- package/src/indexer/skeleton.ts +169 -0
- package/src/indexer/symbolhistory.ts +172 -0
- package/src/indexer/watcher.ts +206 -0
- package/src/mcp/server.ts +1659 -0
- package/src/parser/index.ts +37 -0
- package/src/parser/languages/cpp.ts +361 -0
- package/src/parser/languages/csharp.ts +235 -0
- package/src/parser/languages/go.ts +259 -0
- package/src/parser/languages/java.ts +382 -0
- package/src/parser/languages/python.ts +370 -0
- package/src/parser/languages/rust.ts +164 -0
- package/src/parser/languages/typescript.ts +1435 -0
- package/src/parser/parserContext.ts +392 -0
- package/src/parser/walker.ts +306 -0
- package/src/parser/worker.ts +181 -0
- package/src/parser/workerpool.ts +448 -0
- package/src/scip/format.ts +83 -0
- package/src/scip/import.ts +216 -0
- package/src/types.ts +457 -0
- package/tests/benchmark-service-links.ts +244 -0
- package/tests/bug-regressions.ts +626 -0
- package/tests/filters.ts +264 -0
- package/tests/fixtures/Counter.tsx +38 -0
- package/tests/fixtures/caller.ts +7 -0
- package/tests/fixtures/collisions.ts +23 -0
- package/tests/fixtures/local_helper.ts +5 -0
- package/tests/fixtures/overloads.java +17 -0
- package/tests/fixtures/remote_helper.ts +4 -0
- package/tests/fixtures/sample.c +15 -0
- package/tests/fixtures/sample.cpp +47 -0
- package/tests/fixtures/sample.cs +62 -0
- package/tests/fixtures/sample.go +68 -0
- package/tests/fixtures/sample.h +30 -0
- package/tests/fixtures/sample.java +85 -0
- package/tests/fixtures/sample.py +46 -0
- package/tests/fixtures/sample.rs +78 -0
- package/tests/fixtures/sample.ts +76 -0
- package/tests/fixtures-service/HttpClients.cs +30 -0
- package/tests/fixtures-service/HttpClients.java +24 -0
- package/tests/fixtures-service/billing.ts +15 -0
- package/tests/fixtures-service/docker-compose.yml +15 -0
- package/tests/fixtures-service/gateway.ts +10 -0
- package/tests/fixtures-service/get_user.ts +11 -0
- package/tests/fixtures-service/graphql_client.ts +63 -0
- package/tests/fixtures-service/graphql_server.ts +30 -0
- package/tests/fixtures-service/grpc_client.go +30 -0
- package/tests/fixtures-service/http_clients.go +23 -0
- package/tests/fixtures-service/http_clients.py +38 -0
- package/tests/fixtures-service/http_clients.ts +49 -0
- package/tests/fixtures-service/k8s/payment-service.yaml +22 -0
- package/tests/fixtures-service/k8s_calls.ts +20 -0
- package/tests/fixtures-service/messaging.ts +87 -0
- package/tests/fixtures-service/trpc_client.ts +39 -0
- package/tests/fixtures-service/trpc_server.ts +39 -0
- package/tests/fixtures-service/user_service.proto +33 -0
- package/tests/fixtures-trackcd/Cargo.toml +11 -0
- package/tests/fixtures-trackcd/SpringController.java +36 -0
- package/tests/fixtures-trackcd/auth_service.ts +19 -0
- package/tests/fixtures-trackcd/complex_module.py +50 -0
- package/tests/fixtures-trackcd/express_app.js +30 -0
- package/tests/fixtures-trackcd/fastapi_app.py +49 -0
- package/tests/fixtures-trackcd/fastify_object_routes.js +32 -0
- package/tests/fixtures-trackcd/go.mod +8 -0
- package/tests/fixtures-trackcd/package.json +15 -0
- package/tests/fixtures-trackcd/requirements.txt +4 -0
- package/tests/fixtures-trackcd/tests/auth_service.test.ts +13 -0
- package/tests/fixtures-tracke/auth/AuthService.ts +23 -0
- package/tests/fixtures-tracke/auth/crypto.ts +7 -0
- package/tests/fixtures-tracke/billing/Billing.ts +20 -0
- package/tests/fixtures-tracke/billing/Invoice.ts +10 -0
- package/tests/fixtures-tracke/billing/server.ts +17 -0
- package/tests/fixtures-tracke/package.json +7 -0
- package/tests/fixtures-tracke/tests/auth.test.ts +23 -0
- package/tests/fixtures-tracke/tests/billing.test.ts +14 -0
- package/tests/fixtures-trackf/package.json +5 -0
- package/tests/fixtures-trackf/src/auth.ts +26 -0
- package/tests/fixtures-trackf/src/handlers.ts +35 -0
- package/tests/fixtures-tracki/billing/routes.ts +12 -0
- package/tests/fixtures-tracki/gateway/client.ts +13 -0
- package/tests/git-features.ts +267 -0
- package/tests/init.ts +141 -0
- package/tests/mcp-jit.ts +130 -0
- package/tests/mcp-smoke.ts +191 -0
- package/tests/mcp-trackcd.ts +169 -0
- package/tests/mcp-tracke.ts +229 -0
- package/tests/mcp-trackf.ts +330 -0
- package/tests/mcp-trackg.ts +219 -0
- package/tests/mcp-tracki.ts +174 -0
- package/tests/mcp-watcher.ts +126 -0
- package/tests/optspec.ts +194 -0
- package/tests/parallel-index.ts +333 -0
- package/tests/parallel-read.ts +125 -0
- package/tests/parallel-recovery.ts +241 -0
- package/tests/perf-callers.ts +145 -0
- package/tests/query-parity.ts +184 -0
- package/tests/query-perf.ts +55 -0
- package/tests/scale-parallel-parity.ts +225 -0
- package/tests/scale-test.ts +523 -0
- package/tests/smoke.ts +396 -0
- package/tests/trackcd.ts +325 -0
- package/tests/tracke-collisions.ts +255 -0
- package/tests/tracke.ts +314 -0
- package/tests/trackf-bugs.ts +406 -0
- package/tests/trackf.ts +390 -0
- package/tests/trackg.ts +1372 -0
- package/tests/tracki-boundaries.ts +202 -0
- package/tests/tracki-continuity.ts +253 -0
- package/tests/tracki-contract-diff.ts +249 -0
- package/tests/tracki-external-bundles.ts +341 -0
- package/tests/tracki-preflight.ts +251 -0
- package/tests/verify-roles.ts +51 -0
- package/tests/worker-parity.ts +286 -0
- package/tests/worker-pool.ts +262 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Fixture: tRPC CLIENT CALLS. Each call goes through the trpc proxy and
|
|
2
|
+
// terminates in one of {query, mutate, useQuery, useMutation, subscribe}.
|
|
3
|
+
|
|
4
|
+
declare const trpc: any;
|
|
5
|
+
declare const api: any;
|
|
6
|
+
declare const someOtherObject: any;
|
|
7
|
+
|
|
8
|
+
export async function fetchUser(id: string): Promise<unknown> {
|
|
9
|
+
// operation = 'user.getById' — last segment 'getById' matches userRouter.getById
|
|
10
|
+
return trpc.user.getById.query({ id });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function createUserClient(name: string): Promise<unknown> {
|
|
14
|
+
return trpc.user.create.mutate({ name });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function deleteUserClient(id: string): Promise<unknown> {
|
|
18
|
+
return trpc.user.delete.mutate({ id });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// React-Query hook variants — useQuery / useMutation map to query / mutation.
|
|
22
|
+
export function useUser(id: string): unknown {
|
|
23
|
+
return trpc.user.getById.useQuery({ id });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function useCreateUser(): unknown {
|
|
27
|
+
return trpc.user.create.useMutation();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 'api' proxy variant — many monorepos name the root 'api'.
|
|
31
|
+
export function viaApi(id: string): unknown {
|
|
32
|
+
return api.user.getById.query({ id });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Negative case: an unrelated object that happens to have a .query method —
|
|
36
|
+
// must NOT be classified as a tRPC client call (root name isn't a known proxy).
|
|
37
|
+
export function notATrpcCall(): unknown {
|
|
38
|
+
return someOtherObject.foo.bar.query({});
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Fixture: tRPC procedure DEFINITIONS (server side).
|
|
2
|
+
// Each procedure has a deterministic key (`getById`, `create`, `delete`) — the
|
|
3
|
+
// resolver matches client `trpc.user.getById.query()` against the procedure
|
|
4
|
+
// whose operation == 'getById'.
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
declare const publicProcedure: any;
|
|
9
|
+
declare const protectedProcedure: any;
|
|
10
|
+
declare const router: any;
|
|
11
|
+
|
|
12
|
+
export function getUserById({ input }: any): any {
|
|
13
|
+
return { id: input.id };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createUser({ input }: any): any {
|
|
17
|
+
return { id: 'new', name: input.name };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function deleteUser({ input }: any): any {
|
|
21
|
+
return { ok: true };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const userRouter = router({
|
|
25
|
+
// operation = 'getById', method = QUERY
|
|
26
|
+
getById: publicProcedure
|
|
27
|
+
.input(z.object({ id: z.string() }))
|
|
28
|
+
.query(getUserById),
|
|
29
|
+
|
|
30
|
+
// operation = 'create', method = MUTATION
|
|
31
|
+
create: protectedProcedure
|
|
32
|
+
.input(z.object({ name: z.string() }))
|
|
33
|
+
.mutation(createUser),
|
|
34
|
+
|
|
35
|
+
// operation = 'delete', method = MUTATION (inline arrow handler)
|
|
36
|
+
delete: protectedProcedure
|
|
37
|
+
.input(z.object({ id: z.string() }))
|
|
38
|
+
.mutation(({ input }: any) => deleteUser({ input })),
|
|
39
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Test fixture for gRPC service detection.
|
|
2
|
+
// The proto scanner should emit one route per rpc with operation="Service/Method".
|
|
3
|
+
|
|
4
|
+
syntax = "proto3";
|
|
5
|
+
|
|
6
|
+
package user.v1;
|
|
7
|
+
|
|
8
|
+
service UserService {
|
|
9
|
+
// Single response RPC
|
|
10
|
+
rpc GetUser (GetUserRequest) returns (GetUserResponse);
|
|
11
|
+
// Server-streaming RPC
|
|
12
|
+
rpc ListUsers (ListUsersRequest) returns (stream User);
|
|
13
|
+
// Mutation-style RPC with HTTP annotation
|
|
14
|
+
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse) {
|
|
15
|
+
option (google.api.http) = { post: "/v1/users" body: "*" };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
service AuthService {
|
|
20
|
+
rpc Login (LoginRequest) returns (LoginResponse);
|
|
21
|
+
rpc Logout (LogoutRequest) returns (LogoutResponse);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
message GetUserRequest { string id = 1; }
|
|
25
|
+
message GetUserResponse { string id = 1; string name = 2; }
|
|
26
|
+
message ListUsersRequest {}
|
|
27
|
+
message User { string id = 1; string name = 2; }
|
|
28
|
+
message CreateUserRequest { string name = 1; }
|
|
29
|
+
message CreateUserResponse { string id = 1; }
|
|
30
|
+
message LoginRequest { string username = 1; string password = 2; }
|
|
31
|
+
message LoginResponse { string token = 1; }
|
|
32
|
+
message LogoutRequest { string token = 1; }
|
|
33
|
+
message LogoutResponse { bool ok = 1; }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Spring Boot mapping annotations + System.getenv.
|
|
2
|
+
package com.example.demo;
|
|
3
|
+
|
|
4
|
+
import org.springframework.web.bind.annotation.*;
|
|
5
|
+
|
|
6
|
+
@RestController
|
|
7
|
+
@RequestMapping("/api")
|
|
8
|
+
public class SpringController {
|
|
9
|
+
|
|
10
|
+
@GetMapping("/users")
|
|
11
|
+
public String listUsers() {
|
|
12
|
+
String db = System.getenv("DATABASE_URL");
|
|
13
|
+
if (db == null) {
|
|
14
|
+
return "no-db";
|
|
15
|
+
} else if (db.startsWith("postgres")) {
|
|
16
|
+
return "pg";
|
|
17
|
+
} else {
|
|
18
|
+
return "other";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@PostMapping("/users")
|
|
23
|
+
public String createUser(@RequestBody String body) {
|
|
24
|
+
return "created";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@DeleteMapping("/users/{id}")
|
|
28
|
+
public String deleteUser(@PathVariable String id) {
|
|
29
|
+
return "deleted";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@RequestMapping(value = "/items", method = RequestMethod.GET)
|
|
33
|
+
public String listItems() {
|
|
34
|
+
return "items";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Used by tests directory below — to verify test-edge synthesis works.
|
|
2
|
+
export class AuthService {
|
|
3
|
+
login(username: string, password: string): boolean {
|
|
4
|
+
if (!username || !password) return false;
|
|
5
|
+
return validateCredentials(username, password);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
logout(token: string): void {
|
|
9
|
+
invalidateToken(token);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validateCredentials(username: string, password: string): boolean {
|
|
14
|
+
return username === password;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function invalidateToken(_token: string): void {
|
|
18
|
+
// no-op
|
|
19
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Complexity fixture: deliberately nested branches for cyclomatic / cognitive tests.
|
|
2
|
+
|
|
3
|
+
def simple_function(x):
|
|
4
|
+
return x + 1
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def branchy_function(x, y):
|
|
8
|
+
if x > 0:
|
|
9
|
+
if y > 0:
|
|
10
|
+
if x > y:
|
|
11
|
+
return "x"
|
|
12
|
+
else:
|
|
13
|
+
return "y"
|
|
14
|
+
else:
|
|
15
|
+
return "x-only"
|
|
16
|
+
elif x < 0:
|
|
17
|
+
return "neg"
|
|
18
|
+
else:
|
|
19
|
+
return "zero"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def loopy_function(items):
|
|
23
|
+
total = 0
|
|
24
|
+
for item in items:
|
|
25
|
+
if item > 0:
|
|
26
|
+
for sub in item:
|
|
27
|
+
if sub != 0:
|
|
28
|
+
total += sub
|
|
29
|
+
else:
|
|
30
|
+
continue
|
|
31
|
+
elif item < 0:
|
|
32
|
+
try:
|
|
33
|
+
total -= item
|
|
34
|
+
except Exception:
|
|
35
|
+
pass
|
|
36
|
+
return total
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Calculator:
|
|
40
|
+
def add(self, a, b):
|
|
41
|
+
return a + b
|
|
42
|
+
|
|
43
|
+
def divide(self, a, b):
|
|
44
|
+
if b == 0:
|
|
45
|
+
raise ValueError("zero")
|
|
46
|
+
if a < 0 and b < 0:
|
|
47
|
+
return abs(a) / abs(b)
|
|
48
|
+
elif a < 0:
|
|
49
|
+
return -abs(a) / b
|
|
50
|
+
return a / b
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Express-style route registrations for the route extractor test.
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const app = express();
|
|
4
|
+
|
|
5
|
+
function listUsers(req, res) {
|
|
6
|
+
const dbUrl = process.env.DATABASE_URL;
|
|
7
|
+
const timeoutMs = process.env["TIMEOUT_MS"];
|
|
8
|
+
if (req.query.active) {
|
|
9
|
+
return res.json({ active: true });
|
|
10
|
+
} else if (req.query.archived) {
|
|
11
|
+
return res.json({ archived: true });
|
|
12
|
+
} else {
|
|
13
|
+
return res.json({ all: true });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createUser(req, res) {
|
|
18
|
+
return res.status(201).json({ created: true });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function deleteUser(req, res) {
|
|
22
|
+
return res.status(204).end();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
app.get('/users', listUsers);
|
|
26
|
+
app.post('/users', createUser);
|
|
27
|
+
app.delete('/users/:id', deleteUser);
|
|
28
|
+
app.put('/users/:id', (req, res) => res.json({}));
|
|
29
|
+
|
|
30
|
+
module.exports = app;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# FastAPI + Flask route + env var fixture.
|
|
2
|
+
import os
|
|
3
|
+
from fastapi import FastAPI
|
|
4
|
+
from flask import Flask, request
|
|
5
|
+
|
|
6
|
+
app = FastAPI()
|
|
7
|
+
flask_app = Flask(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_db_url():
|
|
11
|
+
return os.getenv("DATABASE_URL", "sqlite:///dev.db")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def feature_flag():
|
|
15
|
+
return os.environ.get("FEATURE_FLAG", "off")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def secret_key():
|
|
19
|
+
return os.environ["SECRET_KEY"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.get("/items/{item_id}")
|
|
23
|
+
def read_item(item_id: int):
|
|
24
|
+
if item_id < 0:
|
|
25
|
+
return {"error": "negative"}
|
|
26
|
+
elif item_id == 0:
|
|
27
|
+
return {"zero": True}
|
|
28
|
+
else:
|
|
29
|
+
for i in range(item_id):
|
|
30
|
+
if i % 2 == 0:
|
|
31
|
+
continue
|
|
32
|
+
return {"item_id": item_id, "url": get_db_url()}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@app.post("/items")
|
|
36
|
+
def create_item(name: str):
|
|
37
|
+
return {"name": name, "key": secret_key()}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@flask_app.route("/health")
|
|
41
|
+
def health():
|
|
42
|
+
return {"ok": True}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@flask_app.route("/users", methods=["GET", "POST"])
|
|
46
|
+
def users_handler():
|
|
47
|
+
if request.method == "POST":
|
|
48
|
+
return {"created": True}
|
|
49
|
+
return {"list": []}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Fastify object-style route registrations — regression fixture for the
|
|
2
|
+
// `app.route({ method, url, handler })` shape that was claimed-but-not-
|
|
3
|
+
// implemented before bug 6 was fixed.
|
|
4
|
+
const fastify = require('fastify');
|
|
5
|
+
const app = fastify();
|
|
6
|
+
|
|
7
|
+
function getThing(req, reply) { return { ok: true }; }
|
|
8
|
+
function upsertThing(req, reply) { return { upserted: true }; }
|
|
9
|
+
function deleteThing(req, reply) { return { deleted: true }; }
|
|
10
|
+
|
|
11
|
+
// Single-method object form
|
|
12
|
+
app.route({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
url: '/things/:id',
|
|
15
|
+
handler: getThing,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Multi-method object form (array of methods → one route each)
|
|
19
|
+
app.route({
|
|
20
|
+
method: ['PUT', 'PATCH'],
|
|
21
|
+
url: '/things/:id',
|
|
22
|
+
handler: upsertThing,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Order of fields shouldn't matter — handler first, url last.
|
|
26
|
+
app.route({
|
|
27
|
+
handler: deleteThing,
|
|
28
|
+
method: 'DELETE',
|
|
29
|
+
url: '/things/:id',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
module.exports = app;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "trackcd-fixture",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"express": "^4.18.2",
|
|
6
|
+
"lodash": "^4.17.21"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"jest": "^29.0.0",
|
|
10
|
+
"typescript": "^5.0.0"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"react": "^18.0.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Test file — `tests/` directory triggers role='test' classification.
|
|
2
|
+
// Calls into AuthService.login + validateCredentials should produce 'tests' edges.
|
|
3
|
+
import { AuthService, validateCredentials } from '../auth_service';
|
|
4
|
+
|
|
5
|
+
function testAuthServiceLogin() {
|
|
6
|
+
const svc = new AuthService();
|
|
7
|
+
const ok = svc.login('alice', 'alice');
|
|
8
|
+
return ok;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function testValidateCredentials() {
|
|
12
|
+
return validateCredentials('foo', 'foo');
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Auth module entry point used by tests + billing.
|
|
2
|
+
import { hashPassword } from './crypto';
|
|
3
|
+
|
|
4
|
+
export class AuthService {
|
|
5
|
+
login(username: string, password: string): boolean {
|
|
6
|
+
if (!username || !password) return false;
|
|
7
|
+
const hashed = hashPassword(password);
|
|
8
|
+
return validateCredentials(username, hashed);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
logout(token: string): void {
|
|
12
|
+
invalidateToken(token);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function validateCredentials(username: string, password: string): boolean {
|
|
17
|
+
// Trivial check — fixture only.
|
|
18
|
+
return username.length > 0 && password.length > 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function invalidateToken(_token: string): void {
|
|
22
|
+
// no-op
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Tiny helper kept inside the auth module so the clusterer sees a
|
|
2
|
+
// same-directory shared dependency.
|
|
3
|
+
export function hashPassword(pw: string): string {
|
|
4
|
+
let h = 0;
|
|
5
|
+
for (let i = 0; i < pw.length; i++) h = (h * 31 + pw.charCodeAt(i)) | 0;
|
|
6
|
+
return String(h);
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Billing module — imports auth so the file graph has a strong
|
|
2
|
+
// billing → auth dependency.
|
|
3
|
+
import { AuthService } from '../auth/AuthService';
|
|
4
|
+
import { Invoice, formatAmount } from './Invoice';
|
|
5
|
+
|
|
6
|
+
export class BillingService {
|
|
7
|
+
private auth = new AuthService();
|
|
8
|
+
|
|
9
|
+
chargeFor(userId: string, amountCents: number): Invoice | null {
|
|
10
|
+
const ok = this.auth.login(userId, 'token');
|
|
11
|
+
if (!ok) return null;
|
|
12
|
+
const inv = new Invoice(userId, amountCents);
|
|
13
|
+
inv.finalize();
|
|
14
|
+
return inv;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function summariseAmount(c: number): string {
|
|
19
|
+
return formatAmount(c);
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function formatAmount(cents: number): string {
|
|
2
|
+
return `$${(cents / 100).toFixed(2)}`;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export class Invoice {
|
|
6
|
+
constructor(public userId: string, public amountCents: number) {}
|
|
7
|
+
finalize(): void {
|
|
8
|
+
if (this.amountCents <= 0) throw new Error('non-positive');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Express server for billing. `chargeCustomer` is the single canonical
|
|
2
|
+
// route handler — it lives in the same file as the `app.post` call so
|
|
3
|
+
// the route resolver (which links handlers by same-file name lookup)
|
|
4
|
+
// attaches the route to it. That drives the "routeExposed" signal in
|
|
5
|
+
// seer_risk.
|
|
6
|
+
import express from 'express';
|
|
7
|
+
import { BillingService } from './Billing';
|
|
8
|
+
|
|
9
|
+
export const app = express();
|
|
10
|
+
|
|
11
|
+
export function chargeCustomer(req: any, res: any): void {
|
|
12
|
+
const svc = new BillingService();
|
|
13
|
+
const inv = svc.chargeFor(req.body.userId, req.body.amountCents);
|
|
14
|
+
res.json({ ok: inv !== null });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
app.post('/charge', chargeCustomer);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Direct test of validateCredentials + login. Calls into auth so the
|
|
2
|
+
// 'tests' edge synthesizer produces direct-coverage edges for the auth
|
|
3
|
+
// module, and so seer_behavior 2.0 surfaces this as a direct-call test.
|
|
4
|
+
import { AuthService, validateCredentials } from '../auth/AuthService';
|
|
5
|
+
|
|
6
|
+
function testValidateDirectly() {
|
|
7
|
+
const ok = validateCredentials('alice', 'secret');
|
|
8
|
+
expect(ok).toBe(true);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function testLoginExercisesValidate() {
|
|
12
|
+
// login() calls validateCredentials() internally — used by the
|
|
13
|
+
// ranker to compute indirect coverage of validateCredentials.
|
|
14
|
+
const svc = new AuthService();
|
|
15
|
+
const ok = svc.login('alice', 'secret');
|
|
16
|
+
expect(ok).toBe(true);
|
|
17
|
+
expect(typeof ok).toBe('boolean');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Standalone helper for assertion counting checks.
|
|
21
|
+
function expect(_v: unknown) {
|
|
22
|
+
return { toBe(_e: unknown): void { /* */ } };
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Direct billing test — covers chargeFor via BillingService. The
|
|
2
|
+
// clusterer should keep billing tests near the billing module thanks to
|
|
3
|
+
// the heavy test-edge weight.
|
|
4
|
+
import { BillingService } from '../billing/Billing';
|
|
5
|
+
|
|
6
|
+
function testChargeForReturnsInvoice() {
|
|
7
|
+
const svc = new BillingService();
|
|
8
|
+
const inv = svc.chargeFor('alice', 1000);
|
|
9
|
+
expect(inv).not.toBe(null);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function expect(_v: unknown) {
|
|
13
|
+
return { toBe(_e: unknown): void { /* */ }, not: { toBe(_e: unknown): void { /* */ } } };
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Auth module — used as the target of SCIP precision imports in tests.
|
|
2
|
+
|
|
3
|
+
export class AuthService {
|
|
4
|
+
login(user: string, pass: string): boolean {
|
|
5
|
+
if (!user || !pass) return false;
|
|
6
|
+
return this.checkCredentials(user, pass);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
logout(token: string): void {
|
|
10
|
+
if (!token) return;
|
|
11
|
+
this.revokeToken(token);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private checkCredentials(_user: string, _pass: string): boolean {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private revokeToken(_token: string): void {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function authenticate(user: string, pass: string): boolean {
|
|
24
|
+
const svc = new AuthService();
|
|
25
|
+
return svc.login(user, pass);
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Two structurally identical handlers with renamed identifiers — these
|
|
2
|
+
// should land in the same SimHash duplicate cluster.
|
|
3
|
+
|
|
4
|
+
export function fetchUserById(id: number): { ok: boolean; data: string | null } {
|
|
5
|
+
if (id <= 0) {
|
|
6
|
+
return { ok: false, data: null };
|
|
7
|
+
}
|
|
8
|
+
const result = lookupRecord('user', id);
|
|
9
|
+
if (!result) {
|
|
10
|
+
return { ok: false, data: null };
|
|
11
|
+
}
|
|
12
|
+
return { ok: true, data: result };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function fetchOrderById(orderId: number): { ok: boolean; data: string | null } {
|
|
16
|
+
if (orderId <= 0) {
|
|
17
|
+
return { ok: false, data: null };
|
|
18
|
+
}
|
|
19
|
+
const found = lookupRecord('order', orderId);
|
|
20
|
+
if (!found) {
|
|
21
|
+
return { ok: false, data: null };
|
|
22
|
+
}
|
|
23
|
+
return { ok: true, data: found };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// A wholly different function — should NOT cluster with the two above.
|
|
27
|
+
export function sumNumbers(values: number[]): number {
|
|
28
|
+
let total = 0;
|
|
29
|
+
for (const v of values) {
|
|
30
|
+
total = total + v;
|
|
31
|
+
}
|
|
32
|
+
return total;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare function lookupRecord(kind: string, id: number): string | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Billing service — owns POST /api/charge and GET /users/:id
|
|
2
|
+
declare const app: any;
|
|
3
|
+
|
|
4
|
+
export function chargeHandler(req: any, res: any): unknown {
|
|
5
|
+
return res.send({ charged: true });
|
|
6
|
+
}
|
|
7
|
+
app.post('/api/charge', chargeHandler);
|
|
8
|
+
|
|
9
|
+
export function getUser(req: any, res: any): unknown {
|
|
10
|
+
return res.send({ id: req.params.id });
|
|
11
|
+
}
|
|
12
|
+
app.get('/users/:id', getUser);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Gateway service — calls into billing's /api/charge and /users/:id
|
|
2
|
+
declare const fetch: any;
|
|
3
|
+
|
|
4
|
+
export async function processPayment(amount: number): Promise<unknown> {
|
|
5
|
+
return await fetch('/api/charge', {
|
|
6
|
+
method: 'POST',
|
|
7
|
+
body: JSON.stringify({ amount }),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function fetchUser(id: string): Promise<unknown> {
|
|
12
|
+
return await fetch(`/users/${id}`, { method: 'GET' });
|
|
13
|
+
}
|