FILE / ScuroNeko/Laniakea
TODO.md
Исходный файл и его история в репозитории.
6.7 KiB
6.7 KiB
TODO
v1.0.0 pre-release review
Findings from the full-repo review against AGENTS.md priorities. Build, vet, tests, and lint are clean; items below are public-API and godoc hygiene before the stable tag.
Major — close before 1.0.0 tag
- M1.
BotPayloadType*arevar, must beconst—bot.go:50-59. Public sentinels are user-mutable globals.KeyboardButtonStyle*inkeyboard.go:10-17already usesconst; match the pattern. - M2.
Observermethod naming asymmetry —observer.go:147-157.OnReceiveUpdate→OnUpdateReceived;OnHandledUpdate→OnUpdateHandledto matchUpdateReceivedEvent/UpdateHandledEventand the rest of theOnXpattern. Breaking after 1.0. - M3. Uploader returns ad-hoc error string instead of
*ResponseError—tgapi/uploader_api.go:183.tgapi/api.go:258-292returns*ResponseError; uploader must do the same soerrors.As(err, &tgapi.ResponseError{})works for upload paths too. - M4.
BotOptsFileJSONis missingPollTimeout—bot_opts_loader.go:35-46, plusFromBytes/ToBytesmapping. File round-trip silently dropsPollTimeout. - M5. Stale
Bot.Updatesgodoc —methods.go:11-44. Claims "30-second timeout" and "empty slice if none"; in reality timeout isbot.pollTimeoutand the function returnsnilon error. - M6. Self-contradicting
NewRandomDraftProvidergodoc —drafts.go:50-59. Says "cryptographically secure random numbers" but usesmath/rand/v2(the underlying generator type correctly notes it is not crypto-secure). - M7.
Draft.Deletegodoc says "internal method" —drafts.go:190-201. Method is exported; either rewrite the godoc with a public-intent description or unexport. - M8. Russian comments in production code
msg_handler.go:28— "Ищем команду по точному совпадению"tgapi/uploader_api.go:181— "Повторяем запрос"
- M9.
MessageContext.Errorgodoc references unexported helper —msg_context.go:540. "Error is an alias for error()" — rewrite to describe the centralized handler error path andIsUserErrorgating. - M10.
SceneandSceneSessionmix exported fields with settersSceneexportsName/Scope/Entry/PluginNameand also hasSetScope/SetEntry;PluginNameis framework-assigned but publicly mutable.SceneSessionexportsData []byteand also hasSet/Get/HasData/ClearData/BindData/SaveData.- Pick one model per type before 1.0.0.
- M11. Constant-time compare for webhook secret —
bot_webhook.go:296(update handler) andbot_webhook.go:341(/status). Usesubtle.ConstantTimeCompare.
Minor — can slip to 1.0.x
- Strip
// Internal helper …godoc from unexported funcs (~23 occurrences in repo);AGENTS.mdexplicitly forbids godoc-style comments on unexported declarations without a strong reason. Plugin.AddCommandgodoc references unexported field.command—plugins.go:48-49.Runnerbuilder naming:runner.Once(true),runner.Async(true)read awkwardly; considerSetOnce/SetAsyncto matchSet*on other types, or zero-argOnce()+ pairedRepeat(every).- Typo in webhook error string:
bot_webhook.go:143— "MaxConnections must between 1 and 100" (missingbe). RunWebhookWithContextuses inlineerrors.New(...)instead ofErr*sentinels (bot_webhook.go:131-156); rest of the package uses sentinels fromerrors.go.tgapi.UpdateTypeManagedBot(tgapi/types.go:61) has no godoc.Bot.GetAPI,Bot.GetUploader,InlineKeyboard.GetMaxRowhave no godoc.Bot.L10ngodoc says "Returns empty string if translation not found"; actually returns the key (l10n.go:48-59).Bot.handlepanic recovery only logs — emitErrorEventso observers see panics (handler.go:18-23).handleCallbackvshandleMessagediffer in plugin-logger assignment: callback assigns unconditionally then falls back to bot logger (msg_handler.go:209-212); message only assigns if non-nil (msg_handler.go:35-37). Align.SetCallbackDatagodoc says "default payload type is JSON" — actually the zeroBotPayloadTypefalls through to thedefaultbranch (which happens to be JSON). Either document the zero-value behavior explicitly or initialize the builder with the bot's default (keyboard.go:106-122).commands.go:62-66— emptycase CommandValueAny:next todefault: regex = nillooks like an incomplete switch. Merge or add a one-line comment.Bot.SetDebugdoes not callconfigMutableunlike sibling setters; if intentional, note it in godoc.
Tests to add after the fixes
BotOptsFileJSONround-trip forPollTimeout(after M4).- Uploader 4xx/429 surfaces
*tgapi.ResponseError(after M3). Bot.handlepanic → observer receivesErrorEvent(after panic-recovery fix).- Webhook
/statuswith wrongSecretTokenreturns 403 /403-equivalent (after M11), incl. a constant-time-compare smoke. - Table-driven
parseCommandcases for/cmd@botnameand stripping behavior.
The framework backlog has moved to the wiki.
Primary page:
Russian page:
Current priority split:
Partial: none.Ideas: service layer and dependency graph model, plugin composition contract.
Completed former high-priority items:
[v1.0.0-rc.14] Webhook runtime model.[v1.0.0-rc.13] Observability model: added first-classObserverevents for update, command, payload, scene, policy, runner, polling, and centralized error flows, with safe event dispatch and regression coverage for the new runtime hooks.[v1.0.0-rc.13] Authorization and policy model: added first-classPolicy[T], middleware integration throughRequirePolicy(...), plugin and bot policy registration helpers, built-in Telegram-aware policies, and composableAllPolicies(...),AnyPolicy(...), andNotPolicy(...)helpers with regression coverage.[v1.0.0-rc.13] Update schema contract: documented and tested the normalizedMsgContextupdate-routing contract, including routing categories and per-update field guarantees.[v1.0.0-rc.13] User-facing vs internal error model: added explicit user-visible vs internal-only error markers and updated centralized handler error routing accordingly.[v1.0.0-rc.13] Configuration freeze model: formalized bot configuration freeze after first run, documented lifecycle commit points, and added regression coverage for ignored late mutations.[v1.0.0-rc.12] Conversation / Scene Model.[v1.0.0-rc.12] Typed Handler Input Model.[v1.0.0-rc.12] Request Context / Cancellation Model.