@kortexya/reasoninglayer-code-semantic 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,41 @@
1
+ Proprietary Source Code License
2
+
3
+ © 2025–present Kortexya. All rights reserved.
4
+
5
+ This source code and all associated files (the “Software”) are the exclusive
6
+ intellectual property of the Owner.
7
+
8
+ 1. Permissions
9
+ You are allowed to:
10
+ - view the source code;
11
+ - use it solely for personal or internal purposes.
12
+
13
+ No other rights are granted.
14
+
15
+ 2. Restrictions
16
+ Unless you obtain prior written permission from the Owner, you are NOT permitted to:
17
+ - copy, modify, distribute, publish, or sell the Software;
18
+ - share, upload, or redistribute the source code;
19
+ - create derivative works;
20
+ - reverse engineer, decompile, or otherwise attempt to extract or analyze it.
21
+
22
+ 3. Ownership
23
+ All rights, titles, and interests in the Software remain the exclusive property
24
+ of the Owner. No ownership is transferred through access or use.
25
+
26
+ 4. Contributions
27
+ Any contribution to this project is governed by the attached Contributor License
28
+ Agreement (CLA). Under that CLA, all copyrights in contributions are assigned
29
+ to the Owner. Contributors retain no ownership rights.
30
+
31
+ 5. No Warranty
32
+ The Software is provided “as is” without warranty of any kind.
33
+
34
+ 6. Liability
35
+ The Owner shall not be held liable for any damages arising from the use of the Software.
36
+
37
+ 7. Termination
38
+ Any violation of this license immediately terminates your rights to use the Software.
39
+
40
+ 8. Governing Law
41
+ This license is governed by the laws of the Owner’s jurisdiction.
package/README.md CHANGED
@@ -1,3 +1,132 @@
1
- # Temporary Holding Version
1
+ # OSFKB code-semantic MCP
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Investigate architecture, duplicate code, effect hazards and API usage from
4
+ Claude Code, Codex or another stdio MCP client. Discover source-backed FCA groups,
5
+ query resident OSF proofs and check measured runtime requirements.
6
+ The npm launcher runs the native Rust engine locally. FCA groups are review leads;
7
+ confirmed defects require executable evidence. This tool does not find all bugs.
8
+
9
+ Version **0.1.1** has native support for **macOS Apple
10
+ Silicon (darwin/arm64), Node.js 20+**. Linux, Intel macOS and Windows binaries are
11
+ not included. The GitLab release uses the optimized `dist` profile; earlier local
12
+ development artifacts retain their original provenance. No Rust toolchain, API
13
+ key or external model is needed for FCA discovery and native runtime auditing.
14
+
15
+ ## Install and connect
16
+
17
+ ```sh
18
+ npm install -g @kortexya/reasoninglayer-code-semantic@0.1.1
19
+ osfkb-code-semantic-mcp --help
20
+ ```
21
+
22
+ Claude Code:
23
+
24
+ ```sh
25
+ claude mcp add --transport stdio code-semantic -- osfkb-code-semantic-mcp --workspace /absolute/path/to/project/src
26
+ ```
27
+
28
+ Codex:
29
+
30
+ ```sh
31
+ codex mcp add code-semantic -- osfkb-code-semantic-mcp --workspace /absolute/path/to/project/src
32
+ ```
33
+
34
+ Restart the client and check `/mcp`. Add `--watch` to the server arguments for
35
+ incremental source indexing. Use an absolute executable path if the client does
36
+ not inherit your npm global bin directory in `PATH`.
37
+
38
+ You can also use `npx -y @kortexya/reasoninglayer-code-semantic@0.1.1` as the command after `--`,
39
+ followed by the same native arguments. The native optional dependency must remain
40
+ enabled; `--omit=optional` prevents the server from starting. The launcher checks
41
+ its platform, exact version and packaged executable SHA-256 at startup. npm
42
+ provides registry integrity; the bundled digest detects local mismatches and is
43
+ not an independent authenticity signature. No install script downloads code.
44
+
45
+ The commands follow the official [Claude MCP](https://code.claude.com/docs/en/mcp)
46
+ and [Codex MCP](https://developers.openai.com/codex/mcp) configuration interfaces.
47
+
48
+ ## Install the optional skill
49
+
50
+ Run the relevant command in the project you want to review:
51
+
52
+ ```sh
53
+ osfkb-code-semantic-mcp install-skill --client claude --project /absolute/path/to/project
54
+ osfkb-code-semantic-mcp install-skill --client codex --project /absolute/path/to/project
55
+ ```
56
+
57
+ This copies the portable `osf-code-review/SKILL.md` to `.claude/skills/` or
58
+ `.agents/skills/`. It leaves client configuration alone and refuses to overwrite
59
+ a skill that differs. Restart the client to discover it, then invoke
60
+ `/osf-code-review` in Claude Code or `$osf-code-review` in Codex. The skill guides
61
+ the agent; the separately configured MCP provides the executable tools. See the
62
+ official [Claude skills](https://code.claude.com/docs/en/skills) and
63
+ [Codex skills](https://developers.openai.com/codex/skills) documentation.
64
+
65
+ Example request:
66
+
67
+ > Use osf-code-review and the code-semantic MCP to inspect this Rust module.
68
+ > Discover FCA groups and inspect a concrete bug hypothesis. Write a regression
69
+ > that fails before the fix, correct the production path, and show the native
70
+ > evidence, passing regression and any incomplete coverage.
71
+
72
+ ## Tools and scope
73
+
74
+ `index_codebase` indexes the requested source directory. The acceptance controls
75
+ prioritize Rust, Python and TypeScript/JavaScript; bundled parsers have distinct
76
+ coverage limits. `discover_code_concepts` publishes closed groups
77
+ of callables sharing witnessed dependencies into OSF. `prove_query` queries their
78
+ native facts and derivations. Check search and inference completeness separately.
79
+
80
+ The review skill combines these tools with other available discovery passes:
81
+
82
+ | Tool | Review scope | Evidence limit |
83
+ | --- | --- | --- |
84
+ | `analyze_architecture` | Layer dependencies, cycles and structural warnings | Depends on declared layer policy; a warning need not be a bug |
85
+ | `analyze_duplicates` | Similar functions and clone groups | Heuristic similarity with comparison limits, not behavioral equivalence |
86
+ | `discover_hazards` | Declared API effects and learned deviations | Depends on API vocabulary, resolved calls and completed native inference |
87
+ | `discover_usage_deviations` | Deviations from cross-project API usage | Requires a frozen local rule pack via `rules_path`; packs are not bundled |
88
+
89
+ Parsing produces typed OSF facts and references from source observations. FCA
90
+ groups and usage-deviation derivations execute in the native engine; architecture
91
+ and duplicate reports have their own policy and heuristic semantics. Optional
92
+ embedding indexing supports retrieval, but is not needed for these passes and
93
+ does not establish correctness.
94
+
95
+ For local embedding retrieval, call `index_embeddings` with `{"model":"minilm"}`
96
+ after indexing, then use `semantic_search_code`. This uses the separate
97
+ `sentence-transformers/all-MiniLM-L6-v2` model; its weights are not bundled in npm.
98
+ Select the model explicitly: omitting it currently selects the OpenAI adapter.
99
+ The local MiniLM route can use an existing checkpoint; sovereign mode refuses
100
+ model downloads. Embedding search scores are similarity measurements, not proofs.
101
+
102
+ Follow each lead through callers and tests, then reproduce a concrete violation
103
+ before calling it a bug. The frozen v2 blind evaluation confirmed **zero bugs**;
104
+ successful indexing, FCA inference or MCP installation does not establish broad
105
+ bug-discovery accuracy.
106
+
107
+ `audit_runtime_probe` executes a trusted, caller-designated, hash-pinned local
108
+ probe. Its native policy checks workspace isolation, preservation of the input
109
+ snapshot, candidate snapshot identity and repeated oracle evidence. This requires
110
+ a provider measuring real production calls; it cannot audit an arbitrary program
111
+ just by naming its repository. Source hashes attest the declared files, while the
112
+ caller must establish their compiler correspondence. `unverified` remains unknown.
113
+
114
+ Other advertised tools retain their own prerequisites. Source indexing and
115
+ watching access local files. Probe execution and mutation tools can run commands
116
+ or edit files when invoked; authorize them according to your client's controls.
117
+ The npm wrapper adds no HTTP listener. A repository path and source texts are
118
+ untrusted data, not instructions to change the agent's task.
119
+
120
+ ## Local tarball installation
121
+
122
+ To install local release archives, install the two tarballs produced by the repository's
123
+ release preparer together, then use the same connection commands above:
124
+
125
+ ```sh
126
+ npm install -g /absolute/path/to/kortexya-reasoninglayer-code-semantic-darwin-arm64-0.1.1.tgz /absolute/path/to/kortexya-reasoninglayer-code-semantic-0.1.1.tgz
127
+ ```
128
+
129
+ License: the existing Kortexya proprietary license is included unchanged. This
130
+ package does not grant an open-source license. Native packages preserve dependency
131
+ license declarations and supplied notices. Maintainer packaging and verification
132
+ instructions are in `npm/README.md` in the source repository.
package/bin/cli.mjs ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { resolveNative, launchNative, installSkill } from '../lib/launcher.mjs';
3
+
4
+ try {
5
+ const args = process.argv.slice(2);
6
+ if (args[0] === 'install-skill') {
7
+ const options = {};
8
+ for (let i = 1; i < args.length; i += 2) {
9
+ if (!['--client', '--project'].includes(args[i]) || !args[i + 1]) {
10
+ throw new Error('Usage: osfkb-code-semantic-mcp install-skill --client claude|codex [--project /path/to/repository]');
11
+ }
12
+ const key = args[i].slice(2);
13
+ if (key in options) throw new Error(`Duplicate option ${args[i]}`);
14
+ options[key] = args[i + 1];
15
+ }
16
+ process.stdout.write(`Skill installed: ${installSkill(options)}\n`);
17
+ } else {
18
+ launchNative(resolveNative(), args);
19
+ }
20
+ } catch (error) {
21
+ process.stderr.write(`osfkb-code-semantic-mcp: ${error.message}\n`);
22
+ process.exitCode = 1;
23
+ }
@@ -0,0 +1,75 @@
1
+ import { createRequire } from 'node:module';
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
+ import { dirname, join, resolve as absolute } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { spawn } from 'node:child_process';
7
+
8
+ const require = createRequire(import.meta.url);
9
+ const root = fileURLToPath(new URL('../', import.meta.url));
10
+ const metadata = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
11
+
12
+ export function resolveNative({ platform = process.platform, arch = process.arch, resolve = require.resolve } = {}) {
13
+ const name = `${metadata.name}-${platform}-${arch}`;
14
+ if (!metadata.optionalDependencies[name]) {
15
+ throw new Error(`Native MCP server is not available for ${platform}/${arch} in ${metadata.version}. Supported: darwin/arm64.`);
16
+ }
17
+ let packageRoot;
18
+ try {
19
+ packageRoot = dirname(resolve(`${name}/package.json`));
20
+ } catch {
21
+ throw new Error(`Missing native package ${name}@${metadata.version}. Reinstall with optional dependencies enabled (npm install --include=optional ${metadata.name}@${metadata.version}).`);
22
+ }
23
+ const manifest = JSON.parse(readFileSync(join(packageRoot, 'native.json'), 'utf8'));
24
+ if (manifest.schema !== 'osfkb-native-package-v1' || manifest.version !== metadata.version || manifest.platform !== platform || manifest.arch !== arch) {
25
+ throw new Error('Native package version or platform does not match the launcher.');
26
+ }
27
+ if (typeof manifest.binary !== 'string' || !/^[a-zA-Z0-9._-]+$/.test(manifest.binary) || manifest.binary === '..' || manifest.binary === '.') {
28
+ throw new Error('Invalid native binary path.');
29
+ }
30
+ const binary = join(packageRoot, manifest.binary);
31
+ const digest = createHash('sha256').update(readFileSync(binary)).digest('hex');
32
+ if (digest !== manifest.sha256) throw new Error('Native MCP binary SHA-256 mismatch. Reinstall the package.');
33
+ return binary;
34
+ }
35
+
36
+ export function launchNative(binary, args) {
37
+ // Native Rust owns MCP framing, indexing, FCA and reasoning. No shell, model,
38
+ // download, protocol proxy or parallel implementation is involved here.
39
+ const child = spawn(binary, args, { stdio: 'inherit', shell: false });
40
+ const handlers = new Map();
41
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
42
+ const handler = () => child.kill(signal);
43
+ handlers.set(signal, handler);
44
+ process.on(signal, handler);
45
+ }
46
+ const cleanup = () => {
47
+ for (const [signal, handler] of handlers) process.removeListener(signal, handler);
48
+ };
49
+ child.once('error', error => {
50
+ cleanup();
51
+ process.stderr.write(`Cannot start native MCP server: ${error.message}\n`);
52
+ process.exitCode = 1;
53
+ });
54
+ child.once('exit', (code, signal) => {
55
+ cleanup();
56
+ if (signal) process.kill(process.pid, signal);
57
+ else process.exitCode = code ?? 1;
58
+ });
59
+ return child;
60
+ }
61
+
62
+ export function installSkill({ client, project = process.cwd() }) {
63
+ if (!['claude', 'codex'].includes(client)) throw new Error('Choose --client claude or codex.');
64
+ const parent = client === 'claude' ? '.claude' : '.agents';
65
+ const destination = join(absolute(project), parent, 'skills', 'osf-code-review');
66
+ const target = join(destination, 'SKILL.md');
67
+ const content = readFileSync(join(root, 'skills', 'osf-code-review', 'SKILL.md'));
68
+ if (existsSync(target)) {
69
+ if (!readFileSync(target).equals(content)) throw new Error(`Existing skill differs: ${target}. Preserve or remove it explicitly before installing.`);
70
+ return destination;
71
+ }
72
+ mkdirSync(destination, { recursive: true });
73
+ writeFileSync(target, content, { flag: 'wx' });
74
+ return destination;
75
+ }
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@kortexya/reasoninglayer-code-semantic",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Native OSF/FCA code discovery and evidence-backed runtime requirements over MCP",
5
+ "type": "module",
6
+ "bin": { "osfkb-code-semantic-mcp": "bin/cli.mjs" },
7
+ "engines": { "node": ">=20" },
8
+ "license": "SEE LICENSE IN LICENSE",
9
+ "repository": { "type": "git", "url": "https://github.com/osfkb/osfkb.git", "directory": "npm/code-semantic-mcp" },
10
+ "files": ["bin/", "lib/", "skills/", "LICENSE", "README.md"],
11
+ "optionalDependencies": { "@kortexya/reasoninglayer-code-semantic-darwin-arm64": "0.1.1" },
12
+ "scripts": { "test": "node --test test/*.test.mjs" },
13
+ "publishConfig": { "access": "public" },
14
+ "keywords": ["mcp", "fca", "osf", "claude-code", "codex", "code-review"]
15
+ }
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: osf-code-review
3
+ description: Use the OSFKB code-semantic MCP server to investigate bugs across architecture, duplicate code, effect hazards and API usage, with FCA discovery, native OSF evidence and executable regressions.
4
+ ---
5
+
6
+ Use the configured `code-semantic` MCP server. Client prefixes can differ: select
7
+ tools by their advertised names and input schemas. If unavailable, report the
8
+ connection problem; do not invent tool results. This skill installs instructions;
9
+ the separate MCP connection supplies the native engine.
10
+
11
+ For a source review:
12
+
13
+ 1. Index the requested source directory with `index_codebase` unless the server
14
+ already indexes that directory. Record the source revision, requested scope,
15
+ indexing errors and unsupported files before interpreting coverage. Parsing
16
+ and native reasoning do not require embeddings. Optional embedding retrieval
17
+ can help locate related code; it supplies no proof of a defect.
18
+ 2. For broad discovery, inspect the available schemas and execute each applicable
19
+ pass below. Record prerequisites that are absent and searches that stop early.
20
+ Use the engine's returned premises; do not recreate its reasoning in scripts.
21
+ 3. Inspect the actual functions, callers and tests for a concrete lead. State the
22
+ expected behavior and the trigger that would violate it. Follow values across
23
+ callers, returned objects, wrappers and cleanup paths before treating a local
24
+ omission as misuse. For example, a parser builder can return its parser for a
25
+ caller to consume. Deduplicate leads by the same trigger and defect, retaining
26
+ every source witness. Prefer a regression that fails on the original
27
+ implementation before editing production code.
28
+ 4. Query relevant resident facts with `prove_query`, for example sort
29
+ `code.responsibility_overlap` and constraints
30
+ `{"function":"?F","left":"?A","right":"?B"}`. Preserve context and premise
31
+ identities. Use `assert_rule` only with measured or explicitly declared premises;
32
+ a rule's conclusion cannot supply its own evidence.
33
+ 5. Fix a confirmed defect through the existing production path and rerun the
34
+ failing regression and appropriate related tests. Report the trigger, source
35
+ location, before/after result, and which part the MCP actually established.
36
+
37
+ Applicable discovery passes:
38
+
39
+ - `analyze_architecture`: inspect layer mappings against the project's declared
40
+ architecture and pass appropriate `layer_overrides`. Follow reported imports,
41
+ cycles and oversized modules. These policy checks and structural heuristics
42
+ are not automatically behavioral bugs or FCA proofs.
43
+ - `analyze_duplicates`, followed by `find_clone_groups` or `find_similar_to`:
44
+ inspect similar functions for inconsistent guards, cleanup or error handling.
45
+ Similarity is a review signal, not semantic equivalence. Record filters,
46
+ `max_pairs` and `max_block_size`; blocked or truncated comparisons cannot
47
+ establish that no duplicates exist.
48
+ - `discover_code_concepts`, initially with `min_support: 2` and
49
+ `min_shared_callees: 2`: inspect `members`, `shared_callees` and source witnesses.
50
+ Shared calls and overlapping responsibilities do not establish identical
51
+ behavior, a safe inheritance hierarchy, or a bug.
52
+ - `discover_hazards`: inspect both declared effect hazards and statistically
53
+ certified implicit-rule deviations. Check coverage of external APIs, unresolved
54
+ calls and supported languages. Filesystem alias and deletion leads require
55
+ tracing actual arguments and control flow before reproduction.
56
+ - `discover_usage_deviations`: requires `rules_path` pointing to an available
57
+ frozen, previously mined pack. Record its hash and vocabulary. Do not invent
58
+ a pack, change thresholds after seeing candidates, or silently omit this pass
59
+ when its prerequisite is unavailable. A cross-project regularity is a
60
+ statistical observation, not a mandatory API contract.
61
+
62
+ For an evaluation, freeze inputs, policies and tool versions before examining
63
+ reference defects. Record confirmed defects, dismissed leads, unresolved leads,
64
+ reviewed counts and coverage separately. An installed MCP smoke test checks the
65
+ transport and execution path; it does not measure broad bug-discovery accuracy.
66
+ The frozen v2 blind evaluation produced leads but confirmed no bugs. New
67
+ experiments must retain their own identities and evidence.
68
+
69
+ For runtime workspace verification, use `audit_runtime_probe` only with a trusted
70
+ local native executable authorized for the task. The tool executes that program.
71
+ It requires `program`, `arguments`, `expected_program_sha256` and `source_files`
72
+ with measured SHA-256 hashes; it is not a general static bug scanner. The provider
73
+ must emit `verification-workspace-observations-v1` JSON at
74
+ `OSFKB_RUNTIME_AUDIT_OUTPUT`, with repeated observations of real production calls.
75
+ Inspect its implementation and build correspondence before trusting measurements.
76
+ The native policy checks workspace isolation, unchanged input snapshots, candidate
77
+ snapshots and repeated oracle evidence. Query `runtime.audit_violation` with
78
+ `{"context":"?C","requirement":"?R","sample":"?S"}` for resident counterexamples.
79
+ Do not fabricate a passing observation file or replace production calls with mocks
80
+ and then claim production validation.
81
+
82
+ Always inspect completeness: FCA requires `enumeration.stop_reason == "exhausted"`;
83
+ materialized inference also requires `complete` and `provenance_complete` in its
84
+ receipt. A limited search can retain partial findings but cannot prove absence.
85
+ Runtime `unverified`, unavailable measurements and failed collection remain
86
+ unresolved. `conforms` covers the declared requirements and observed samples.
87
+ Distinguish a structural lead, a native counterexample, a reproduced production
88
+ defect, and an injected evaluation fault. Never claim this finds all bugs.