- Update submodule pointers: xAiApi, Modules/xAiModels, Modules/xHttpService;
- Add Documents/Docs/Developer/xAiApi-14050807-Overview.html and -Overview-1.html (review reports); - Add Documents/GeneratedContext/*-20261029_145645.txt (xAiApi, xAiModels, xAiService); - Add Documents/Docs/ChangeLogs/1405-08-07-v01.html and this commit message file.
This commit is contained in:
@@ -0,0 +1,950 @@
|
||||
<!doctype html>
|
||||
<html
|
||||
lang="fa"
|
||||
dir="rtl"
|
||||
>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1"
|
||||
/>
|
||||
<title>ChangeLog ۱۴۰۵/۰۸/۰۷ v01 - Pre-Production Fixes</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 24px;
|
||||
background: #f4f7fb;
|
||||
color: #172033;
|
||||
font-family: Tahoma, 'Segoe UI', sans-serif;
|
||||
line-height: 1.9;
|
||||
}
|
||||
.wrap {
|
||||
max-width: 1180px;
|
||||
margin: auto;
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 12px 40px #20386422;
|
||||
overflow: hidden;
|
||||
}
|
||||
.hero {
|
||||
padding: 38px;
|
||||
background: linear-gradient(135deg, #173b78, #2563eb);
|
||||
color: #fff;
|
||||
}
|
||||
.meta {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
flex-wrap: wrap;
|
||||
padding: 16px 30px;
|
||||
background: #f8fafc;
|
||||
color: #53627a;
|
||||
}
|
||||
main {
|
||||
padding: 30px;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 26px;
|
||||
padding: 22px;
|
||||
background: #f4f7fb;
|
||||
border-right: 5px solid #2563eb;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.section h2 {
|
||||
color: #173b78;
|
||||
border-bottom: 1px solid #dbe3ef;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.section h3 {
|
||||
color: #1e40af;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
background: #fff;
|
||||
margin: 12px 0;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #dbe3ef;
|
||||
}
|
||||
th {
|
||||
background: #173b78;
|
||||
color: #fff;
|
||||
}
|
||||
code {
|
||||
direction: ltr;
|
||||
display: inline-block;
|
||||
background: #e7edf6;
|
||||
border-radius: 4px;
|
||||
padding: 0 5px;
|
||||
font-family: Consolas, monospace;
|
||||
}
|
||||
pre {
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
overflow: auto;
|
||||
background: #172033;
|
||||
color: #e7eefc;
|
||||
border-radius: 7px;
|
||||
padding: 14px;
|
||||
}
|
||||
.note,
|
||||
.warn {
|
||||
padding: 13px 16px;
|
||||
border-radius: 7px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.note {
|
||||
background: #eff6ff;
|
||||
border-right: 4px solid #2563eb;
|
||||
}
|
||||
.warn {
|
||||
background: #fff7ed;
|
||||
border-right: 4px solid #b45309;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
border-radius: 15px;
|
||||
padding: 1px 10px;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
.mod {
|
||||
background: #b45309;
|
||||
}
|
||||
.new {
|
||||
background: #087f5b;
|
||||
}
|
||||
.del {
|
||||
background: #b91c1c;
|
||||
}
|
||||
.sub {
|
||||
background: #6d28d9;
|
||||
}
|
||||
footer {
|
||||
text-align: center;
|
||||
color: #68758a;
|
||||
padding: 18px;
|
||||
border-top: 1px solid #dbe3ef;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="hero">
|
||||
<h1>گزارش تغییرات ساختار پروژه</h1>
|
||||
<p>
|
||||
xSaherelmWorkspace | تاریخ: ۱۴۰۵/۰۸/۰۷ (2026-10-29) | نسخه
|
||||
مستند: <strong>v01</strong>
|
||||
</p>
|
||||
<p>
|
||||
موضوع: رفع موانع پیش از Production در xAiApi — Scope واقعی
|
||||
RAG، حذف ProxyController، ترتیب Middleware، استانداردسازی
|
||||
SSE و اصلاح باگهای منطقی xAiModels
|
||||
</p>
|
||||
</header>
|
||||
<div class="meta">
|
||||
<span
|
||||
><strong>دامنه:</strong> <code>xAiApi</code>،
|
||||
<code>Modules/xAiModels</code>،
|
||||
<code>Modules/xHttpService</code></span
|
||||
>
|
||||
<span><strong>وضعیت:</strong> commitنشده (Working Tree)</span>
|
||||
<span><strong>Build:</strong> 0 Error</span>
|
||||
</div>
|
||||
<main>
|
||||
<section class="section">
|
||||
<h2>۱. خلاصه</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>موضوع</th>
|
||||
<th>نتیجه</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>۱</td>
|
||||
<td>Scope در RAG ماندگار</td>
|
||||
<td>
|
||||
چهار Scope (Conversation / Project / User /
|
||||
Global) با بررسی مالکیت و بازیابی لایهای
|
||||
پیادهسازی شد.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>۲</td>
|
||||
<td>تداخل Route در ProxyController</td>
|
||||
<td>
|
||||
Controller حذف شد؛ Proxy فقط از طریق
|
||||
<code>XAiModelProxyMiddleware</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>۳</td>
|
||||
<td>ترتیب Middleware</td>
|
||||
<td>
|
||||
ExceptionHandler/HSTS، Static Files پیش از
|
||||
Routing، Swagger فقط در Development.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>۴</td>
|
||||
<td>قالب SSE</td>
|
||||
<td>
|
||||
Helper مشترک در <code>xHttpService</code>؛ قالب
|
||||
<code>data:</code> استاندارد با رویدادهای
|
||||
<code>done</code> و <code>error</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>۵</td>
|
||||
<td>بازآرایی ساختاری</td>
|
||||
<td>
|
||||
ثابتهای Knowledge و enum Scope به
|
||||
<code>xAiModels</code> منتقل شدند.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>۶</td>
|
||||
<td>باگهای منطقی xAiModels</td>
|
||||
<td>
|
||||
شرطهای معکوس فیلتر مالکیت و چند خطای دیگر اصلاح
|
||||
شد.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۲. Scope واقعی در RAG ماندگار (xAiApi)</h2>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span>
|
||||
Providers/XAiRAGService.cs — بازنویسی کامل
|
||||
</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Scope</th>
|
||||
<th>قالب شناسه</th>
|
||||
<th>خواندن</th>
|
||||
<th>نوشتن</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Conversation</td>
|
||||
<td><code>conversation/{id}/{file}#i</code></td>
|
||||
<td>مالک گفتگو</td>
|
||||
<td>مالک گفتگو</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Project</td>
|
||||
<td><code>project/{id}/{file}#i</code></td>
|
||||
<td>مالک پروژه</td>
|
||||
<td>مالک پروژه</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User (پیشفرض)</td>
|
||||
<td><code>user/{ownerId}/{file}#i</code></td>
|
||||
<td>خود کاربر</td>
|
||||
<td>خود کاربر</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Global</td>
|
||||
<td><code>global/{file}#i</code></td>
|
||||
<td>همهٔ کاربران احرازشده</td>
|
||||
<td>فقط نقش <code>admin</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
<ul>
|
||||
<li>
|
||||
بررسی مالکیت از طریق <code>GetProject</code> /
|
||||
<code>GetConversation</code>؛ عدم تطابق ←
|
||||
<code>NotAuthorized</code>، نبود رکورد ←
|
||||
<code>NotFound</code>.
|
||||
</li>
|
||||
<li>
|
||||
بازیابی لایهای: Conversation → Project (بهطور
|
||||
خودکار پروژهٔ همان گفتگو) → User → Global. Embedding
|
||||
سؤال یکبار، حذف نتایج تکراری، هر لایه باقیماندهٔ
|
||||
TopK را پر میکند. <code>IncludeUser</code> و
|
||||
<code>IncludeGlobal</code> قابل غیرفعالشدناند.
|
||||
</li>
|
||||
<li>
|
||||
فیلتر <code>request.Type</code> اکنون واقعاً به
|
||||
<code>SearchVectorsAsync</code> ارسال میشود (قبلاً
|
||||
<code>null</code> بود).
|
||||
</li>
|
||||
<li>
|
||||
پاکسازی نام فایل: حذف مسیر کلاینت و جایگزینی
|
||||
<code>/</code>، <code>\</code> و <code>#</code> تا
|
||||
ساختار شناسه نشکند.
|
||||
</li>
|
||||
<li>
|
||||
اعمال محدودیتهای موجود در تنظیمات:
|
||||
<code>MaxFilesPerIngest</code>،
|
||||
<code>MaxFileSizeBytes</code>،
|
||||
<code>MaxDocumentsPerScope</code> (Global بدون
|
||||
محدودیت تعداد سند).
|
||||
</li>
|
||||
<li>
|
||||
Metadata هر Chunk شامل <code>type</code>،
|
||||
<code>scope</code>، <code>scopeId</code>،
|
||||
<code>ownerId</code>، <code>ingestedAtUtc</code>؛ در
|
||||
Documents و Sources بازگردانده میشود.
|
||||
</li>
|
||||
<li>
|
||||
متد جدید <code>MigrateLegacyVectorsAsync</code>:
|
||||
انتقال دادههای قدیمی <code>{ownerId}/...</code> به
|
||||
<code>user/{ownerId}/...</code> (اول ذخیره، سپس حذف؛
|
||||
تکرارپذیر).
|
||||
</li>
|
||||
</ul>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span>
|
||||
Interfaces/IXAiRAGService.cs
|
||||
</h3>
|
||||
<p>
|
||||
امضای <code>IngestAsync</code>،
|
||||
<code>LoadDocumentsAsync</code> و
|
||||
<code>RemoveDocumentAsync</code> پارامتر
|
||||
<code>XAiKnowledgeScopeDescriptor scope</code> میگیرد؛
|
||||
<code>RetrieveAsync</code> اکنون
|
||||
<code>XAiKnowledgeAskRequest</code> میپذیرد؛
|
||||
<code>MigrateLegacyVectorsAsync</code> اضافه شد.
|
||||
</p>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span>
|
||||
Models/XAiKnowledgeModels.cs
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
حذف <code>using</code>های تکراری (هشدار CS0105).
|
||||
</li>
|
||||
<li>
|
||||
مقدار پیشفرض <code>Scope</code> در Descriptor به
|
||||
<code>User</code> تغییر کرد (قبلاً صفر =
|
||||
Conversation بود و نتایج را غلط گزارش میکرد).
|
||||
</li>
|
||||
<li>
|
||||
Factory جدید
|
||||
<code>XAiKnowledgeScopeDescriptor.User()</code>؛
|
||||
فیلدهای <code>IncludeUser</code> و
|
||||
<code>IncludeGlobal</code> در
|
||||
<code>XAiKnowledgeAskRequest</code>.
|
||||
</li>
|
||||
</ul>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span>
|
||||
Controllers/KnowledgeController.cs
|
||||
</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Endpoint</th>
|
||||
<th>تغییر</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>POST /Knowledge/Ingest</code></td>
|
||||
<td>
|
||||
FormData جدید: <code>scope</code>،
|
||||
<code>scopeId</code> (+
|
||||
<code>knowledgeType</code>،
|
||||
<code>replaceExisting</code>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>GET /Knowledge/Documents</code></td>
|
||||
<td>
|
||||
Query جدید: <code>scope</code>،
|
||||
<code>scopeId</code>، <code>knowledgeType</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>DELETE /Knowledge/Documents</code></td>
|
||||
<td>
|
||||
Query جدید: <code>scope</code>،
|
||||
<code>scopeId</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>POST /Knowledge/MigrateLegacy</code></td>
|
||||
<td>
|
||||
<span class="badge new">جدید</span> مهاجرت
|
||||
دادههای قدیمی کاربر جاری
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>POST /Knowledge/AskStream</code></td>
|
||||
<td>
|
||||
اولین آیتم پیش از شروع Stream دریافت میشود تا
|
||||
خطاهای Scope/مالکیت با کد HTTP مناسب برگردند.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۳. حذف ProxyController (xAiApi)</h2>
|
||||
<h3>
|
||||
<span class="badge del">حذفشده</span>
|
||||
Controllers/ProxyController.cs
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
Route ریشهٔ <code>{modelName}/{path}</code> با همهٔ
|
||||
Verbها و <code>[AllowAnonymous]</code> هر مسیر
|
||||
دوبخشی را تصاحب میکرد (مثلاً
|
||||
<code>GET /Knowledge/Ask</code> بهجای 405 بدون
|
||||
احراز هویت وارد Proxy میشد).
|
||||
</li>
|
||||
<li>
|
||||
درخواست را با یک Hop اضافه به همین سرویس و مسیر
|
||||
<code>/ai-model</code> میفرستاد؛ فقط بدنهٔ JSON و
|
||||
فقط یک Segment از مسیر را پشتیبانی میکرد.
|
||||
</li>
|
||||
<li>
|
||||
Proxy اکنون صرفاً توسط
|
||||
<code>XAiModelProxyMiddleware</code> روی
|
||||
<code>/ai-model/{model}/{**path}</code> با احراز
|
||||
هویت ApiKey/Token انجام میشود.
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۴. ترتیب Middleware (xAiApi)</h2>
|
||||
<h3><span class="badge mod">اصلاحشده</span> Startup.cs</h3>
|
||||
<pre>
|
||||
Development : DeveloperExceptionPage
|
||||
Production : UseExceptionHandler("/error") + UseHsts
|
||||
→ UseHttpsRedirection
|
||||
→ UseXStorageService (Static Files — قبلاً بعد از UseEndpoints بود)
|
||||
→ UseXSwagger (فقط Development — قبلاً همیشه فعال)
|
||||
→ UseXCors → UseXAiModelProxy
|
||||
→ UseRouting → UseXIdentityService → UseAuthorization → UseEndpoints
|
||||
→ UseXPushService (UseSignalR قدیمی؛ عمداً جابهجا نشد)
|
||||
→ Init: Database / String / Tag / File</pre
|
||||
>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span>
|
||||
Controllers/StartupController.cs
|
||||
</h3>
|
||||
<p>
|
||||
Endpoint جدید <code>/error</code> (پنهان از Swagger) که
|
||||
یک <code>XError</code> عمومی با کد 500 برمیگرداند و
|
||||
جزئیات Exception را افشا نمیکند.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۵. استانداردسازی SSE</h2>
|
||||
<h3>
|
||||
<span class="badge new">جدید</span>
|
||||
Modules/xHttpService/Extensions/XSseExtensions.cs
|
||||
</h3>
|
||||
<p>
|
||||
Helper مشترک در ماژول <code>xHttpService</code> (نه در
|
||||
xAiApi) تا سایر سرویسها هم بتوانند استفاده کنند:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>متد</th>
|
||||
<th>کار</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>PrepareSseResponse</code></td>
|
||||
<td>
|
||||
Content-Type
|
||||
<code>text/event-stream; charset=utf-8</code>،
|
||||
Cache-Control،
|
||||
<code>X-Accel-Buffering: no</code>، غیرفعالسازی
|
||||
Buffering
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>WriteSseEventAsync</code></td>
|
||||
<td>
|
||||
سریالسازی camelCase و ارسال <code>data:</code>؛
|
||||
متن چندخطی به چند خط <code>data:</code> تقسیم
|
||||
میشود
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>WriteSseDoneAsync</code></td>
|
||||
<td>
|
||||
<code>event: done</code> +
|
||||
<code>data: [DONE]</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>WriteSseErrorAsync</code></td>
|
||||
<td>
|
||||
<code>event: error</code> +
|
||||
<code>data: {"error":"..."}</code> (هرگز
|
||||
Exception پرتاب نمیکند)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>IsClientCancellation</code></td>
|
||||
<td>
|
||||
تشخیص قطع اتصال کلاینت برای جلوگیری از لاگ خطای
|
||||
کاذب
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span>
|
||||
Modules/xHttpService/xHttpService.csproj
|
||||
</h3>
|
||||
<p>
|
||||
افزودن
|
||||
<code>Microsoft.AspNetCore.Http.Features 2.3.13</code>
|
||||
(برای <code>IHttpBufferingFeature</code>).
|
||||
</p>
|
||||
<h3>
|
||||
<span class="badge mod">اصلاحشده</span> Endpointهای
|
||||
Stream در xAiApi
|
||||
</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Endpoint</th>
|
||||
<th>قبل</th>
|
||||
<th>بعد</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code
|
||||
>XAiServiceControllerBase.AskTextStream</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
<code>{text}\n\n</code> بدون <code>data:</code>
|
||||
</td>
|
||||
<td><code>data: {"text":"..."}</code> + done</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>XAiServiceControllerBase.AskStream</code>
|
||||
</td>
|
||||
<td>
|
||||
<code>{json}</code> بدون <code>data:</code> و
|
||||
جداکننده
|
||||
</td>
|
||||
<td><code>data: {json}</code> + done</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>KnowledgeController.AskStream</code></td>
|
||||
<td><code>data: {json}</code> بدون پایان</td>
|
||||
<td>+ done / error</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code
|
||||
>ChatWithDocumentsController.AskStream</code
|
||||
>
|
||||
</td>
|
||||
<td><code>data: {json}</code> بدون پایان</td>
|
||||
<td>+ done / error</td>
|
||||
</tr>
|
||||
</table>
|
||||
<ul>
|
||||
<li>
|
||||
اعتبارسنجی پیش از شروع Stream؛ خطا با کد 400 و JSON
|
||||
برمیگردد (قبلاً 200 خالی).
|
||||
</li>
|
||||
<li>
|
||||
خطای پیش از شروع Stream از طریق
|
||||
<code>GetExceptionActionResult</code> با کد HTTP
|
||||
درست (401/404/...) برمیگردد.
|
||||
</li>
|
||||
<li>
|
||||
هدر <code>Connection: keep-alive</code> حذف شد (در
|
||||
HTTP/2 نامعتبر است).
|
||||
</li>
|
||||
</ul>
|
||||
<div class="warn">
|
||||
<b>تغییر شکننده:</b> کلاینتهای
|
||||
<code>AskTextStream</code> و <code>AskStream</code> باید
|
||||
به قالب جدید (<code>data:</code> +
|
||||
<code>event: done</code>) مهاجرت کنند.
|
||||
</div>
|
||||
<pre>
|
||||
data: {"text":"سلام"}
|
||||
|
||||
data: {"text":" دنیا"}
|
||||
|
||||
event: done
|
||||
data: [DONE]</pre
|
||||
>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۶. بازآرایی ساختاری: انتقال ثابتها به xAiModels</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>مسیر</th>
|
||||
<th>شرح</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">جدید</span></td>
|
||||
<td>
|
||||
<code
|
||||
>Modules/xAiModels/Constants/XAiKnowledgeScope.cs</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
enum با <code>Conversation=0</code>،
|
||||
<code>Project=1</code>، <code>Global=2</code>،
|
||||
<code>User=3</code> و
|
||||
<code>[StringValue]</code> برای پیشوند شناسه
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge del">حذفشده</span></td>
|
||||
<td>
|
||||
<code
|
||||
>xAiApi/Constants/XAiKnowledgeScope.cs</code
|
||||
>
|
||||
</td>
|
||||
<td>به xAiModels منتقل شد</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">اصلاحشده</span></td>
|
||||
<td>
|
||||
<code
|
||||
>Modules/xAiModels/Constants/XAiModelsConstants.cs</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
ثابتهای Knowledge، پیشوندهای Scope، کلیدهای
|
||||
Metadata، <code>XAiErrorRoute</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">اصلاحشده</span></td>
|
||||
<td>
|
||||
<code>xAiApi/Constants/XAiApiConstants.cs</code>
|
||||
</td>
|
||||
<td>
|
||||
حذف ثابتهای منتقلشده و
|
||||
<code>XOpenAINoKey</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">اصلاحشده</span></td>
|
||||
<td>
|
||||
<code
|
||||
>xAiApi/Extensions/XModelsExtensions.cs</code
|
||||
><br /><code
|
||||
>xAiApi/Providers/XAiEmbeddingServiceBase.cs</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
ارجاع به
|
||||
<code>XAiModelsConstants.XOpenAINoKey</code>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="note">
|
||||
مقادیر عددی enum و رشتههای ثابت تغییر نکردهاند؛ فقط
|
||||
namespace از <code>xAiApi.Constants</code> به
|
||||
<code>xAiModels.Constants</code> رفته است.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۷. رفع باگهای منطقی در xAiModels</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>فایل / متد</th>
|
||||
<th>مشکل</th>
|
||||
<th>اصلاح</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>XAiDataProvider.QueryProjects</code
|
||||
><br /><code>QueryConversations</code
|
||||
><br /><code>QueryMessages</code>
|
||||
</td>
|
||||
<td>
|
||||
شرط معکوس
|
||||
<code>if (ownerId.IsNullOrEmpty())</code>: فیلتر
|
||||
مالکیت فقط با ownerId خالی اعمال میشد و کاربر
|
||||
دادههای دیگران را میدید.
|
||||
</td>
|
||||
<td>
|
||||
<code>if (!ownerId.IsNullOrEmpty())</code> —
|
||||
<b>رفع نشت داده بین کاربران</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>XAiDataProvider.LoadConversations</code>
|
||||
</td>
|
||||
<td>
|
||||
<code>ignoreSoftDeleteds: false</code> گفتگوهای
|
||||
حذفشده را هم برمیگرداند
|
||||
</td>
|
||||
<td><code>true</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>CreateProject</code> (۲ مورد)<br /><code
|
||||
>CreateConversation</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
پرچم <code>isDefaultLanguageHandled</code> پس از
|
||||
تنظیم زبان پیشفرض <code>false</code> میماند
|
||||
</td>
|
||||
<td><code>true</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>GetDefaultConversation</code></td>
|
||||
<td>
|
||||
استفاده از <code>project.Id</code> پیش از
|
||||
بارگذاری <code>project</code>
|
||||
</td>
|
||||
<td><code>id: projectId</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code
|
||||
>XAiModelsExtensions.HasDefaultProject</code
|
||||
><br /><code>HasDefaultConversation</code>
|
||||
</td>
|
||||
<td>
|
||||
شرط معکوس <code>if (source.HasChild())</code>:
|
||||
برای لیست غیرخالی Exception پرتاب میشد
|
||||
</td>
|
||||
<td><code>if (!source.HasChild() ...)</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۸. سایر تغییرات xAiApi</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>مسیر</th>
|
||||
<th>شرح</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">اصلاحشده</span></td>
|
||||
<td><code>Database/XAiApiDbContext.cs</code></td>
|
||||
<td>
|
||||
ثبت <code>XAiVectorEntityRegisterar</code>؛ بدون
|
||||
آن Entity جدول <code>XAiVector</code> در
|
||||
DbContext ثبت نمیشد.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">اصلاحشده</span></td>
|
||||
<td>
|
||||
<code
|
||||
>Providers/Extractors/XCodeFileContentExtractor.cs</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
محتوای فایل واقعاً با
|
||||
<code>ReadToEndAsync</code> خوانده میشود (قبلاً
|
||||
<code>result.Text</code> خالی میماند)؛ نام فایل
|
||||
ثابت <code>"book.epub"</code> حذف شد.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۹. وضعیت Git در کل Workspace</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>مسیر</th>
|
||||
<th>شرح</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge sub">سابماژول</span></td>
|
||||
<td><code>xAiApi</code></td>
|
||||
<td>
|
||||
۱۵ فایل (۱۳ اصلاح، ۲ حذف) — حدود ۹۲۵+ / ۵۹۵−
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge sub">سابماژول</span></td>
|
||||
<td><code>Modules/xAiModels</code></td>
|
||||
<td>
|
||||
۳ اصلاح + ۱ فایل جدید
|
||||
(<code>XAiKnowledgeScope.cs</code>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge sub">سابماژول</span></td>
|
||||
<td><code>Modules/xHttpService</code></td>
|
||||
<td>
|
||||
۱ اصلاح (<code>csproj</code>) + ۱ فایل جدید
|
||||
(<code>XSseExtensions.cs</code>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">جدید</span></td>
|
||||
<td>
|
||||
<code
|
||||
>Documents/Docs/Developer/xAiApi-14050807-Overview*.html</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
گزارش بازبینی معماری که این تغییرات بر اساس آن
|
||||
انجام شد
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">جدید</span></td>
|
||||
<td>
|
||||
<code
|
||||
>Documents/GeneratedContext/*-20261029_145645.txt</code
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
Context تولیدشدهٔ xAiApi، xAiModels، xAiService
|
||||
(مستندات کمکی)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">جدید</span></td>
|
||||
<td>
|
||||
<code
|
||||
>Documents/Docs/ChangeLogs/1405-08-07-v01.html</code
|
||||
><br /><code
|
||||
>CommitMessage-1405-08-07-v01.txt</code
|
||||
>
|
||||
</td>
|
||||
<td>همین گزارش و پیام Commit</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="note">
|
||||
<b>ترتیب Commit:</b> ابتدا سابماژولهای
|
||||
<code>Modules/xHttpService</code> و
|
||||
<code>Modules/xAiModels</code> (وابستگیها)، سپس
|
||||
<code>xAiApi</code>، و در پایان مخزن اصلی برای
|
||||
بهروزرسانی pointerها و مستندات.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۱۰. اعتبارسنجی</h2>
|
||||
<pre>
|
||||
dotnet build xAiApi/xAiApi.csproj --nologo -v q
|
||||
392 Warning(s) (MSB3277 / NU1900 — تعارض نسخهٔ مراجع، از قبل موجود)
|
||||
0 Error(s)</pre
|
||||
>
|
||||
<table>
|
||||
<tr>
|
||||
<th>درخواست (Development، بدون توکن)</th>
|
||||
<th>نتیجه</th>
|
||||
<th>معنا</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>GET /</code></td>
|
||||
<td>200</td>
|
||||
<td>سرویس بالا آمد</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>GET /Knowledge/Ask</code></td>
|
||||
<td>405</td>
|
||||
<td>دیگر توسط ProxyController تصاحب نمیشود</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>GET /foo/bar</code></td>
|
||||
<td>404</td>
|
||||
<td>مسیر دوبخشی ناشناخته</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>GET /error</code></td>
|
||||
<td>500 JSON</td>
|
||||
<td>Endpoint خطای عمومی</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>GET /ai-model/NotExists/v1/models</code>
|
||||
</td>
|
||||
<td>404</td>
|
||||
<td>Middleware پروکسی فعال است</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Endpointهای محافظتشده (Knowledge,
|
||||
AskTextStream)
|
||||
</td>
|
||||
<td>401</td>
|
||||
<td>Authorization سالم</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="warn">
|
||||
تست End-to-End با کاربر احرازشده و مدل Embedding/LLM
|
||||
واقعی (Ingest/Ask/AskStream در Scopeهای مختلف، بررسی
|
||||
403/NotAuthorized روی پروژهٔ کاربر دیگر) هنوز انجام نشده
|
||||
است.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۱۱. اقدامات بعدی</h2>
|
||||
<ul>
|
||||
<li>
|
||||
هماهنگی Frontend با قالب جدید SSE در
|
||||
<code>AskTextStream</code> و <code>AskStream</code>.
|
||||
</li>
|
||||
<li>
|
||||
فراخوانی
|
||||
<code>POST /Knowledge/MigrateLegacy</code> برای هر
|
||||
کاربر دارای دادههای قبلی (یا افزودن یک Job
|
||||
یکباره).
|
||||
</li>
|
||||
<li>
|
||||
بررسی <code>UseHsts</code> در Production اگر سرویس
|
||||
پشت Reverse Proxy بدون TLS اجرا میشود.
|
||||
</li>
|
||||
<li>
|
||||
بررسی دسترسی بدون احراز هویت به فایلهای آپلودشده در
|
||||
<code>wwwroot/Storage/Uploads</code> (خارج از این
|
||||
تغییرات).
|
||||
</li>
|
||||
<li>
|
||||
جستجوی برداری فعلاً همهٔ کاندیداهای پیشوند را در
|
||||
حافظه امتیازدهی میکند؛ برای حجم بالا ایندکس برداری
|
||||
توصیه میشود.
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۱۲. فایلهای مستند</h2>
|
||||
<p>
|
||||
گزارش:
|
||||
<code
|
||||
>Documents/Docs/ChangeLogs/1405-08-07-v01.html</code
|
||||
>
|
||||
</p>
|
||||
<p>
|
||||
Commit message:
|
||||
<code
|
||||
>Documents/Docs/ChangeLogs/CommitMessage-1405-08-07-v01.txt</code
|
||||
>
|
||||
</p>
|
||||
<p>
|
||||
برای تغییرات بعدی همین تاریخ از پسوند
|
||||
<code>v02</code> استفاده شود.
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
<footer>
|
||||
تولیدشده در تاریخ ۱۴۰۵/۰۸/۰۷ (2026-10-29) | xSaherelmWorkspace |
|
||||
ChangeLog v01
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,84 @@
|
||||
===============================================================================
|
||||
Commit Message - xSaherelmWorkspace
|
||||
تاریخ: ۱۴۰۵/۰۸/۰۷ (2026-10-29)
|
||||
نسخه مستند: v01
|
||||
گزارش کامل: Documents/Docs/ChangeLogs/1405-08-07-v01.html
|
||||
===============================================================================
|
||||
|
||||
هدف: رفع موانع پیش از Production در xAiApi (Scope واقعی RAG، حذف
|
||||
ProxyController، ترتیب Middleware، قالب SSE) و اصلاح باگهای منطقی xAiModels.
|
||||
|
||||
ترتیب Commit: [1] xHttpService -> [2] xAiModels -> [3] xAiApi -> [4] Root
|
||||
|
||||
[1] Modules/xHttpService
|
||||
Add Shared Server-Sent Events Helpers
|
||||
- Add XSseExtensions: PrepareSseResponse, WriteSseEventAsync, WriteSseRawAsync,
|
||||
WriteSseDoneAsync, WriteSseErrorAsync, IsClientCancellation;
|
||||
- Spec-compliant "data:" framing, multi-line split, "event: done" / "event: error";
|
||||
- Add Microsoft.AspNetCore.Http.Features 2.3.13 reference.
|
||||
Files: A Extensions/XSseExtensions.cs; M xHttpService.csproj
|
||||
|
||||
[2] Modules/xAiModels
|
||||
Move Knowledge Constants and Fix Inverted Ownership Filters
|
||||
- Add XAiKnowledgeScope enum (Conversation=0, Project=1, Global=2, User=3) with StringValue prefixes;
|
||||
- Add Knowledge constants, scope prefixes, metadata keys and XAiErrorRoute to XAiModelsConstants;
|
||||
- Fix inverted ownerId condition in QueryProjects / QueryConversations / QueryMessages
|
||||
(ownership filter was skipped for real owners -> cross-user data exposure);
|
||||
- Fix inverted HasChild() validation in HasDefaultProject / HasDefaultConversation;
|
||||
- LoadConversations: ignore soft-deleted conversations;
|
||||
- CreateProject / CreateConversation: set isDefaultLanguageHandled = true;
|
||||
- GetDefaultConversation: use projectId instead of unloaded project.Id.
|
||||
Files: A Constants/XAiKnowledgeScope.cs; M Constants/XAiModelsConstants.cs;
|
||||
M Extensions/XAiModelsExtensions.cs; M Providers/XAiDataProvider.cs
|
||||
|
||||
[3] xAiApi
|
||||
Implement RAG Scopes, Remove ProxyController, Fix Pipeline Order and SSE Format
|
||||
- RAG: real scopes with identifiers conversation/{id}/, project/{id}/, user/{ownerId}/, global/;
|
||||
- RAG: ownership checks via GetProject/GetConversation; Global write requires admin role;
|
||||
- RAG: tiered retrieval Conversation -> Project -> User -> Global (single embedding, dedup, TopK fill);
|
||||
- RAG: apply Type filter, sanitize file names, enforce MaxFilesPerIngest/MaxFileSizeBytes/MaxDocumentsPerScope;
|
||||
- RAG: store scope/scopeId/type/ownerId metadata; return it in documents and sources;
|
||||
- RAG: add MigrateLegacyVectorsAsync + POST /Knowledge/MigrateLegacy ({ownerId}/... -> user/{ownerId}/...);
|
||||
- Knowledge API: scope/scopeId on Ingest, Documents, DELETE Documents;
|
||||
- Remove ProxyController (root route "{modelName}/{path}" + AllowAnonymous hijacked all 2-segment paths);
|
||||
- Startup: ExceptionHandler("/error") + HSTS outside Development; Swagger only in Development;
|
||||
static files before routing; CORS before model proxy; add /error endpoint;
|
||||
- SSE: all stream endpoints use xHttpService XSseExtensions; validate before streaming;
|
||||
pre-stream errors return proper HTTP status; remove "Connection: keep-alive";
|
||||
- Use xAiModels.Constants for XAiKnowledgeScope / Knowledge constants / XOpenAINoKey;
|
||||
- Register XAiVectorEntityRegisterar in XAiApiDbContext;
|
||||
- XCodeFileContentExtractor: actually read stream content; drop hard-coded "book.epub".
|
||||
BREAKING: AskTextStream emits data: {"text":"..."}; AskStream emits data: {json}; both end with event: done.
|
||||
Files: D Controllers/ProxyController.cs; D Constants/XAiKnowledgeScope.cs;
|
||||
M Constants/XAiApiConstants.cs; M Controllers/ChatWithDocumentsController.cs;
|
||||
M Controllers/KnowledgeController.cs; M Controllers/StartupController.cs;
|
||||
M Controllers/XAiServiceControllerBase.cs; M Database/XAiApiDbContext.cs;
|
||||
M Extensions/XModelsExtensions.cs; M Interfaces/IXAiRAGService.cs;
|
||||
M Models/XAiKnowledgeModels.cs; M Providers/Extractors/XCodeFileContentExtractor.cs;
|
||||
M Providers/XAiEmbeddingServiceBase.cs; M Providers/XAiRAGService.cs; M Startup.cs
|
||||
|
||||
[4] Workspace (root)
|
||||
- Update submodule pointers: xAiApi, Modules/xAiModels, Modules/xHttpService;
|
||||
- Add Documents/Docs/Developer/xAiApi-14050807-Overview.html and -Overview-1.html (review reports);
|
||||
- Add Documents/GeneratedContext/*-20261029_145645.txt (xAiApi, xAiModels, xAiService);
|
||||
- Add Documents/Docs/ChangeLogs/1405-08-07-v01.html and this commit message file.
|
||||
|
||||
Validation:
|
||||
- dotnet build xAiApi/xAiApi.csproj --nologo -v q -> 0 Error(s), 392 pre-existing warnings (MSB3277/NU1900);
|
||||
- Runtime smoke (Development, anonymous): GET / 200; GET /Knowledge/Ask 405 (no longer proxied);
|
||||
GET /foo/bar 404; GET /error 500 JSON; /ai-model/NotExists 404 (middleware); protected endpoints 401;
|
||||
- Authenticated end-to-end tests (Ingest/Ask/AskStream with real embedding/LLM) still pending.
|
||||
|
||||
Follow-ups:
|
||||
- Frontend must migrate to the new SSE format;
|
||||
- Call POST /Knowledge/MigrateLegacy for users with legacy vectors;
|
||||
- Review UseHsts behind TLS-terminating reverse proxy;
|
||||
- Review anonymous access to wwwroot/Storage/Uploads.
|
||||
|
||||
Suggested root commit title:
|
||||
Implement RAG Scopes, Remove ProxyController, Fix Pipeline and SSE, Fix xAiModels Ownership Filters (۱۴۰۵/۰۸/۰۷ v01)
|
||||
|
||||
For additional documentation use v02:
|
||||
1405-08-07-v02.html
|
||||
CommitMessage-1405-08-07-v02.txt
|
||||
===============================================================================
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\Constants\ConfigurationNodeNames.cs
|
||||
|
||||
namespace xAiService.Constants
|
||||
{
|
||||
public partial struct ConfigurationNodeNames
|
||||
{
|
||||
public const string AI_SERVICE_NODE = "AIServiceConfiguration";
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\Constants\XAiServiceConstants.cs
|
||||
|
||||
namespace xAiService.Constants
|
||||
{
|
||||
public struct XAiServiceConstants
|
||||
{
|
||||
//
|
||||
// Service Extensions Log Tag ...
|
||||
public const string XAiServiceDILogTag = "XAiService";
|
||||
|
||||
//
|
||||
// File Provider Identifiers ...
|
||||
public const string XAiProjectFilesIdentifier = "AiPrjF";
|
||||
public const string XAiMessageFilesIdentifier = "AiMsgF";
|
||||
public const string XMetaDataFileIdsIdentifier = "FileIds";
|
||||
public const string XAiConversationFilesIdentifier = "AiCnvrF";
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\DI\XDIHelperExtension.cs
|
||||
|
||||
namespace xAiService.DI
|
||||
{
|
||||
public static partial class XDIHelperExtension
|
||||
{ }
|
||||
}
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\Extensions\XAiServiceExtensions.cs
|
||||
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityModels.Models;
|
||||
|
||||
namespace xAiService.Extensions
|
||||
{
|
||||
public static class XAiServiceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Validate User Info ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XUserClaimsInfoDto source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.UserId.IsNullOrEmpty() &&
|
||||
!source.AccessToken.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate User Info ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="invalidException"></param>
|
||||
public static void Validate(
|
||||
this XUserClaimsInfoDto source,
|
||||
XException invalidException = XException.InvalidArgs
|
||||
)
|
||||
{
|
||||
//
|
||||
var isValid = source.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
invalidException.Throw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
Submodule Modules/xAiModels updated: 093fc08e14...ef1421def4
+1
-1
Submodule Modules/xHttpService updated: d412141193...f3372333fd
+1
-1
Submodule xAiApi updated: d3ecc8feea...37d4e622e9
Reference in New Issue
Block a user