Repository navigation
fix: findings from a code audit - #15
Closed
dev-agentic-platform[bot] wants to merge 8 commits into
Closed
dev-agentic-platform[bot] wants to merge 8 commits into
dev-agentic-platform[bot] wants to merge 8 commits into
Conversation
added 8 commits
November 10, 2026 22:50
…020128c2f141d9cefeda1bc70516f2f96cce8af4958421b961, 74e8f98c131a7a40af033f63dc834b7117364b338222ddec706ba65bc9a8ca43)
…620c598a976be77df3fa7a2da069b127d7730b705f885968f34c10b5f738db3, 64f1f564596b5afb21d683c3adb0e43f36c9505a7d5ff8dd0e6f5acc361ad4a3)
Fingerprints: f2dc349dd3cff54bf10125220a357a1ad720a60f33221630b516ae662c7ceb4f, 6c83c72b422a54ac3beff62c9b7e8bcb92d1a657260a8f5fbbf1cb45b8d6e826, bb2c77653800c0a7baf402364e5c613c50c4a065d1fc2b1c94d6f85a32aab1fd
…04b45d8cd7fac22902c3f8b88912b23ca078, 6ba0b0bee2cfa27d661440cc999f697df0a553fbe5ba719041fe3a1cf9c2b6df)
…ty/ItemState tests
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes for findings a person selected after a code audit. Agents made these changes; the run was approved at a gate before this pull request was opened.
Review it as you would any change: agents can be wrong.
Decouple Quality from ItemKind; add Quality/ItemState tests
I could not build or run the tests here, so none of this has been compiled or run.
src/Core/ProposedCode/Domain/Quality.cs:24(value-object-coupled-to-item-kind). Fixed: I removedFromItemKind, theLegendaryconstant and theallowLegendaryconstructor.Qualityno longer referencesItemKind.internal static Quality Unclamped(int)factory. It uses a private constructor with a neutralclampflag, so it knows nothing about item kinds.ItemStatenow holdspublic const int LegendaryQuality = 80.ItemState.Create(ItemKind, int, int)keeps its signature. ForItemKind.Sulfurasit usesQuality.Unclamped(80). Other kinds usenew Quality(quality), which clamps.ItemMaturationServiceoutput should not change.Quality, but also allowed a factory that is not kind-aware.Qualitystill has a non-clamping path, but onlyItemStatecan reach it.tests/Core.Tests/ProposedCode/Domain/QualityTests.cs:26(missing-error-case-test). Fixed: I addedIncrease_WhenAmountIsNegative_ThrowsandDecrease_WhenAmountIsNegative_Throws. Both useact.Should().Throw<ArgumentOutOfRangeException>().tests/Core.Tests/ProposedCode/Domain/QualityTests.cs:60(missing-branch-test). Fixed: I removed theFromItemKindtest and addedtests/Core.Tests/ProposedCode/Domain/ItemStateTests.cs, in namespaceGildedRoseKata.ProposedCode.Tests. It covers:SellInis passed through unchanged for 10, 0 and -3.Centralize item names in ItemKind and extend its tests
I couldn't build or run the tests here, so the build and test run are unconfirmed.
src/Core/ProposedCode/Domain/ItemKind.cs:23(hardcoded-item-names-and-duplicated-aliases)AgedBrieName,BackstageName,ConjuredNameandSulfurasName.AgedBrieAlias,BackstageAliasandConjuredAliasare now explicit constants under a comment saying they are accepted in addition to the canonical names.FromNamenow matches on these constants withorpatterns. The input-to-kind mapping is the same as before, andsrc/Core/OriginalCodeis untouched.tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs:13(weak-test-coverage)"aged brie","AGED BRIE","backstage"), names with surrounding whitespace,""and" ". All of them are expected to map toItemKind.Standard.FromName(null)does not throw and returnsStandard.ItemKind result = null;rather thanItemKind?because I found noNullablesetting in the repo.Dedupe ItemMaturingPolicy and add boundary tests
I couldn't run the build or tests here (my tools only read and write files). I checked each expected value by hand against the code.
src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs:23(duplicated-maturation-algorithm): Fixed: I replaced the fourMature*methods with one privateAge(state, dailyChange, expiredChange)helper. The helper changes quality, advances the day, then applies the expired change if the new sellIn is expired. Each kind now declares only its two changes:BackstageDailyChangereads the sellIn before the day advances (+3 below 6, +2 below 11, otherwise +1), thenResetwhen expired.Mature(ItemKind, ItemState)and the Sulfuras pass-through are unchanged, so behaviour is the same.tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs:46(missing-edge-case-test): Fixed: I added these cases, each checked against the code:ItemState.Create(new ItemKind.Sulfuras(), 10, 5)that checks the state is unchanged and sellIn stays 5.Createsets Sulfuras quality to 80, so the test covers the nonzero sellIn rather than a quality other than 80.Extend ItemMaturationService tests
I couldn't build or run the tests here, so none of the new tests have been run. I worked out the expected values by reading
ItemMaturingPolicy,QualityandItemKind.FromName. Onlytests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cschanged.tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs:14(missing-edge-case-test, ee9c8340…ca078)[InlineData]rows to the existing theory:Mature_PreservesNamecovers a standard name, Aged Brie, Sulfuras, a custom name, an empty name and a null name.Mature_DoesNotMutateInputItemchecks that Name, Quality and SellIn are unchanged and that the result is a different instance.Mature_NullItem_ThrowsNullReferenceExceptionpins the current behaviour withShould().Throw<NullReferenceException>().string?and usename!to avoid nullable warnings. No src files were touched.tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs:25(missing-injection-test, 6ba0b0be…b6df)Mature_WithInjectedPolicy_PassesResolvedKindAndStateAndUsesReturnedState, which uses a private nestedStubMaturingPolicy : IMaturingPolicy. The stub records the call count, theItemKindand theItemStateit receives, and returns a fixedItemState(Quality 33, SellIn 7).ItemKind.AgedBrie;