Repository navigation
feat: remote MarkRoleDegraded + task-cancel HIVE endpoints #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bcaa8d3
feat: remote MarkRoleDegraded + task-cancel endpoints (HV-3/HV-4 gaps)
hardcoreerik ab127f6
docs: update ROADMAP.md for the native-runtime default flip
hardcoreerik 4129df7
fix: remote task cancel no longer gets silently requeued (grok BLOCKER)
hardcoreerik a07227d
fix: address CodeRabbit findings on PR #94
hardcoreerik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
OrchestratorIDE.UnitTests/HiveNodeServerAuthorizationTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright (C) 2025-present hardcoreerik / TheOrc contributors | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
| using NUnit.Framework; | ||
| using OrchestratorIDE.Services.Hive; | ||
|
|
||
| namespace OrchestratorIDE.UnitTests; | ||
|
|
||
| /// <summary> | ||
| /// HiveNodeServer.IsWarchief is the shared authority gate for the Warchief-only mutation | ||
| /// endpoints (remote deploy, /hive/roles/degrade, /hive/tasks/cancel — HV-3 item 3 / HV-4 | ||
| /// item 1). It reads ElectionService.WarchiefNodeId, which requires a real HiveElectionService | ||
| /// (itself requiring a real HiveIdentity, private-constructor-only) to test the "configured and | ||
| /// matches" branch — too heavy for what should be a cheap authorization check. This covers the | ||
| /// safe-default branch instead: no ElectionService configured must mean nobody is authorized | ||
| /// (fail-closed), not "any caller passes." | ||
| /// </summary> | ||
| [TestFixture] | ||
| public sealed class HiveNodeServerAuthorizationTests | ||
| { | ||
| [TestCase("")] | ||
| [TestCase("some-node-id")] | ||
| public void IsWarchief_ReturnsFalse_WhenElectionServiceNotConfigured(string nodeId) | ||
| { | ||
| using var server = new HiveNodeServer(); | ||
| Assert.That(server.ElectionService, Is.Null, "test assumes the default-constructed state"); | ||
| Assert.That(server.IsWarchief(nodeId), Is.False); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: hardcoreerik/TheOrc
Length of output: 319
🏁 Script executed:
Repository: hardcoreerik/TheOrc
Length of output: 207
🏁 Script executed:
Repository: hardcoreerik/TheOrc
Length of output: 207
🌐 Web query:
Microsoft .NET Enum.TryParse numeric string undefined enum value IsDefined behavior💡 Result:
In.NET, the Enum.TryParse method is designed to parse both the names and the underlying numeric values of an enumeration [1][2][3]. When a numeric string is provided, Enum.TryParse will successfully parse it into the target enum type even if that numeric value is not explicitly defined in the enumeration [1][4][5]. This behavior occurs because Enum.TryParse treats any string representation of an integer as a valid attempt to convert to the enum's underlying integral type [1][2][5]. Consequently, the method will return true and output the corresponding enum value, regardless of whether that value corresponds to a named member [4][6]. If this behavior is undesirable and you need to ensure that the parsed value is a valid, defined member of the enumeration, you must explicitly call Enum.IsDefined after a successful parse [1][2][5]. Example of the safe usage pattern: string input = "99"; // An undefined value if (Enum.TryParse(input, out MyEnum result) && Enum.IsDefined(typeof(MyEnum), result)) { // Result is a valid, defined member of the enum } else { // Handle invalid or undefined value } Note that Enum.IsDefined evaluates whether the specific value (or name) exists within the enumeration [7][5]. In cases where you are dealing with enumerations marked with the [Flags] attribute, keep in mind that Enum.IsDefined may return false for composite values (e.g., bitwise combinations) even if they are logically valid for your use case, and you should use Enum.HasFlag instead [7].
Citations:
🌐 Web query:
Microsoft .NET Enum.TryParse numeric string undefined enum value IsDefined behavior💡 Result:
In.NET, the Enum.TryParse method is designed to succeed even when the input numeric string does not correspond to a defined constant within the enumeration [1][2][3]. If the input string is a valid representation of the underlying integral type of the enum, Enum.TryParse will parse it and return true, assigning the resulting value to the output parameter [1][4]. This behavior is intentional, as it allows the method to support the parsing of underlying integral values that may not be explicitly named constants [1][5]. Because Enum.TryParse returns true for these undefined values, it does not implicitly validate that the result is a defined member of the enumeration [6][3]. To ensure that a parsed value is an actual defined member of the enum, you must explicitly call Enum.IsDefined [1][6]. When using Enum.IsDefined for this purpose, it is critical to pass the enum value itself, not the original string [6][7]. Enum.IsDefined(typeof(TEnum), "some_string") looks for a member named "some_string" and will return false if the string is numeric, even if that number corresponds to a valid enum constant [7]. Instead, you should perform the following sequence [6][8][7]: 1. Use Enum.TryParse to convert the string to the enum type [1][8]. 2. Pass the resulting enum value to Enum.IsDefined to verify it is a defined constant [6][8]. Example: string input = "99"; // Undefined value if (Enum.TryParse(input, out MyEnum result)) { if (Enum.IsDefined(typeof(MyEnum), result)) { // Value is defined } else { // Value is parsed but not defined in the enum } }
Citations:
🏁 Script executed:
Repository: hardcoreerik/TheOrc
Length of output: 7935
Reject undefined
RuntimeRolevalues before invoking the handler..NETenum parsing accepts valid integer strings for undefined values, so{"role":"999"}currently returns success and callsMarkRoleDegradedHandler(999)instead of returning the documented 400 role validation error.🛡️ Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents