Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/bounded-user-regex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@agent-native/core": patch
---

Add `compileUserRegex`, `testUserRegex`, and `analyzeRegexSource` to
`@agent-native/core/shared` for evaluating regular expressions that come from an
agent or an end user rather than from source.

`new RegExp(source).test(value)` is not a bounded operation, and JavaScript has
no way to time a match out once V8 is inside it. A pattern an LLM routinely
writes to mean "at least two words" — `^([A-Za-z]+\s?)+$` — is 17 characters,
compiles cleanly, and backtracks exponentially: a 26-character non-matching
value already costs ~750 ms and the cost doubles with every further character.
Stored on a form field it froze the respondent's tab and, because the same
pattern was re-checked on submit, the request handler's event loop with it.
Capping the input length does not help, because the blowup is reached well
inside any sane cap.

`analyzeRegexSource` recognises the ambiguity signatures that cause
super-linear backtracking (nested and adjacent overlapping repetition, nullable
parts under an unbounded repeat, overlapping single-atom alternatives) and
refuses those patterns instead of running them. Patterns it clears are still
evaluated against a capped input. `testUserRegex` returns a tri-state result so
"did not match" and "was not evaluated" stay distinguishable — collapsing the
second into the first is how an unenforceable rule silently becomes an
enforced-looking one.
16 changes: 8 additions & 8 deletions packages/core/docs/content/locales/ar-SA/plan-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ description: "ثبِّت مهارات Agent-Native Plan (/visual-plan، و/visua
<div class="diagram-routes">
<div class="diagram-col">
<div class="diagram-node">
CLI العام<br /><small class="diagram-muted"
>skills add visual-plan</small
>
CLI العام<br /><small class="diagram-muted">skills add visual-plan</small>
</div>
<div class="diagram-node">
مكوّن Claude Code الإضافي<br /><small class="diagram-muted"
>/plugin install</small
>
</div>
<div class="diagram-node">
مكوّن Codex الإضافي<br /><small class="diagram-muted">codex plugin add</small>
مكوّن Codex الإضافي<br /><small class="diagram-muted"
>codex plugin add</small
>
</div>
</div>
<div class="diagram-arrow diagram-muted" aria-hidden="true">&rarr;</div>
Expand Down Expand Up @@ -155,16 +155,16 @@ npx @agent-native/core@latest plan local serve --dir plans/<slug> --kind plan --
<span class="diagram-pill accent">افتراضي · مستضاف</span
><strong>النشر إلى تطبيق Plan</strong
><small class="diagram-muted"
>موصل MCP &rarr; قاعدة بيانات مستضافة &rarr; روابط مشاركة، وتعليقات،
وسجل، ولقطات شاشة</small
>موصل MCP &rarr; قاعدة بيانات مستضافة &rarr; روابط مشاركة، وتعليقات، وسجل،
ولقطات شاشة</small
>
</div>
<div class="diagram-card">
<span class="diagram-pill warn">خصوصية الملفات المحلية</span
><strong>كتابة MDX على القرص</strong
><small class="diagram-muted"
>plan.mdx + canvas.mdx + prototype.mdx &rarr; جسر localhost &rarr;
تقرأ واجهة Plan المستضافة المصدر المحلي. لا كتابة في قاعدة البيانات حتى
>plan.mdx + canvas.mdx + prototype.mdx &rarr; جسر localhost &rarr; تقرأ
واجهة Plan المستضافة المصدر المحلي. لا كتابة في قاعدة البيانات حتى
<code>publish-visual-plan</code>.</small
>
</div>
Expand Down
86 changes: 43 additions & 43 deletions packages/core/docs/content/locales/ar-SA/pr-visual-recap.mdx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ description: "اربط مجلدات Markdown وMDX بمساحات Content الم
<div class="diagram-flow">
<div class="diagram-col">
<div class="diagram-node">
مساحة موجودة<br /><small class="diagram-muted"
>شخصية أو مؤسسة</small
>
مساحة موجودة<br /><small class="diagram-muted">شخصية أو مؤسسة</small>
</div>
<div class="diagram-node">
مساحة جديدة مدعومة بمجلد<br /><small class="diagram-muted"
Expand Down Expand Up @@ -90,11 +88,11 @@ Desktop. لا يخزّن Content في SQL سوى معرف اتصال معتم،

### اختر سياسة المصدر الموثوق

| السياسة | السلوك |
| ------------------------ | -------------------------------------------------------------------- |
| `database_primary` | Content هو المرجع الموثوق؛ تتم مراجعة تغييرات المجلد قبل استخدامها |
| السياسة | السلوك |
| ------------------------ | ------------------------------------------------------------------ |
| `database_primary` | Content هو المرجع الموثوق؛ تتم مراجعة تغييرات المجلد قبل استخدامها |
| `source_primary` | يكون المجلد هو المرجع الموثوق عند عدم وجود تعديل متزامن في Content |
| `reviewed_bidirectional` | تتطلب التغييرات في أي من الاتجاهين المراجعة عند وجود تعارضات |
| `reviewed_bidirectional` | تتطلب التغييرات في أي من الاتجاهين المراجعة عند وجود تعارضات |

</Steps>

Expand Down
Loading
Loading