Drn utils

From duranserkan/DRN-Project · View interactive version

Drn utils is an AI agent skill from the GitHub repository duranserkan/DRN-Project. DRN utilities for DI, configuration, scoped diagnostics, HTTP, Source-Known IDs, cancellation, and MFA.

How to use this skill

Skill file

DRN.Framework.Utils

Use the installed DRN.Framework.Utils README and XML documentation for API signatures and examples. Locate the package

Registration and configuration

Scan the application's service assembly with services.AddServicesWithAttributes(typeof(OrderService).Assembly). Annotate the implementation with [Scoped<IOrderService>]. Import DRN.Framework.Utils.DependencyInjection for the extension and DRN.Framework.Utils.DependencyInjection.Attributes for the attribute.

DRNDEPENDENCYINJECTION001 checks eligible services and repositories on supported attribute-scan paths. Consult SharedKernel's installed CONVENTIONS.md for service eligibility, key matching and exceptions. Custom composition still requires runtime verification.

Nexus Keys

Configure NexusAppSettings:AppId (0 through 127) and AppInstanceId (0 through 63) explicitly in every environment. Zero is valid. Concurrent generators in the same partition need distinct instance IDs. Configure exactly one default Nexus key. All keys must decode to 32 bytes using the declared UTF-8, Hex, Base64, or Base64Url encoding. Write with the default key and retain previous keys for rotation reads.

ID Generation

Validate<TEntity> checks the entity's declared type and application partition. Validate(id, entityType) uses the configured partition. Select another explicitly with Validate<TApp> or an EntityTypeId. Never trust a caller-constructed ID record at an external boundary.

ConfiguredDefault selects Secure or Plain from UseSecureSourceKnownIds. Secure requires decryption and verification. Plain skips decryption. Auto tries plain then encrypted forms. Keep format overrides under application control. Authenticate an external GUID in the required format before conversion. Conversions revalidate using Auto. Undefined formats fail even for null IDs. Apply authorization and rate limits separately. See SharedKernel validation.

Configure epoch and minimum before first use. Generation, decoding and filtering must share an epoch across a dataset. Use EntityCreatedFilter for date boundaries. Inclusive boundaries admit the whole 250 ms tick, exclusive boundaries exclude it, and reversed endpoints normalize. Domain filtering

Scoped logging and classification

Use IScopedLog for operation diagnostics. Use code-owned metric names. A scoped log owns a correlation ID and captures a W3C trace ID only when one exists. HTTP request IDs and native activity fields have separate meanings. Copies retain the destination's correlation and primary event.

Scope events bypass diagnostic sanitization and budgets. Supply safe event data. Keep one primary and up to eight additional events on the first emitted record, with the omission count when needed. Ordinary diagnostic values remain bounded on every record.

Classify dynamic backend values at capture. Compiler name/path checks and browser rules do not redact server values at runtime. Explicit URL capture removes credentials and validates encoding. Explicit Sensitive/Personal values redact as [redacted]. Free text keeps its contents within capture budgets. See the installed DRN.Framework.Utils README and its linked GitHub diagnostic guide for capture limits and overflow behavior.

HTTP and ambient context

Inject IExternalRequest for external endpoints or IInternalRequest for service traffic. Inject a handler for test routing. Buffered converters dispose the response even on read failure. Dispose streaming wrappers after consumption.

Try converters preserve readable HTTP statuses and payloads, return processing failures separately and propagate cancellation. ThrowIfFailure() rethrows a captured failure with its original stack. Check status explicitly when a readable error response should fail the operation. Keep failure messages and exceptions out of public responses and redact them before logging.

Use ScopeContext only after Hosting initializes a request or a test calls InitializeForTest. Use injected services elsewhere. ScopeContext.Problem supplies missing public response fields. Keep diagnostics private. Its exception factories throw immediately. Hosting error mapping

Scoped Cancellation

ICancellationUtils.Root affects all present and future children in the DI scope. Merging an external token or canceling a keyed child affects only that group. To cancel one operation, create and dispose a local linked token source after all consumers finish.

Use typed CancellationScopeKey.For<T>() for a component, optionally with a constant name. Ownerless keys share an ordinal, case-sensitive namespace. Names are non-null, at most 128 characters and may be empty. Never derive them from requests or instance IDs. The default key is invalid. Reusing a key returns the same scope and stable token. Canceled scopes stay canceled. The service owns child scopes. Disposal remains safe inside cancellation callbacks. See repository cancellation.

Authentication and other utilities

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.