cognitivebc 0.1.0 → 0.2.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.
Files changed (66) hide show
  1. package/LICENSE +70 -0
  2. package/README.md +98 -4
  3. package/SECURITY.md +29 -0
  4. package/TERMS_OF_SERVICE.md +55 -0
  5. package/bin/cbc-cloud-bootstrap.js +108 -0
  6. package/bin/cbc-seed-projects.js +29 -0
  7. package/bin/cbc-server.js +45 -0
  8. package/bin/cognitivebc.js +251 -0
  9. package/docs/ACCESS_CONTROL.md +111 -0
  10. package/docs/ARTIFACT_AUDIT.md +36 -0
  11. package/docs/CONNECT_CLIENTS.md +116 -0
  12. package/docs/DEPLOY_AZURE.md +136 -0
  13. package/docs/INGESTION.md +29 -0
  14. package/docs/OPERATIONS.md +85 -0
  15. package/docs/PROJECT_IDENTITY.md +35 -0
  16. package/docs/RESOLVER.md +86 -0
  17. package/docs/SDK.md +96 -0
  18. package/docs/STORAGE.md +63 -0
  19. package/docs/TECHNICAL_SPECIFICATION.md +365 -0
  20. package/docs/TELEMETRY.md +119 -0
  21. package/index.js +27 -2
  22. package/package.json +45 -5
  23. package/packages/cbc-compiler/index.js +357 -0
  24. package/packages/cbc-compiler/sanitizer.js +43 -0
  25. package/packages/cbc-identity/index.js +92 -0
  26. package/packages/cbc-mcp/http-backend.js +138 -0
  27. package/packages/cbc-mcp/http-route.js +64 -0
  28. package/packages/cbc-mcp/index.js +50 -0
  29. package/packages/cbc-mcp/tools.js +122 -0
  30. package/packages/cbc-resolver/catalog-linker.js +215 -0
  31. package/packages/cbc-resolver/graph-builder.js +533 -0
  32. package/packages/cbc-resolver/index.js +548 -0
  33. package/packages/cbc-resolver/obsidian-bridge.js +564 -0
  34. package/packages/cbc-schema/index.js +194 -0
  35. package/packages/cbc-sdk-js/client.js +162 -0
  36. package/services/cbc-api/access-policy.js +130 -0
  37. package/services/cbc-api/artifact-audit.js +167 -0
  38. package/services/cbc-api/cloud.js +56 -0
  39. package/services/cbc-api/context-service.js +48 -0
  40. package/services/cbc-api/ingestion-service.js +234 -0
  41. package/services/cbc-api/pg-store.js +172 -0
  42. package/services/cbc-api/project-registry.js +322 -0
  43. package/services/cbc-api/public/app.html +123 -0
  44. package/services/cbc-api/public/graph.html +1168 -0
  45. package/services/cbc-api/public/graph2.html +455 -0
  46. package/services/cbc-api/public/graph3.html +503 -0
  47. package/services/cbc-api/public/index.html +78 -0
  48. package/services/cbc-api/public/vendor/cbc-app.js +209 -0
  49. package/services/cbc-api/public/vendor/cbc-auth.js +49 -0
  50. package/services/cbc-api/public/vendor/cbc-site.css +101 -0
  51. package/services/cbc-api/public/vendor/cose-base.js +3214 -0
  52. package/services/cbc-api/public/vendor/cytoscape-dagre.js +397 -0
  53. package/services/cbc-api/public/vendor/cytoscape-fcose.js +1549 -0
  54. package/services/cbc-api/public/vendor/cytoscape.min.js +32 -0
  55. package/services/cbc-api/public/vendor/dagre.min.js +3809 -0
  56. package/services/cbc-api/public/vendor/graphology-library.min.js +2 -0
  57. package/services/cbc-api/public/vendor/graphology.umd.min.js +2 -0
  58. package/services/cbc-api/public/vendor/layout-base.js +5230 -0
  59. package/services/cbc-api/public/vendor/pf-graph.css +86 -0
  60. package/services/cbc-api/public/vendor/pf-telemetry.js +176 -0
  61. package/services/cbc-api/public/vendor/sigma.min.js +1351 -0
  62. package/services/cbc-api/runtime-info.js +39 -0
  63. package/services/cbc-api/server.js +642 -0
  64. package/services/cbc-api/store-loader.js +269 -0
  65. package/services/cbc-api/telemetry.js +148 -0
  66. package/services/cbc-api/token-service.js +61 -0
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const crypto = require('crypto');
6
+ const { execFileSync } = require('child_process');
7
+ const root = path.resolve(__dirname, '../..');
8
+ const version = require('../../package.json').version;
9
+
10
+ /** Capture once at server construction, never manufacture a revision per request.
11
+ * This identifies the source snapshot observed at startup, not V8 bytecode or a
12
+ * proof that files were unchanged between require() and the snapshot.
13
+ */
14
+ function captureRuntimeInfo({ sourceRoot = root, publicExports = {} } = {}) {
15
+ const files = [];
16
+ const visit = relative => {
17
+ const absolute = path.join(sourceRoot, relative);
18
+ if (!fs.existsSync(absolute)) return;
19
+ if (fs.lstatSync(absolute).isSymbolicLink()) throw new Error('Runtime sources must not be symlinks');
20
+ if (fs.statSync(absolute).isDirectory()) {
21
+ for (const name of fs.readdirSync(absolute).sort()) visit(path.join(relative, name));
22
+ } else if (relative.endsWith('.js') || relative === 'package.json') files.push(relative);
23
+ };
24
+ ['index.js', 'package.json', 'packages', 'services', 'bin'].forEach(visit);
25
+ const hash = crypto.createHash('sha256');
26
+ for (const file of files.sort()) hash.update(file.split(path.sep).join('/') + '\0').update(fs.readFileSync(path.join(sourceRoot, file))).update('\0');
27
+ const exportsHash = crypto.createHash('sha256');
28
+ for (const name of Object.keys(publicExports).sort()) {
29
+ const value = publicExports[name];
30
+ if (typeof value === 'function') exportsHash.update(name + '\0' + Function.prototype.toString.call(value) + '\0');
31
+ }
32
+ let gitRevision = null, gitDirty = null;
33
+ try {
34
+ gitRevision = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: sourceRoot, encoding: 'utf8', timeout: 1000, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
35
+ gitDirty = Boolean(execFileSync('git', ['status', '--porcelain', '--untracked-files=normal'], { cwd: sourceRoot, encoding: 'utf8', timeout: 1000, stdio: ['ignore', 'pipe', 'ignore'] }).trim());
36
+ } catch { /* Installed tarballs need no Git executable or repository. */ }
37
+ return Object.freeze({ version, pid: process.pid, process_started_at: new Date(Date.now() - process.uptime() * 1000).toISOString(), captured_at: new Date().toISOString(), node_version: process.version, source_snapshot_sha256: hash.digest('hex'), source_file_count: files.length, runtime_exports_sha256: exportsHash.digest('hex'), git_revision: gitRevision, git_dirty: gitDirty, attestation: 'startup_files_and_public_function_bodies_not_full_loaded_code' });
38
+ }
39
+ module.exports = { captureRuntimeInfo };