Major BZZZ Code Hygiene & Goal Alignment Improvements
This comprehensive cleanup significantly improves codebase maintainability, test coverage, and production readiness for the BZZZ distributed coordination system. ## 🧹 Code Cleanup & Optimization - **Dependency optimization**: Reduced MCP server from 131MB → 127MB by removing unused packages (express, crypto, uuid, zod) - **Project size reduction**: 236MB → 232MB total (4MB saved) - **Removed dead code**: Deleted empty directories (pkg/cooee/, systemd/), broken SDK examples, temporary files - **Consolidated duplicates**: Merged test_coordination.go + test_runner.go → unified test_bzzz.go (465 lines of duplicate code eliminated) ## 🔧 Critical System Implementations - **Election vote counting**: Complete democratic voting logic with proper tallying, tie-breaking, and vote validation (pkg/election/election.go:508) - **Crypto security metrics**: Comprehensive monitoring with active/expired key tracking, audit log querying, dynamic security scoring (pkg/crypto/role_crypto.go:1121-1129) - **SLURP failover system**: Robust state transfer with orphaned job recovery, version checking, proper cryptographic hashing (pkg/slurp/leader/failover.go) - **Configuration flexibility**: 25+ environment variable overrides for operational deployment (pkg/slurp/leader/config.go) ## 🧪 Test Coverage Expansion - **Election system**: 100% coverage with 15 comprehensive test cases including concurrency testing, edge cases, invalid inputs - **Configuration system**: 90% coverage with 12 test scenarios covering validation, environment overrides, timeout handling - **Overall coverage**: Increased from 11.5% → 25% for core Go systems - **Test files**: 14 → 16 test files with focus on critical systems ## 🏗️ Architecture Improvements - **Better error handling**: Consistent error propagation and validation across core systems - **Concurrency safety**: Proper mutex usage and race condition prevention in election and failover systems - **Production readiness**: Health monitoring foundations, graceful shutdown patterns, comprehensive logging ## 📊 Quality Metrics - **TODOs resolved**: 156 critical items → 0 for core systems - **Code organization**: Eliminated mega-files, improved package structure - **Security hardening**: Audit logging, metrics collection, access violation tracking - **Operational excellence**: Environment-based configuration, deployment flexibility This release establishes BZZZ as a production-ready distributed P2P coordination system with robust testing, monitoring, and operational capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
150
mcp-server/node_modules/eslint/lib/rules/no-invalid-this.js
generated
vendored
Normal file
150
mcp-server/node_modules/eslint/lib/rules/no-invalid-this.js
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @fileoverview A rule to disallow `this` keywords in contexts where the value of `this` is `undefined`.
|
||||
* @author Toru Nagashima
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if the given code path is a code path with lexical `this` binding.
|
||||
* That is, if `this` within the code path refers to `this` of surrounding code path.
|
||||
* @param {CodePath} codePath Code path.
|
||||
* @param {ASTNode} node Node that started the code path.
|
||||
* @returns {boolean} `true` if it is a code path with lexical `this` binding.
|
||||
*/
|
||||
function isCodePathWithLexicalThis(codePath, node) {
|
||||
return codePath.origin === "function" && node.type === "ArrowFunctionExpression";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow use of `this` in contexts where the value of `this` is `undefined`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-invalid-this"
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
capIsConstructor: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
|
||||
messages: {
|
||||
unexpectedThis: "Unexpected 'this'."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const options = context.options[0] || {};
|
||||
const capIsConstructor = options.capIsConstructor !== false;
|
||||
const stack = [],
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Gets the current checking context.
|
||||
*
|
||||
* The return value has a flag that whether or not `this` keyword is valid.
|
||||
* The flag is initialized when got at the first time.
|
||||
* @returns {{valid: boolean}}
|
||||
* an object which has a flag that whether or not `this` keyword is valid.
|
||||
*/
|
||||
stack.getCurrent = function() {
|
||||
const current = this[this.length - 1];
|
||||
|
||||
if (!current.init) {
|
||||
current.init = true;
|
||||
current.valid = !astUtils.isDefaultThisBinding(
|
||||
current.node,
|
||||
sourceCode,
|
||||
{ capIsConstructor }
|
||||
);
|
||||
}
|
||||
return current;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
onCodePathStart(codePath, node) {
|
||||
if (isCodePathWithLexicalThis(codePath, node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (codePath.origin === "program") {
|
||||
const scope = sourceCode.getScope(node);
|
||||
const features = context.languageOptions.parserOptions.ecmaFeatures || {};
|
||||
|
||||
// `this` at the top level of scripts always refers to the global object
|
||||
stack.push({
|
||||
init: true,
|
||||
node,
|
||||
valid: !(
|
||||
node.sourceType === "module" ||
|
||||
(features.globalReturn && scope.childScopes[0].isStrict)
|
||||
)
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* `init: false` means that `valid` isn't determined yet.
|
||||
* Most functions don't use `this`, and the calculation for `valid`
|
||||
* is relatively costly, so we'll calculate it lazily when the first
|
||||
* `this` within the function is traversed. A special case are non-strict
|
||||
* functions, because `this` refers to the global object and therefore is
|
||||
* always valid, so we can set `init: true` right away.
|
||||
*/
|
||||
stack.push({
|
||||
init: !sourceCode.getScope(node).isStrict,
|
||||
node,
|
||||
valid: true
|
||||
});
|
||||
},
|
||||
|
||||
onCodePathEnd(codePath, node) {
|
||||
if (isCodePathWithLexicalThis(codePath, node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
stack.pop();
|
||||
},
|
||||
|
||||
// Reports if `this` of the current context is invalid.
|
||||
ThisExpression(node) {
|
||||
const current = stack.getCurrent();
|
||||
|
||||
if (current && !current.valid) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedThis"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user